From e043c38bbde903eb54f8bbe76973361b55a455f9 Mon Sep 17 00:00:00 2001 From: Denys Herasymuk Date: Sat, 14 Sep 2024 12:15:33 +0300 Subject: [PATCH] Fixed tests for Python 3.11 --- ...nTreeClassifier_50_Estimators_20240913.csv | 19 ------------------- ...ression_50_Estimators_202409013_220132.csv | 19 ------------------- .../test_multiple_models_api.py | 5 +++-- 3 files changed, 3 insertions(+), 40 deletions(-) delete mode 100644 tests/files_for_tests/law_school_dataset_20k/python_3_11/Metrics_law_school_DecisionTreeClassifier_50_Estimators_20240913.csv delete mode 100644 tests/files_for_tests/law_school_dataset_20k/python_3_11/Metrics_law_school_LogisticRegression_50_Estimators_202409013_220132.csv diff --git a/tests/files_for_tests/law_school_dataset_20k/python_3_11/Metrics_law_school_DecisionTreeClassifier_50_Estimators_20240913.csv b/tests/files_for_tests/law_school_dataset_20k/python_3_11/Metrics_law_school_DecisionTreeClassifier_50_Estimators_20240913.csv deleted file mode 100644 index 6e242bfa..00000000 --- a/tests/files_for_tests/law_school_dataset_20k/python_3_11/Metrics_law_school_DecisionTreeClassifier_50_Estimators_20240913.csv +++ /dev/null @@ -1,19 +0,0 @@ -Metric,overall,male_priv,male_dis,race_priv,race_dis,male&race_priv,male&race_dis,Model_Name,Virny_Random_State,Model_Params -Std,0.041588229003281706,0.04014981475236609,0.04348899069199162,0.035707999117036614,0.07429121098892864,0.03859272201556965,0.0763542646485458,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -IQR,0.053505982148091664,0.05084500766436651,0.05702226985872847,0.044968952602027774,0.10098479315664254,0.049091273172528614,0.1047433620765962,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -Aleatoric_Uncertainty,0.35318189936459926,0.3413540927984995,0.368811500898374,0.3031037696893525,0.6316921284417605,0.3271516798716977,0.6552902043882751,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -Statistical_Bias,0.14871459501539216,0.13922538692994388,0.1612539056997345,0.12087562594490028,0.3035414166913454,0.13498160237084172,0.3081005399506289,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -Mean_Prediction,0.10730163589001154,0.10127383420207314,0.11526694526335872,0.08243941922626423,0.2455732067991173,0.0941339892140465,0.26012614125045447,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -Overall_Uncertainty,0.37102753012884837,0.35860883223592943,0.3874379523444912,0.3189445800260836,0.6606875964732465,0.3439739430925971,0.6850131008829163,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -Epistemic_Uncertainty,0.01784563076424911,0.017254739437429945,0.018626451446117187,0.015840810336731126,0.028995468031486005,0.016822263220899414,0.029722896494641216,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -Jitter,0.03490286499215079,0.027672021511307245,0.044457908163265336,0.013944459235764642,0.15146333612309273,0.023045132413278664,0.1725244279529997,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -Label_Stability,0.9493557692307693,0.9616385135135135,0.9331249999999999,0.9821100397050483,0.767192429022082,0.9684804177545692,0.7273939393939394,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -TPR,0.9959763948497854,0.9986046511627907,0.9923954372623575,1.0,0.967741935483871,0.9991389207807119,0.9508196721311475,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -TNR,0.1111111111111111,0.06880733944954129,0.1542056074766355,0.0,0.28402366863905326,0.04335260115606936,0.38372093023255816,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -PPV,0.9062728825970222,0.9136170212765957,0.8963938179736691,0.9254112308564946,0.7880910683012259,0.9131689401888772,0.8140350877192982,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -FNR,0.004023605150214592,0.0013953488372093023,0.0076045627376425855,0.0,0.03225806451612903,0.0008610792192881745,0.04918032786885246,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -FPR,0.8888888888888888,0.9311926605504587,0.8457943925233645,1.0,0.7159763313609467,0.9566473988439307,0.6162790697674418,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -Accuracy,0.9040865384615384,0.9130067567567568,0.8922991071428571,0.9254112308564946,0.7854889589905363,0.9127937336814621,0.803030303030303,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -F1,0.9490095846645368,0.9542222222222222,0.9419548872180451,0.9612608631609957,0.8687258687258688,0.9542214912280702,0.8771266540642723,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -Selection-Rate,0.9848557692307692,0.9923986486486487,0.9748883928571429,1.0,0.9006309148264984,0.9953002610966057,0.8636363636363636,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" -Sample_Size,4160.0,2368.0,1792.0,3526.0,634.0,3830.0,330.0,DecisionTreeClassifier,100,"{'ccp_alpha': 0.0, 'class_weight': None, 'criterion': 'gini', 'max_depth': 20, 'max_features': 0.6, 'max_leaf_nodes': None, 'min_impurity_decrease': 0.0, 'min_samples_leaf': 1, 'min_samples_split': 0.1, 'min_weight_fraction_leaf': 0.0, 'random_state': None, 'splitter': 'best'}" diff --git a/tests/files_for_tests/law_school_dataset_20k/python_3_11/Metrics_law_school_LogisticRegression_50_Estimators_202409013_220132.csv b/tests/files_for_tests/law_school_dataset_20k/python_3_11/Metrics_law_school_LogisticRegression_50_Estimators_202409013_220132.csv deleted file mode 100644 index f9a516f8..00000000 --- a/tests/files_for_tests/law_school_dataset_20k/python_3_11/Metrics_law_school_LogisticRegression_50_Estimators_202409013_220132.csv +++ /dev/null @@ -1,19 +0,0 @@ -Metric,overall,male_priv,male_dis,race_priv,race_dis,male&race_priv,male&race_dis,Model_Name,Virny_Random_State,Model_Params -Std,0.00917147943187975,0.008607050335196386,0.00991733216678277,0.007286748976074028,0.01965343461669202,0.008239377682845418,0.01998950882218732,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -IQR,0.012256803023578407,0.0114453771719569,0.013329044327506827,0.009739371815789648,0.026257532422100754,0.010976514379656195,0.027115910618190745,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -Aleatoric_Uncertainty,0.34187256444638636,0.3224331953447354,0.3675603021878538,0.2923502561200833,0.6172915852011884,0.3152813861742172,0.6504913910597441,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -Statistical_Bias,0.13884987532254198,0.12866752312909457,0.15230512643531174,0.11307241003118768,0.28221161446657245,0.12620186366971659,0.28564346511139427,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -Mean_Prediction,0.10451562164187415,0.09389099362293032,0.11855530866690708,0.07598923254310201,0.26316553956343663,0.08851874474140387,0.2901763444564233,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -Overall_Uncertainty,0.3427815142556397,0.3232951664439477,0.3685313310068042,0.2930493994498858,0.6193673767242337,0.31609460569791553,0.6525113923649841,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -Epistemic_Uncertainty,0.0009089498092533232,0.0008619710992122664,0.0009710288189503924,0.0006991433298024763,0.0020757915230452673,0.0008132195236983386,0.002020001305240049,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -Jitter,0.008828885400313994,0.007884376723662437,0.010076986151603502,0.005247780337319282,0.02874525204403535,0.006921084883039359,0.030970933828076638,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -Label_Stability,0.9874423076923078,0.9889695945945947,0.9854241071428572,0.9924333522404991,0.9596845425867508,0.9902872062663186,0.9544242424242425,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -TPR,0.9849785407725322,0.9897674418604652,0.9784537389100126,0.9947900704872816,0.9161290322580645,0.9913892078071183,0.8934426229508197,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -TNR,0.24074074074074073,0.17889908256880735,0.3037383177570093,0.11787072243346007,0.4319526627218935,0.16473988439306358,0.5465116279069767,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -PPV,0.918,0.9224100563502384,0.9119905493207324,0.9332949971247844,0.8160919540229885,0.9227892065188351,0.8482490272373541,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -FNR,0.015021459227467811,0.010232558139534883,0.021546261089987327,0.005209929512718358,0.08387096774193549,0.008610792192881744,0.10655737704918032,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -FPR,0.7592592592592593,0.8211009174311926,0.6962616822429907,0.8821292775665399,0.5680473372781065,0.8352601156069365,0.45348837209302323,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -Accuracy,0.9076923076923077,0.9151182432432432,0.8978794642857143,0.9293817356778219,0.7870662460567823,0.9167101827676241,0.803030303030303,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -F1,0.9503105590062112,0.9549024007179717,0.9440538061754815,0.9630618602581219,0.8632218844984803,0.9558599695585996,0.8702594810379242,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -Selection-Rate,0.9615384615384616,0.9742398648648649,0.9447544642857143,0.9863868406125922,0.8233438485804416,0.9772845953002611,0.7787878787878788,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" -Sample_Size,4160.0,2368.0,1792.0,3526.0,634.0,3830.0,330.0,LogisticRegression,100,"{'C': 0.1, 'class_weight': None, 'dual': False, 'fit_intercept': True, 'intercept_scaling': 1, 'l1_ratio': None, 'max_iter': 250, 'multi_class': 'auto', 'n_jobs': None, 'penalty': 'l2', 'random_state': None, 'solver': 'lbfgs', 'tol': 0.0001, 'verbose': 0, 'warm_start': False}" diff --git a/tests/user_interfaces/test_multiple_models_api.py b/tests/user_interfaces/test_multiple_models_api.py index b2412b5d..5d34de34 100644 --- a/tests/user_interfaces/test_multiple_models_api.py +++ b/tests/user_interfaces/test_multiple_models_api.py @@ -99,5 +99,6 @@ def test_compute_metrics_with_config_should_equal_prev_release_results(law_schoo metrics_dct['LogisticRegression'] = metrics_dct['LogisticRegression'].drop('Runtime_in_Mins', axis=1) metrics_dct['DecisionTreeClassifier'] = metrics_dct['DecisionTreeClassifier'].drop('Runtime_in_Mins', axis=1) - assert compare_metric_dfs_with_tolerance(expected_metrics_dct['LogisticRegression'], metrics_dct['LogisticRegression']) - assert compare_metric_dfs_with_tolerance(expected_metrics_dct['DecisionTreeClassifier'], metrics_dct['DecisionTreeClassifier']) + tolerance = 1e-4 if sys.version_info.major == 3 and sys.version_info.minor == 11 else 1e-6 + assert compare_metric_dfs_with_tolerance(expected_metrics_dct['LogisticRegression'], metrics_dct['LogisticRegression'], tolerance) + assert compare_metric_dfs_with_tolerance(expected_metrics_dct['DecisionTreeClassifier'], metrics_dct['DecisionTreeClassifier'], tolerance)