16
16
17
17
CLASSIFICATION_METRICS = ["areaUnderROC" , "areaUnderPR" ]
18
18
19
-
20
- def test_model_evaluator_with_linear_regression_and_tiny_dataset ( logistic_model , preprocessor ):
19
+ def test_model_evaluator_with_linear_regression_and_tiny_dataset ( logistic_model ,
20
+ preprocessor ):
21
21
_check_evaluation (preprocessor = preprocessor , model = logistic_model ,
22
22
metrics = {"areaUnderROC" : 1. , "areaUnderPR" : 1. })
23
23
24
-
25
- def test_model_evaluator_with_linear_regression_and_full_train_data ( logistic_model_train_data , preprocessor_train_data ):
24
+ def test_model_evaluator_with_linear_regression_and_full_train_data (
25
+ logistic_model_train_data , preprocessor_train_data ):
26
26
_check_evaluation (preprocessor = preprocessor_train_data ,
27
27
model = logistic_model_train_data ,
28
- metrics = {"areaUnderROC" : 0.764655781 , "areaUnderPR" : 0.63384702449 })
29
-
28
+ metrics = {"areaUnderROC" : 0.764655781 ,
29
+ "areaUnderPR" : 0.63384702449 })
30
30
31
31
def test_several_classification_models_fitting (preprocessor_train_data ):
32
32
df = preprocessor_train_data .train_df .sample (0.1 )
@@ -48,22 +48,24 @@ def test_several_classification_models_fitting(preprocessor_train_data):
48
48
"metrics" : {"areaUnderROC" : 0.615000 , "areaUnderPR" : 0.504709 }, },
49
49
]
50
50
for result in expected_results :
51
- _check_evaluation (preprocessor = preprocessor , model = result ["model" ], metrics = result [ "metrics" ])
52
-
51
+ _check_evaluation (preprocessor = preprocessor , model = result ["model" ],
52
+ metrics = result [ "metrics" ])
53
53
54
54
def _check_evaluation (preprocessor , model , metrics : Dict [str , float ]):
55
55
evaluator = ModelEvaluator (metrics_class = BinaryClassificationMetrics )
56
56
# The purpose of this parameter is to prove names can be arbitrary in the compare method
57
57
dataframes_sets = [['train' , 'test' ], ['train1' , 'test1' ]]
58
58
for dataframes in dataframes_sets :
59
59
comparison = evaluator .compare (
60
- data_frames = {dataframe : preprocessor .train_encoded_df for dataframe in dataframes },
60
+ data_frames = {dataframe : preprocessor .train_encoded_df for dataframe
61
+ in dataframes },
61
62
models = [model ])
62
63
63
64
assert isinstance (comparison , pandas .DataFrame )
64
65
65
66
for metric in metrics :
66
67
assert metric in comparison
67
68
for dataframe in dataframes :
68
- assert comparison [metric ][evaluator .index_key (dataframe , model )] == pytest .approx (metrics [metric ],
69
- abs = 0.035 )
69
+ assert \
70
+ comparison [metric ][evaluator .index_key (dataframe , model )] == \
71
+ pytest .approx (metrics [metric ], abs = 0.05 )
0 commit comments