mljar-supervised 1.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mljar_supervised-1.2.1.dist-info/METADATA +657 -0
- mljar_supervised-1.2.1.dist-info/RECORD +94 -0
- mljar_supervised-1.2.1.dist-info/WHEEL +5 -0
- mljar_supervised-1.2.1.dist-info/licenses/LICENSE +21 -0
- mljar_supervised-1.2.1.dist-info/top_level.txt +1 -0
- supervised/__init__.py +14 -0
- supervised/algorithms/__init__.py +0 -0
- supervised/algorithms/algorithm.py +151 -0
- supervised/algorithms/baseline.py +90 -0
- supervised/algorithms/catboost.py +436 -0
- supervised/algorithms/decision_tree.py +305 -0
- supervised/algorithms/extra_trees.py +176 -0
- supervised/algorithms/factory.py +28 -0
- supervised/algorithms/knn.py +137 -0
- supervised/algorithms/lightgbm.py +406 -0
- supervised/algorithms/linear.py +211 -0
- supervised/algorithms/nn.py +180 -0
- supervised/algorithms/random_forest.py +181 -0
- supervised/algorithms/registry.py +76 -0
- supervised/algorithms/sklearn.py +197 -0
- supervised/algorithms/xgboost.py +413 -0
- supervised/automl.py +568 -0
- supervised/base_automl.py +2542 -0
- supervised/callbacks/__init__.py +0 -0
- supervised/callbacks/callback.py +25 -0
- supervised/callbacks/callback_list.py +33 -0
- supervised/callbacks/early_stopping.py +213 -0
- supervised/callbacks/learner_time_constraint.py +47 -0
- supervised/callbacks/max_iters_constraint.py +16 -0
- supervised/callbacks/metric_logger.py +48 -0
- supervised/callbacks/terminate_on_nan.py +28 -0
- supervised/callbacks/total_time_constraint.py +79 -0
- supervised/ensemble.py +583 -0
- supervised/exceptions.py +21 -0
- supervised/fairness/__init__.py +0 -0
- supervised/fairness/metrics.py +654 -0
- supervised/fairness/optimization.py +414 -0
- supervised/fairness/plots.py +131 -0
- supervised/fairness/report.py +116 -0
- supervised/fairness/utils.py +40 -0
- supervised/model_framework.py +734 -0
- supervised/preprocessing/__init__.py +0 -0
- supervised/preprocessing/datetime_transformer.py +106 -0
- supervised/preprocessing/encoding_selector.py +30 -0
- supervised/preprocessing/exclude_missing_target.py +46 -0
- supervised/preprocessing/goldenfeatures_transformer.py +310 -0
- supervised/preprocessing/kmeans_transformer.py +115 -0
- supervised/preprocessing/label_binarizer.py +81 -0
- supervised/preprocessing/label_encoder.py +54 -0
- supervised/preprocessing/preprocessing.py +652 -0
- supervised/preprocessing/preprocessing_categorical.py +117 -0
- supervised/preprocessing/preprocessing_missing.py +97 -0
- supervised/preprocessing/preprocessing_utils.py +136 -0
- supervised/preprocessing/scale.py +92 -0
- supervised/preprocessing/text_transformer.py +73 -0
- supervised/tuner/__init__.py +0 -0
- supervised/tuner/data_info.py +64 -0
- supervised/tuner/hill_climbing.py +80 -0
- supervised/tuner/mljar_tuner.py +1501 -0
- supervised/tuner/optuna/__init__.py +0 -0
- supervised/tuner/optuna/catboost.py +148 -0
- supervised/tuner/optuna/extra_trees.py +80 -0
- supervised/tuner/optuna/knn.py +64 -0
- supervised/tuner/optuna/lightgbm.py +165 -0
- supervised/tuner/optuna/nn.py +66 -0
- supervised/tuner/optuna/random_forest.py +77 -0
- supervised/tuner/optuna/tuner.py +335 -0
- supervised/tuner/optuna/xgboost.py +130 -0
- supervised/tuner/preprocessing_tuner.py +137 -0
- supervised/tuner/random_parameters.py +22 -0
- supervised/tuner/time_controller.py +273 -0
- supervised/utils/__init__.py +11 -0
- supervised/utils/additional_metrics.py +955 -0
- supervised/utils/additional_plots.py +228 -0
- supervised/utils/automl_plots.py +368 -0
- supervised/utils/common.py +39 -0
- supervised/utils/config.py +25 -0
- supervised/utils/constants.py +4 -0
- supervised/utils/data_validation.py +48 -0
- supervised/utils/importance.py +93 -0
- supervised/utils/jsonencoder.py +33 -0
- supervised/utils/leaderboard_plots.py +137 -0
- supervised/utils/learning_curves.py +145 -0
- supervised/utils/metric.py +450 -0
- supervised/utils/report_structured.py +525 -0
- supervised/utils/shap.py +373 -0
- supervised/utils/subsample.py +17 -0
- supervised/utils/utils.py +29 -0
- supervised/validation/__init__.py +0 -0
- supervised/validation/validation_step.py +37 -0
- supervised/validation/validator_base.py +17 -0
- supervised/validation/validator_custom.py +112 -0
- supervised/validation/validator_kfold.py +153 -0
- supervised/validation/validator_split.py +143 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
mljar_supervised-1.2.1.dist-info/licenses/LICENSE,sha256=F30c0zOLSlK65-rn_v1JEtNTvVkLf2WV7frt9YQ1Kwc,1073
|
|
2
|
+
supervised/__init__.py,sha256=wto_CkCup0p8SF4hi6wz7hQPIQ7ovKh7f6RiSTgjnmI,262
|
|
3
|
+
supervised/automl.py,sha256=jKcfVpu_Wyo7R6EQ_YKPaTpk5JCUcCbLJZ3Y9-4XCzM,26742
|
|
4
|
+
supervised/base_automl.py,sha256=i14VrhKYKZfG1ZM7tdMO4SojOipVsKq7f5bVPi7354E,101174
|
|
5
|
+
supervised/ensemble.py,sha256=GCVp0SmKG5v2fF_9iJgZ9he7V-5iRXDTvlMasGd2pm0,22942
|
|
6
|
+
supervised/exceptions.py,sha256=9m-ovWlN9tYCI4MPPmmGlDC1cL3LNpKew-WMHFlpzsk,547
|
|
7
|
+
supervised/model_framework.py,sha256=eWdw31NS59Eu_g4l3hjWqSoIunDj2WH84hx_UWAbjRQ,29319
|
|
8
|
+
supervised/algorithms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
supervised/algorithms/algorithm.py,sha256=SQ5ezI7JRyg5T84SiZc2N54HijgeKc92LZ0XQTi6Ow0,4229
|
|
10
|
+
supervised/algorithms/baseline.py,sha256=zD8j2teM5vmlS-8aTS-I8uWbwiT0NH87sdBEVhHNurI,2475
|
|
11
|
+
supervised/algorithms/catboost.py,sha256=c5B7nvDnPWow8oi-UxjTNyfQadwDxMcTiorYhjAZdyk,14719
|
|
12
|
+
supervised/algorithms/decision_tree.py,sha256=dQ5pAYCBVPszgtTDTwNYIEr30YZU3YvIegPXsFyGhwU,9175
|
|
13
|
+
supervised/algorithms/extra_trees.py,sha256=TvpgJ8HZI6sJs-QPg4GHsHuq6by1oUyVuNUwdnBF1UY,5161
|
|
14
|
+
supervised/algorithms/factory.py,sha256=8GYpCzCxLN8e5qbROXxztBacDJeNLoyDKfDprfWYWSM,911
|
|
15
|
+
supervised/algorithms/knn.py,sha256=X5jiuhgoPUzWpGwT69mNSPGK7UcuPEfzXu2XlrwnvZ8,3710
|
|
16
|
+
supervised/algorithms/lightgbm.py,sha256=HGvV_0IyhJLs1guGivxc8LsEK7xHw4cZG4eAJcWuRAA,12349
|
|
17
|
+
supervised/algorithms/linear.py,sha256=LUMbMRHnbliFhRKu4spI4JHztL8wPVBZ-qEA-Pz70-A,5833
|
|
18
|
+
supervised/algorithms/nn.py,sha256=oh8s0rGDf4bEW9ybmhXHHrQ8laZ6ep6FoFIXnnyqBmc,4842
|
|
19
|
+
supervised/algorithms/random_forest.py,sha256=lWFf70UMHEEyFFwFZZHINMWeJBF_yUQ73QuN9M3lbE0,5282
|
|
20
|
+
supervised/algorithms/registry.py,sha256=qdbN8WdUmt0PpIFXNW3uaZrNJXLH8n-PPJmdyqzkPKE,2346
|
|
21
|
+
supervised/algorithms/sklearn.py,sha256=air9ih-pDQ-Oi6eBUa982iPF5G15Eb7gPvWl_2XkG7M,6245
|
|
22
|
+
supervised/algorithms/xgboost.py,sha256=_PPDOUsS7DQLgFlxCVSE7U4ixAK6YyMa6b3HDl-s89c,12733
|
|
23
|
+
supervised/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
+
supervised/callbacks/callback.py,sha256=voqhdjnlsAc1zrtm4i74ysSwRLI-AIl60PB9Ji5Jhnw,592
|
|
25
|
+
supervised/callbacks/callback_list.py,sha256=tstUgUsLhe4aILjxfbA0NGdqtVhDVvvmuIZOydo3DSg,1027
|
|
26
|
+
supervised/callbacks/early_stopping.py,sha256=HPgEYUmbL208pH2KXUVm43H-1pdqtbXUzg2_5AYgPKw,9018
|
|
27
|
+
supervised/callbacks/learner_time_constraint.py,sha256=JuQVkRnZ_FzigZeoMfWz5K8h-5muJw-ap34eYMPpOzw,1701
|
|
28
|
+
supervised/callbacks/max_iters_constraint.py,sha256=FuCUAbwPj6MFj0e1IpbPu-VTd4NuKtf996xAEOZLsnU,568
|
|
29
|
+
supervised/callbacks/metric_logger.py,sha256=z1DTERDa0KTvE5Zh3cVI4zir5HBo5THrIxJW8eTlg5Y,1847
|
|
30
|
+
supervised/callbacks/terminate_on_nan.py,sha256=YzpSLYoP6VJcEptHSUZD7rKbEA3Bwf66Db2iPAWP4qs,933
|
|
31
|
+
supervised/callbacks/total_time_constraint.py,sha256=_qHl1gDmFuNlUMVC6RWPCkG8ggdZOm0kPnR2mB4ZogU,3353
|
|
32
|
+
supervised/fairness/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
|
+
supervised/fairness/metrics.py,sha256=p5Z1HTBTtWJ44mvXtv354zbPRmNiHtfi7WK7nSSQsq0,26141
|
|
34
|
+
supervised/fairness/optimization.py,sha256=L2M8eXmp9L4yVZg8wOA2C3BBAL_SO1JdSTHsSZ9JDfQ,15001
|
|
35
|
+
supervised/fairness/plots.py,sha256=GWxN3rCEPaHn4mOrR-pOCsdaE47gQkH4z9ZKLar1ETE,4049
|
|
36
|
+
supervised/fairness/report.py,sha256=c_I3AsCtLIpFgL6EFc1p_y8fDjGSQ5kyjIXwUGHCELY,4975
|
|
37
|
+
supervised/fairness/utils.py,sha256=tJXO1rLrxSnCogxOyRUk7iGN5iXvOHg_yIKqhww4uTE,701
|
|
38
|
+
supervised/preprocessing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
|
+
supervised/preprocessing/datetime_transformer.py,sha256=GY8ru25XiGufo0bvxMpN_6O63KeCi0NvEFde7ujVg8w,3535
|
|
40
|
+
supervised/preprocessing/encoding_selector.py,sha256=BE-SbKBaOhFmmPPBHuqSG7loPz0QBh4j9GQ8Lory9X0,835
|
|
41
|
+
supervised/preprocessing/exclude_missing_target.py,sha256=DitRhlFo91o7XBjt8EO-nEiNXa1BchmGbjDkj3OOldE,1517
|
|
42
|
+
supervised/preprocessing/goldenfeatures_transformer.py,sha256=QAFBAdLA79mObMshVX0ZS-nvQlh5PQ-bZc62i7nqr_0,10846
|
|
43
|
+
supervised/preprocessing/kmeans_transformer.py,sha256=qel2EJrFDBKBwrEWXiFjJFLe_y79gZytHKi_5jqL4LA,3819
|
|
44
|
+
supervised/preprocessing/label_binarizer.py,sha256=oIhdD9GeilHo361yUIeqMsLBRsCb9GNV20iZspBHEqM,2700
|
|
45
|
+
supervised/preprocessing/label_encoder.py,sha256=915erpxnw1iafTp51l3vA96rpr5HmJnYG5kiNAcOWvw,1793
|
|
46
|
+
supervised/preprocessing/preprocessing.py,sha256=NB9zvAxr9Li4cAq0wE9ksq3f7mw4QPX10YlbsKW5gsc,26337
|
|
47
|
+
supervised/preprocessing/preprocessing_categorical.py,sha256=kKhLivsNHRFTiwIZiyEkIS1dnCAw2SQRZADb7pP8Hv0,4745
|
|
48
|
+
supervised/preprocessing/preprocessing_missing.py,sha256=R9dfH69cl51B49bllZLjGs5WsAwsnJ_6yNF0q-IncJc,3737
|
|
49
|
+
supervised/preprocessing/preprocessing_utils.py,sha256=3ctyxNwXR1DL1U7_KpeBLeIAD-GVmOKV9MnGK1_E5-U,4038
|
|
50
|
+
supervised/preprocessing/scale.py,sha256=umR_j24PQpTeNs1z4WF2j4oqWyKIj-NA1_WesssO5no,3779
|
|
51
|
+
supervised/preprocessing/text_transformer.py,sha256=eY1qgEyiEU2XzarnKGg1SOtAV_35G2sxL7B80MXXheM,2585
|
|
52
|
+
supervised/tuner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
|
+
supervised/tuner/data_info.py,sha256=GHf1Gb37mJtoC7ZjT44nTo2TzJqpEgdJBP8K_RnTac8,2361
|
|
54
|
+
supervised/tuner/hill_climbing.py,sha256=FlHAFxE6Jw0cJc1lp5bQ5PV4zMtKZfQxbiPzJSXwxiU,2346
|
|
55
|
+
supervised/tuner/mljar_tuner.py,sha256=MJ8jPxDz9hsxgJZbhArrmZHpVrLMJxJNKhkrkne_NhQ,58809
|
|
56
|
+
supervised/tuner/preprocessing_tuner.py,sha256=p2me6Q8Iv0_EpphTjTD-FRg3OHofkTuevFc1SmG_RSg,5979
|
|
57
|
+
supervised/tuner/random_parameters.py,sha256=3VNstZQmzaSKiU2gm7iR7DkjzZ5NSOq4JwcGKKvuSg8,564
|
|
58
|
+
supervised/tuner/time_controller.py,sha256=M0USrnnMpybA0knA0G3Old8h8o50AppaW2SxyGwyiwY,8944
|
|
59
|
+
supervised/tuner/optuna/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
60
|
+
supervised/tuner/optuna/catboost.py,sha256=vHEl8v1M1jTVH2nY4IFyGIoBccpfBu8g-z86lskQB8k,5539
|
|
61
|
+
supervised/tuner/optuna/extra_trees.py,sha256=hydXetsghgwxhjVz21KUUTvFtMfLPW50DUvQVLOGhaI,2510
|
|
62
|
+
supervised/tuner/optuna/knn.py,sha256=QRiFR5g7h8hcs6tXev1ym2YFfqmVo9MZLazLYRnfH4Q,1910
|
|
63
|
+
supervised/tuner/optuna/lightgbm.py,sha256=dkbXK8a-OOlAHoblMrzo27eIxQjI0mqQVrs-jWD1h0U,5922
|
|
64
|
+
supervised/tuner/optuna/nn.py,sha256=Hytn000Vxto2cp-aF_TaxIEnV0MjEqQyU-IYA0uE_hE,2122
|
|
65
|
+
supervised/tuner/optuna/random_forest.py,sha256=PWw_zUVuvw4N_I4hZ8YdTbQQMkff3gT2TL9i3jg4PM0,2511
|
|
66
|
+
supervised/tuner/optuna/tuner.py,sha256=78iX6R-hwiW5ICXuq12fBiQv_GXN661j8ve-RNoQtyM,11606
|
|
67
|
+
supervised/tuner/optuna/xgboost.py,sha256=h4x12yKsRfc9tlZnDvj51MyPU9BBS6FKuSJgZ8m-Uf4,4753
|
|
68
|
+
supervised/utils/__init__.py,sha256=bNfSKVX2-H2GgtQO5IwPPBHxZWZBU_F1kfl13QVwijg,259
|
|
69
|
+
supervised/utils/additional_metrics.py,sha256=lp5H0a3P6F_K0YsWMmGLCPmhmxHwfdEsUi6iR93KTXY,37054
|
|
70
|
+
supervised/utils/additional_plots.py,sha256=mX0ScTYbKxEIgfuEPcjFQbRiCFj5QZ_5WrdKIugFrEw,8148
|
|
71
|
+
supervised/utils/automl_plots.py,sha256=qE6936r_TDuYmsEmx0IwUOyaCVOg_1kwaotfIfNnISo,17043
|
|
72
|
+
supervised/utils/common.py,sha256=lBe8NAk93Ig8X0d2qsgRcYGMHAd_gKEyhoS6xr_WAms,1052
|
|
73
|
+
supervised/utils/config.py,sha256=rQ2BSAO3Uy33Gfa2CJ9QuIxmHbVM0ukGmABYQ-o1JXg,524
|
|
74
|
+
supervised/utils/constants.py,sha256=nBCex_lwIF2QyXX-m2US2AHGGIR4i99Pdw6szpuRykk,173
|
|
75
|
+
supervised/utils/data_validation.py,sha256=G6serv0Yl5armM_1fcHmMpUuBOXtItWcds2PkuPjXJA,1481
|
|
76
|
+
supervised/utils/importance.py,sha256=uGZaiPezBLd3NFxk9LbnHOXrvftHtkbHNKoEUViUfFc,3015
|
|
77
|
+
supervised/utils/jsonencoder.py,sha256=hJj8Qe0xNsP3DGQgqrW4KvVVez4IqlU2s6rfJWlZ9qw,823
|
|
78
|
+
supervised/utils/leaderboard_plots.py,sha256=xOB-r5y84vjXKFWPEYNBQYynuds-EWBR4mxy1h9hvdc,4941
|
|
79
|
+
supervised/utils/learning_curves.py,sha256=Va6luMon1yYwZnDcpLyJqiHAB5TLutTqw4Pg8lt-LI4,4972
|
|
80
|
+
supervised/utils/metric.py,sha256=8AkSEAxNZkz-SvYcuxA29z1ZpHtXMnVh8XJdJHt_Ld8,13242
|
|
81
|
+
supervised/utils/report_structured.py,sha256=T8PVG5FCwMPfALEV-cuQO7tJlNnhsKxhb6sMfk6a35w,18242
|
|
82
|
+
supervised/utils/shap.py,sha256=0kq2HPsG1WHOg5ovBFFAHy-pfoQ-1NQub3m0ULX73Yc,12455
|
|
83
|
+
supervised/utils/subsample.py,sha256=LQLBBey9YKB95xpdY2EiknOT_YrdzCGTWFUduFapClE,424
|
|
84
|
+
supervised/utils/utils.py,sha256=V_ec1YkOzaCKm_CYfqbI2OHv9m1ZH79Jk34OReSESZU,589
|
|
85
|
+
supervised/validation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
86
|
+
supervised/validation/validation_step.py,sha256=CyrYXGzuDFdYI7L2IjRQAmnyAASNm86Hy-gj_61Q4MQ,1210
|
|
87
|
+
supervised/validation/validator_base.py,sha256=6ghMmNLQoeVxvQA-AenKgij-4R2pJnx7qy_lsRB1zqs,264
|
|
88
|
+
supervised/validation/validator_custom.py,sha256=3gbwDn9af8iJIb8VMjj0sAcNZhFh9u3W5RB0JBmgHwU,4087
|
|
89
|
+
supervised/validation/validator_kfold.py,sha256=rvxsfv6tz4YlccyNot3EZuJZJCpCaVrc0LY0wC4LgfE,5548
|
|
90
|
+
supervised/validation/validator_split.py,sha256=eZiHfRsYVY9mOlnvHi7cuBCOZzeMmZ-5C0rQduLnIH8,4751
|
|
91
|
+
mljar_supervised-1.2.1.dist-info/METADATA,sha256=2PE1IqkR93UjXIRGcDV1MvttRgTwDsaf_plOyFuEa9o,27627
|
|
92
|
+
mljar_supervised-1.2.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
93
|
+
mljar_supervised-1.2.1.dist-info/top_level.txt,sha256=ShMnWfsjqWoXIvvw2WArpKSrpfVo1K9fnN5vMOqCqro,11
|
|
94
|
+
mljar_supervised-1.2.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 MLJAR Sp. z o.o.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
supervised
|
supervised/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
__version__ = "1.2.1"
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _ensure_numpy_compat():
|
|
7
|
+
if not hasattr(np, "in1d"):
|
|
8
|
+
# NumPy 2.4 removed np.in1d; some dependencies still use it.
|
|
9
|
+
np.in1d = np.isin
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
_ensure_numpy_compat()
|
|
13
|
+
|
|
14
|
+
from supervised.automl import AutoML
|
|
File without changes
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import uuid
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from sklearn.base import BaseEstimator
|
|
6
|
+
|
|
7
|
+
from supervised.utils.common import construct_learner_name
|
|
8
|
+
from supervised.utils.importance import PermutationImportance
|
|
9
|
+
from supervised.utils.shap import PlotSHAP
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class BaseAlgorithm(BaseEstimator):
|
|
13
|
+
"""
|
|
14
|
+
This is an abstract class.
|
|
15
|
+
All algorithms inherit from BaseAlgorithm.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
algorithm_name = "Unknown"
|
|
19
|
+
algorithm_short_name = "Unknown"
|
|
20
|
+
|
|
21
|
+
def __init__(self, params):
|
|
22
|
+
self.params = params
|
|
23
|
+
self.stop_training = False
|
|
24
|
+
self.library_version = None
|
|
25
|
+
self.model = None
|
|
26
|
+
self.uid = params.get("uid", str(uuid.uuid4()))
|
|
27
|
+
self.ml_task = params.get("ml_task")
|
|
28
|
+
self.model_file_path = None
|
|
29
|
+
self.name = "amazing_learner"
|
|
30
|
+
|
|
31
|
+
def set_learner_name(self, fold, repeat, repeats):
|
|
32
|
+
self.name = construct_learner_name(fold, repeat, repeats)
|
|
33
|
+
|
|
34
|
+
def is_fitted(self):
|
|
35
|
+
# base class method
|
|
36
|
+
return False
|
|
37
|
+
|
|
38
|
+
def reload(self):
|
|
39
|
+
if not self.is_fitted() and self.model_file_path is not None:
|
|
40
|
+
self.load(self.model_file_path)
|
|
41
|
+
|
|
42
|
+
def fit(
|
|
43
|
+
self,
|
|
44
|
+
X,
|
|
45
|
+
y,
|
|
46
|
+
sample_weight=None,
|
|
47
|
+
X_validation=None,
|
|
48
|
+
y_validation=None,
|
|
49
|
+
sample_weight_validation=None,
|
|
50
|
+
log_to_file=None,
|
|
51
|
+
max_time=None,
|
|
52
|
+
):
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
def predict(self, X):
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
# needed for feature importance
|
|
59
|
+
def predict_proba(self, X):
|
|
60
|
+
y = self.predict(X)
|
|
61
|
+
if "num_class" in self.params and self.params["num_class"] > 2:
|
|
62
|
+
return y
|
|
63
|
+
return np.column_stack((1 - y, y))
|
|
64
|
+
|
|
65
|
+
def update(self, update_params):
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
def copy(self):
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
def save(self, model_file_path):
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
def load(self, model_file_path):
|
|
75
|
+
pass
|
|
76
|
+
|
|
77
|
+
def get_fname(self):
|
|
78
|
+
return f"{self.name}.{self.file_extension()}"
|
|
79
|
+
|
|
80
|
+
def interpret(
|
|
81
|
+
self,
|
|
82
|
+
X_train,
|
|
83
|
+
y_train,
|
|
84
|
+
X_validation,
|
|
85
|
+
y_validation,
|
|
86
|
+
model_file_path,
|
|
87
|
+
learner_name,
|
|
88
|
+
target_name=None,
|
|
89
|
+
class_names=None,
|
|
90
|
+
metric_name=None,
|
|
91
|
+
ml_task=None,
|
|
92
|
+
explain_level=2,
|
|
93
|
+
):
|
|
94
|
+
# do not produce feature importance for Baseline
|
|
95
|
+
if self.algorithm_short_name == "Baseline":
|
|
96
|
+
return
|
|
97
|
+
if explain_level > 0:
|
|
98
|
+
PermutationImportance.compute_and_plot(
|
|
99
|
+
self,
|
|
100
|
+
X_validation,
|
|
101
|
+
y_validation,
|
|
102
|
+
model_file_path,
|
|
103
|
+
learner_name,
|
|
104
|
+
metric_name,
|
|
105
|
+
ml_task,
|
|
106
|
+
self.params.get("n_jobs", -1),
|
|
107
|
+
)
|
|
108
|
+
if explain_level > 1:
|
|
109
|
+
PlotSHAP.compute(
|
|
110
|
+
self,
|
|
111
|
+
X_train,
|
|
112
|
+
y_train,
|
|
113
|
+
X_validation,
|
|
114
|
+
y_validation,
|
|
115
|
+
model_file_path,
|
|
116
|
+
learner_name,
|
|
117
|
+
class_names,
|
|
118
|
+
ml_task,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
def get_metric_name(self):
|
|
122
|
+
return None
|
|
123
|
+
|
|
124
|
+
def get_params(self):
|
|
125
|
+
params = {
|
|
126
|
+
"library_version": self.library_version,
|
|
127
|
+
"algorithm_name": self.algorithm_name,
|
|
128
|
+
"algorithm_short_name": self.algorithm_short_name,
|
|
129
|
+
"uid": self.uid,
|
|
130
|
+
"params": self.params,
|
|
131
|
+
"name": self.name,
|
|
132
|
+
}
|
|
133
|
+
if hasattr(self, "best_ntree_limit") and self.best_ntree_limit is not None:
|
|
134
|
+
params["best_ntree_limit"] = self.best_ntree_limit
|
|
135
|
+
return params
|
|
136
|
+
|
|
137
|
+
def set_params(self, json_desc, learner_path):
|
|
138
|
+
self.library_version = json_desc.get("library_version", self.library_version)
|
|
139
|
+
self.algorithm_name = json_desc.get("algorithm_name", self.algorithm_name)
|
|
140
|
+
self.algorithm_short_name = json_desc.get(
|
|
141
|
+
"algorithm_short_name", self.algorithm_short_name
|
|
142
|
+
)
|
|
143
|
+
self.uid = json_desc.get("uid", self.uid)
|
|
144
|
+
self.params = json_desc.get("params", self.params)
|
|
145
|
+
self.name = json_desc.get("name", self.name)
|
|
146
|
+
self.model_file_path = learner_path
|
|
147
|
+
|
|
148
|
+
if hasattr(self, "best_ntree_limit"):
|
|
149
|
+
self.best_ntree_limit = json_desc.get(
|
|
150
|
+
"best_ntree_limit", self.best_ntree_limit
|
|
151
|
+
)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import sklearn
|
|
4
|
+
from sklearn.base import ClassifierMixin, RegressorMixin
|
|
5
|
+
from sklearn.dummy import DummyClassifier, DummyRegressor
|
|
6
|
+
|
|
7
|
+
from supervised.algorithms.registry import (
|
|
8
|
+
BINARY_CLASSIFICATION,
|
|
9
|
+
MULTICLASS_CLASSIFICATION,
|
|
10
|
+
REGRESSION,
|
|
11
|
+
AlgorithmsRegistry,
|
|
12
|
+
)
|
|
13
|
+
from supervised.algorithms.sklearn import SklearnAlgorithm
|
|
14
|
+
from supervised.utils.config import LOG_LEVEL
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
logger.setLevel(LOG_LEVEL)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class BaselineClassifierAlgorithm(ClassifierMixin, SklearnAlgorithm):
|
|
21
|
+
algorithm_name = "Baseline Classifier"
|
|
22
|
+
algorithm_short_name = "Baseline"
|
|
23
|
+
|
|
24
|
+
def __init__(self, params):
|
|
25
|
+
super(BaselineClassifierAlgorithm, self).__init__(params)
|
|
26
|
+
logger.debug("BaselineClassifierAlgorithm.__init__")
|
|
27
|
+
|
|
28
|
+
self.library_version = sklearn.__version__
|
|
29
|
+
self.max_iters = additional.get("max_steps", 1)
|
|
30
|
+
self.model = DummyClassifier(
|
|
31
|
+
strategy="prior", random_state=params.get("seed", 1)
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
def file_extension(self):
|
|
35
|
+
return "baseline"
|
|
36
|
+
|
|
37
|
+
def is_fitted(self):
|
|
38
|
+
return (
|
|
39
|
+
hasattr(self.model, "n_outputs_")
|
|
40
|
+
and self.model.n_outputs_ is not None
|
|
41
|
+
and self.model.n_outputs_ > 0
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class BaselineRegressorAlgorithm(RegressorMixin, SklearnAlgorithm):
|
|
46
|
+
algorithm_name = "Baseline Regressor"
|
|
47
|
+
algorithm_short_name = "Baseline"
|
|
48
|
+
|
|
49
|
+
def __init__(self, params):
|
|
50
|
+
super(BaselineRegressorAlgorithm, self).__init__(params)
|
|
51
|
+
logger.debug("BaselineRegressorAlgorithm.__init__")
|
|
52
|
+
|
|
53
|
+
self.library_version = sklearn.__version__
|
|
54
|
+
self.max_iters = additional.get("max_steps", 1)
|
|
55
|
+
self.model = DummyRegressor(strategy="mean")
|
|
56
|
+
|
|
57
|
+
def file_extension(self):
|
|
58
|
+
return "baseline"
|
|
59
|
+
|
|
60
|
+
def is_fitted(self):
|
|
61
|
+
return (
|
|
62
|
+
hasattr(self.model, "n_outputs_")
|
|
63
|
+
and self.model.n_outputs_ is not None
|
|
64
|
+
and self.model.n_outputs_ > 0
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
additional = {"max_steps": 1, "max_rows_limit": None, "max_cols_limit": None}
|
|
69
|
+
required_preprocessing = ["target_as_integer"]
|
|
70
|
+
|
|
71
|
+
AlgorithmsRegistry.add(
|
|
72
|
+
BINARY_CLASSIFICATION,
|
|
73
|
+
BaselineClassifierAlgorithm,
|
|
74
|
+
{},
|
|
75
|
+
required_preprocessing,
|
|
76
|
+
additional,
|
|
77
|
+
{},
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
AlgorithmsRegistry.add(
|
|
81
|
+
MULTICLASS_CLASSIFICATION,
|
|
82
|
+
BaselineClassifierAlgorithm,
|
|
83
|
+
{},
|
|
84
|
+
required_preprocessing,
|
|
85
|
+
additional,
|
|
86
|
+
{},
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
AlgorithmsRegistry.add(REGRESSION, BaselineRegressorAlgorithm, {}, {}, additional, {})
|