Skip to content

Commit

Permalink
Remove default from metrics (#507)
Browse files Browse the repository at this point in the history
* remove_default_from_metrics

* merge
  • Loading branch information
JKL98ISR committed Jan 5, 2022
1 parent a54f6fe commit a33f540
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
32 changes: 16 additions & 16 deletions deepchecks/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,39 +56,39 @@ class ModelType(enum.Enum):


DEFAULT_BINARY_SCORERS = {
'Accuracy (Default)': 'accuracy',
'Precision (Default)': make_scorer(precision_score, zero_division=0),
'Recall (Default)': make_scorer(recall_score, zero_division=0)
'Accuracy': 'accuracy',
'Precision': make_scorer(precision_score, zero_division=0),
'Recall': make_scorer(recall_score, zero_division=0)
}


DEFAULT_MULTICLASS_SCORERS = {
'Accuracy (Default)': 'accuracy',
'Precision - Macro Average (Default)': make_scorer(precision_score, average='macro', zero_division=0),
'Recall - Macro Average (Default)': make_scorer(recall_score, average='macro', zero_division=0)
'Accuracy': 'accuracy',
'Precision - Macro Average': make_scorer(precision_score, average='macro', zero_division=0),
'Recall - Macro Average': make_scorer(recall_score, average='macro', zero_division=0)
}

MULTICLASS_SCORERS_NON_AVERAGE = {
'F1 (Default)': make_scorer(f1_score, average=None, zero_division=0),
'Precision (Default)': make_scorer(precision_score, average=None, zero_division=0),
'Recall (Default)': make_scorer(recall_score, average=None, zero_division=0)
'F1': make_scorer(f1_score, average=None, zero_division=0),
'Precision': make_scorer(precision_score, average=None, zero_division=0),
'Recall': make_scorer(recall_score, average=None, zero_division=0)
}


DEFAULT_REGRESSION_SCORERS = {
'Neg RMSE (Default)': 'neg_root_mean_squared_error',
'Neg MAE (Default)': 'neg_mean_absolute_error',
'R2 (Default)': 'r2'
'Neg RMSE': 'neg_root_mean_squared_error',
'Neg MAE': 'neg_mean_absolute_error',
'R2': 'r2'
}


DEFAULT_SINGLE_SCORER = {
ModelType.BINARY: 'Accuracy (Default)',
ModelType.MULTICLASS: 'Accuracy (Default)',
ModelType.REGRESSION: 'Neg RMSE (Default)'
ModelType.BINARY: 'Accuracy',
ModelType.MULTICLASS: 'Accuracy',
ModelType.REGRESSION: 'Neg RMSE'
}

DEFAULT_SINGLE_SCORER_MULTICLASS_NON_AVG = 'F1 (Default)'
DEFAULT_SINGLE_SCORER_MULTICLASS_NON_AVG = 'F1'


DEFAULT_SCORERS_DICT = {
Expand Down
2 changes: 1 addition & 1 deletion tests/checks/performance/model_error_analysis_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_condition_fail(iris_labeled_dataset, iris_adaboost):
equal_condition_result(
is_pass=False,
name='The performance of the detected segments must not differ by more than 5.00%',
details='Change in Accuracy (Default) in features: petal length (cm) exceeds threshold.',
details='Change in Accuracy in features: petal length (cm) exceeds threshold.',
category=ConditionCategory.WARN
)
))
Expand Down
6 changes: 3 additions & 3 deletions tests/checks/performance/performance_report_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_condition_degradation_ratio_not_greater_than_not_passed(iris_split_data
# Assert
assert_that(result, has_items(
equal_condition_result(is_pass=False,
details=re.compile(r'F1 \(Default\) for class 1 \(train=0.94 test=0.88\)'),
details=re.compile(r'F1 for class 1 \(train=0.94 test=0.88\)'),
name='Train-Test scores relative degradation is not greater than 0')
))

Expand Down Expand Up @@ -198,7 +198,7 @@ def test_condition_class_performance_imbalance_ratio_not_greater_than_not_passed
equal_condition_result(is_pass=False,
details=re.compile('Relative ratio difference between highest and '
'lowest in Test dataset classes is 14.29%'),
name='Relative ratio difference between labels \'F1 (Default)\' '
name='Relative ratio difference between labels \'F1\' '
'score is not greater than 0%')
))

Expand All @@ -212,6 +212,6 @@ def test_condition_class_performance_imbalance_ratio_not_greater_than_passed(iri
# Assert
assert_that(result, has_items(
equal_condition_result(is_pass=True,
name='Relative ratio difference between labels \'F1 (Default)\' '
name='Relative ratio difference between labels \'F1\' '
'score is not greater than 100%')
))
6 changes: 3 additions & 3 deletions tests/checks/performance/simple_model_comparison_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_condition_ratio_not_less_than_not_passed(diabetes_split_dataset_and_mod
equal_condition_result(
is_pass=False,
name='Model performance gain over simple model must be at least 40.00%',
details='Metrics failed: "Neg RMSE (Default)"')
details='Metrics failed: "Neg RMSE"')
))


Expand All @@ -127,7 +127,7 @@ def test_condition_failed_for_multiclass(iris_split_dataset_and_model):
equal_condition_result(
is_pass=False,
name='Model performance gain over simple model must be at least 80.00%',
details='Metrics failed: "F1 (Default)" - Classes: 1')
details='Metrics failed: "F1" - Classes: 1')
))


Expand Down Expand Up @@ -157,7 +157,7 @@ def test_condition_pass_for_multiclass_avg_with_classes(iris_split_dataset_and_m
equal_condition_result(
is_pass=False,
name='Model performance gain over simple model must be at least 100%',
details='Metrics failed: "F1 (Default)" - Classes: 1, 2'
details='Metrics failed: "F1" - Classes: 1, 2'
),
equal_condition_result(
is_pass=True,
Expand Down

0 comments on commit a33f540

Please sign in to comment.