Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for explain_model function. gssoc-extd #24

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

NikhilJ2005
Copy link

WhatsApp Image 2024-10-02 at 8 08 51 AM
WhatsApp Image 2024-10-02 at 8 08 51 AM (3)
WhatsApp Image 2024-10-02 at 8 08 51 AM (1)
WhatsApp Image 2024-10-02 at 8 08 50 AM (1)

Description: This pull request introduces a series of unit tests for the explain_model and calculate_metrics functions located in the utils.py file of the explainableai directory. These tests use the pytest framework to ensure the functions work correctly for both regression and classification models.

Added Tests:

test_explain_model_regression:

Tests the explain_model function using a LinearRegression model.
Checks if the returned explanation contains keys "feature_importance" and "model_type".
Verifies that the model type matches the expected linear regression model and that the number of feature importances corresponds to the number of input features.
test_explain_model_classification:

Tests the explain_model function using a LogisticRegression model.
Checks if the explanation contains keys "feature_importance" and "model_type".
Confirms the model type matches the logistic regression model and that the number of feature importances matches the input feature count.
test_calculate_metrics_regression:

Tests the calculate_metrics function with a LinearRegression model.
Verifies that the metrics returned include "mse" (Mean Squared Error) and "r2" (R-squared).
test_calculate_metrics_classification:

Tests the calculate_metrics function using a LogisticRegression model.
Ensures the returned metrics contain "accuracy" and "f1_score".

Used Pytest to acheive this.
WhatsApp Image 2024-10-02 at 8 08 51 AM (1)
WhatsApp Image 2024-10-02 at 8 08 51 AM (2)

@ombhojane
Copy link
Owner

Thank you for your contribution!

@ombhojane ombhojane merged commit 5f51c33 into ombhojane:main Oct 2, 2024
1 of 4 checks passed
@NikhilJ2005 NikhilJ2005 changed the title Added tests for explain_model function Added tests for explain_model function. gssoc-extd Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants