mljar-supervised 1.1.2__tar.gz → 1.1.4__tar.gz

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.
Files changed (105) hide show
  1. mljar-supervised-1.1.4/PKG-INFO +586 -0
  2. mljar-supervised-1.1.4/mljar_supervised.egg-info/PKG-INFO +586 -0
  3. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/mljar_supervised.egg-info/requires.txt +14 -14
  4. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/requirements.txt +1 -1
  5. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/setup.py +1 -1
  6. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/__init__.py +1 -1
  7. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/baseline.py +0 -1
  8. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/catboost.py +1 -2
  9. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/decision_tree.py +0 -1
  10. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/extra_trees.py +0 -2
  11. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/knn.py +0 -3
  12. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/lightgbm.py +0 -1
  13. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/linear.py +0 -3
  14. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/nn.py +0 -1
  15. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/random_forest.py +0 -3
  16. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/registry.py +2 -5
  17. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/xgboost.py +0 -5
  18. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/automl.py +0 -1
  19. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/base_automl.py +7 -16
  20. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/callbacks/early_stopping.py +0 -2
  21. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/callbacks/max_iters_constraint.py +0 -3
  22. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/callbacks/metric_logger.py +0 -2
  23. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/ensemble.py +1 -4
  24. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/fairness/metrics.py +0 -11
  25. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/fairness/optimization.py +0 -4
  26. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/model_framework.py +1 -6
  27. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/datetime_transformer.py +0 -3
  28. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/eda.py +0 -1
  29. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/exclude_missing_target.py +0 -2
  30. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/goldenfeatures_transformer.py +0 -1
  31. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/kmeans_transformer.py +0 -3
  32. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/label_binarizer.py +0 -2
  33. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/label_encoder.py +0 -1
  34. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/loo_encoder.py +0 -3
  35. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/preprocessing.py +0 -4
  36. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/preprocessing_categorical.py +0 -4
  37. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/preprocessing_missing.py +0 -3
  38. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/scale.py +2 -2
  39. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/text_transformer.py +0 -3
  40. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/data_info.py +0 -3
  41. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/hill_climbing.py +1 -1
  42. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/mljar_tuner.py +1 -1
  43. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/optuna/catboost.py +1 -2
  44. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/optuna/extra_trees.py +0 -2
  45. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/optuna/knn.py +0 -3
  46. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/optuna/lightgbm.py +0 -2
  47. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/optuna/nn.py +0 -2
  48. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/optuna/random_forest.py +0 -2
  49. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/optuna/xgboost.py +0 -2
  50. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/preprocessing_tuner.py +0 -4
  51. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/time_controller.py +0 -2
  52. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/__init__.py +1 -0
  53. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/additional_metrics.py +0 -11
  54. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/additional_plots.py +0 -7
  55. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/automl_plots.py +0 -2
  56. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/importance.py +1 -7
  57. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/jsonencoder.py +3 -1
  58. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/learning_curves.py +10 -8
  59. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/metric.py +2 -4
  60. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/shap.py +1 -1
  61. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/subsample.py +0 -2
  62. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/utils.py +0 -3
  63. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/validation/validator_custom.py +0 -8
  64. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/validation/validator_kfold.py +0 -4
  65. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/validation/validator_split.py +0 -5
  66. mljar-supervised-1.1.2/PKG-INFO +0 -586
  67. mljar-supervised-1.1.2/mljar_supervised.egg-info/PKG-INFO +0 -586
  68. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/LICENSE +0 -0
  69. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/MANIFEST.in +0 -0
  70. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/README.md +0 -0
  71. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/mljar_supervised.egg-info/SOURCES.txt +0 -0
  72. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/mljar_supervised.egg-info/dependency_links.txt +0 -0
  73. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/mljar_supervised.egg-info/top_level.txt +0 -0
  74. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/requirements_dev.txt +0 -0
  75. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/setup.cfg +0 -0
  76. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/__init__.py +0 -0
  77. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/algorithm.py +0 -0
  78. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/factory.py +0 -0
  79. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/algorithms/sklearn.py +0 -0
  80. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/callbacks/__init__.py +0 -0
  81. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/callbacks/callback.py +0 -0
  82. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/callbacks/callback_list.py +0 -0
  83. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/callbacks/learner_time_constraint.py +0 -0
  84. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/callbacks/terminate_on_nan.py +0 -0
  85. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/callbacks/total_time_constraint.py +0 -0
  86. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/exceptions.py +0 -0
  87. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/fairness/__init__.py +0 -0
  88. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/fairness/plots.py +0 -0
  89. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/fairness/report.py +0 -0
  90. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/fairness/utils.py +0 -0
  91. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/__init__.py +0 -0
  92. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/encoding_selector.py +0 -0
  93. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/preprocessing/preprocessing_utils.py +0 -0
  94. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/__init__.py +0 -0
  95. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/optuna/__init__.py +0 -0
  96. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/optuna/tuner.py +1 -1
  97. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/tuner/random_parameters.py +0 -0
  98. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/common.py +0 -0
  99. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/config.py +0 -0
  100. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/constants.py +0 -0
  101. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/data_validation.py +0 -0
  102. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/utils/leaderboard_plots.py +0 -0
  103. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/validation/__init__.py +0 -0
  104. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/validation/validation_step.py +0 -0
  105. {mljar-supervised-1.1.2 → mljar-supervised-1.1.4}/supervised/validation/validator_base.py +0 -0
@@ -0,0 +1,586 @@
1
+ Metadata-Version: 2.1
2
+ Name: mljar-supervised
3
+ Version: 1.1.4
4
+ Summary: Automated Machine Learning for Humans
5
+ Home-page: https://github.com/mljar/mljar-supervised
6
+ Author: MLJAR, Sp. z o.o.
7
+ Author-email: contact@mljar.com
8
+ License: MIT
9
+ Keywords: automated machine learning,automl,machine learning,data science,data mining,mljar,random forest,decision tree,xgboost,lightgbm,catboost,neural network,extra trees,linear model,features selection,features engineering
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+
19
+ # MLJAR Automated Machine Learning for Humans
20
+
21
+ [![Tests status](https://github.com/mljar/mljar-supervised/actions/workflows/run-tests.yml/badge.svg)](https://github.com/mljar/mljar-supervised/actions/workflows/run-tests.yml)
22
+ [![PyPI version](https://badge.fury.io/py/mljar-supervised.svg)](https://badge.fury.io/py/mljar-supervised)
23
+ [![Anaconda-Server Badge](https://anaconda.org/conda-forge/mljar-supervised/badges/version.svg)](https://anaconda.org/conda-forge/mljar-supervised)
24
+ [![PyPI pyversions](https://img.shields.io/pypi/pyversions/mljar-supervised.svg)](https://pypi.python.org/pypi/mljar-supervised/)
25
+
26
+
27
+ [![Anaconda-Server Badge](https://anaconda.org/conda-forge/mljar-supervised/badges/platforms.svg)](https://anaconda.org/conda-forge/mljar-supervised)
28
+ [![Anaconda-Server Badge](https://anaconda.org/conda-forge/mljar-supervised/badges/license.svg)](https://anaconda.org/conda-forge/mljar-supervised)
29
+ [![Downloads](https://pepy.tech/badge/mljar-supervised)](https://pepy.tech/project/mljar-supervised)
30
+
31
+ <p align="center">
32
+ <img
33
+ alt="mljar AutoML"
34
+ src="https://raw.githubusercontent.com/mljar/mljar-examples/master/media/AutoML_white.png#gh-light-mode-only" width="100%" />
35
+ </p>
36
+ <p align="center">
37
+ <img
38
+ alt="mljar AutoML"
39
+ src="https://raw.githubusercontent.com/mljar/mljar-examples/master/media/AutoML_black.png#gh-dark-mode-only" width="100%" />
40
+ </p>
41
+
42
+ ---
43
+
44
+ **Documentation**: <a href="https://supervised.mljar.com/" target="_blank">https://supervised.mljar.com/</a>
45
+
46
+ **Source Code**: <a href="https://github.com/mljar/mljar-supervised" target="_blank">https://github.com/mljar/mljar-supervised</a>
47
+
48
+ **Looking for commercial support**: Please contact us by [email](https://mljar.com/contact/) for details
49
+
50
+
51
+ <p align="center">
52
+ <img src="https://raw.githubusercontent.com/mljar/mljar-examples/master/media/pipeline_AutoML.png" width="100%" />
53
+ </p>
54
+
55
+
56
+
57
+ ---
58
+
59
+ ## Table of Contents
60
+
61
+ - [Automated Machine Learning](https://github.com/mljar/mljar-supervised#automated-machine-learning)
62
+ - [What's good in it?](https://github.com/mljar/mljar-supervised#whats-good-in-it)
63
+ - [AutoML Web App with GUI](https://github.com/mljar/mljar-supervised#automl-web-app-with-user-interface)
64
+ - [Automatic Documentation](https://github.com/mljar/mljar-supervised#automatic-documentation)
65
+ - [Available Modes](https://github.com/mljar/mljar-supervised#available-modes)
66
+ - [Fairness Aware Training](https://github.com/mljar/mljar-supervised#fairness-aware-training)
67
+ - [Examples](https://github.com/mljar/mljar-supervised#examples)
68
+ - [FAQ](https://github.com/mljar/mljar-supervised#faq)
69
+ - [Documentation](https://github.com/mljar/mljar-supervised#documentation)
70
+ - [Installation](https://github.com/mljar/mljar-supervised#installation)
71
+ - [Demo](https://github.com/mljar/mljar-supervised#demo)
72
+ - [Contributing](https://github.com/mljar/mljar-supervised#contributing)
73
+ - [Cite](https://github.com/mljar/mljar-supervised#cite)
74
+ - [License](https://github.com/mljar/mljar-supervised#license)
75
+ - [Commercial support](https://github.com/mljar/mljar-supervised#commercial-support)
76
+ - [MLJAR](https://github.com/mljar/mljar-supervised#mljar)
77
+
78
+
79
+ # Automated Machine Learning
80
+
81
+ The `mljar-supervised` is an Automated Machine Learning Python package that works with tabular data. It is designed to save time for a data scientist. It abstracts the common way to preprocess the data, construct the machine learning models, and perform hyper-parameters tuning to find the best model :trophy:. It is no black box, as you can see exactly how the ML pipeline is constructed (with a detailed Markdown report for each ML model).
82
+
83
+ The `mljar-supervised` will help you with:
84
+ - explaining and understanding your data (Automatic Exploratory Data Analysis),
85
+ - trying many different machine learning models (Algorithm Selection and Hyper-Parameters tuning),
86
+ - creating Markdown reports from analysis with details about all models (Automatic-Documentation),
87
+ - saving, re-running, and loading the analysis and ML models.
88
+
89
+ It has four built-in modes of work:
90
+ - `Explain` mode, which is ideal for explaining and understanding the data, with many data explanations, like decision trees visualization, linear models coefficients display, permutation importance, and SHAP explanations of data,
91
+ - `Perform` for building ML pipelines to use in production,
92
+ - `Compete` mode that trains highly-tuned ML models with ensembling and stacking, with the purpose to use in ML competitions.
93
+ - `Optuna` mode can be used to search for highly-tuned ML models should be used when the performance is the most important, and computation time is not limited (it is available from version `0.10.0`)
94
+
95
+ Of course, you can further customize the details of each `mode` to meet the requirements.
96
+
97
+ ## What's good in it?
98
+
99
+ - It uses many algorithms: `Baseline`, `Linear`, `Random Forest`, `Extra Trees`, `LightGBM`, `Xgboost`, `CatBoost`, `Neural Networks`, and `Nearest Neighbors`.
100
+ - It can compute Ensemble based on a greedy algorithm from [Caruana paper](http://www.cs.cornell.edu/~alexn/papers/shotgun.icml04.revised.rev2.pdf).
101
+ - It can stack models to build a level 2 ensemble (available in `Compete` mode or after setting the `stack_models` parameter).
102
+ - It can do features preprocessing, like missing values imputation and converting categoricals. What is more, it can also handle target values preprocessing.
103
+ - It can do advanced features engineering, like [Golden Features](https://supervised.mljar.com/features/golden_features/), [Features Selection](https://supervised.mljar.com/features/features_selection/), Text and Time Transformations.
104
+ - It can tune hyper-parameters with a `not-so-random-search` algorithm (random-search over a defined set of values) and hill climbing to fine-tune final models.
105
+ - It can compute the `Baseline` for your data so that you will know if you need Machine Learning or not!
106
+ - It has extensive explanations. This package is training simple `Decision Trees` with `max_depth <= 5`, so you can easily visualize them with amazing [dtreeviz](https://github.com/parrt/dtreeviz) to better understand your data.
107
+ - The `mljar-supervised` uses simple linear regression and includes its coefficients in the summary report, so you can check which features are used the most in the linear model.
108
+ - It cares about the explainability of models: for every algorithm, the feature importance is computed based on permutation. Additionally, for every algorithm, the SHAP explanations are computed: feature importance, dependence plots, and decision plots (explanations can be switched off with the `explain_level` parameter).
109
+ - There is automatic documentation for every ML experiment run with AutoML. The `mljar-supervised` creates markdown reports from AutoML training full of ML details, metrics, and charts.
110
+
111
+ <p align="center">
112
+ <img src="https://raw.githubusercontent.com/mljar/visual-identity/main/media/infograph.png" width="100%" />
113
+ </p>
114
+
115
+ # AutoML Web App with User Interface
116
+
117
+ We created a Web App with GUI, so you don't need to write any code 🐍. Just upload your data. Please check the Web App at [github.com/mljar/automl-app](https://github.com/mljar/automl-app). You can run this Web App locally on your computer, so your data is safe and secure :cat:
118
+
119
+ <kbd>
120
+ <img src="https://github.com/mljar/automl-app/blob/main/media/web-app.gif" alt="AutoML training in Web App"></img>
121
+ </kbd>
122
+
123
+ # Automatic Documentation
124
+
125
+ ## The AutoML Report
126
+
127
+ The report from running AutoML will contain the table with information about each model score and the time needed to train the model. There is a link for each model, which you can click to see the model's details. The performance of all ML models is presented as scatter and box plots so you can visually inspect which algorithms perform the best :trophy:.
128
+
129
+ ![AutoML leaderboard](https://github.com/mljar/mljar-examples/blob/master/media/automl_summary.gif)
130
+
131
+ ## The `Decision Tree` Report
132
+
133
+ The example for `Decision Tree` summary with trees visualization. For classification tasks, additional metrics are provided:
134
+ - confusion matrix
135
+ - threshold (optimized in the case of binary classification task)
136
+ - F1 score
137
+ - Accuracy
138
+ - Precision, Recall, MCC
139
+
140
+ ![Decision Tree summary](https://github.com/mljar/mljar-examples/blob/master/media/decision_tree_summary.gif)
141
+
142
+ ## The `LightGBM` Report
143
+
144
+ The example for `LightGBM` summary:
145
+
146
+ ![Decision Tree summary](https://github.com/mljar/mljar-examples/blob/master/media/lightgbm_summary.gif)
147
+
148
+
149
+ ## Available Modes
150
+
151
+ In the [docs](https://supervised.mljar.com/features/modes/) you can find details about AutoML modes that are presented in the table.
152
+
153
+ <p align="center">
154
+ <img src="https://raw.githubusercontent.com/mljar/visual-identity/main/media/mljar_modes.png" width="100%" />
155
+ </p>
156
+
157
+ ### Explain
158
+
159
+ ```py
160
+ automl = AutoML(mode="Explain")
161
+ ```
162
+
163
+ It is aimed to be used when the user wants to explain and understand the data.
164
+ - It is using 75%/25% train/test split.
165
+ - It uses: `Baseline`, `Linear`, `Decision Tree`, `Random Forest`, `Xgboost`, `Neural Network' algorithms, and ensemble.
166
+ - It has full explanations: learning curves, importance plots, and SHAP plots.
167
+
168
+ ### Perform
169
+
170
+ ```py
171
+ automl = AutoML(mode="Perform")
172
+ ```
173
+
174
+ It should be used when the user wants to train a model that will be used in real-life use cases.
175
+ - It uses a 5-fold CV.
176
+ - It uses: `Linear`, `Random Forest`, `LightGBM`, `Xgboost`, `CatBoost`, and `Neural Network`. It uses ensembling.
177
+ - It has learning curves and importance plots in reports.
178
+
179
+ ### Compete
180
+
181
+ ```py
182
+ automl = AutoML(mode="Compete")
183
+ ```
184
+
185
+ It should be used for machine learning competitions.
186
+ - It adapts the validation strategy depending on dataset size and `total_time_limit`. It can be: a train/test split (80/20), 5-fold CV or 10-fold CV.
187
+ - It is using: `Linear`, `Decision Tree`, `Random Forest`, `Extra Trees`, `LightGBM`, `Xgboost`, `CatBoost`, `Neural Network`, and `Nearest Neighbors`. It uses ensemble and **stacking**.
188
+ - It has only learning curves in the reports.
189
+
190
+ ### Optuna
191
+
192
+ ```py
193
+ automl = AutoML(mode="Optuna", optuna_time_budget=3600)
194
+ ```
195
+
196
+ It should be used when the performance is the most important and time is not limited.
197
+ - It uses a 10-fold CV
198
+ - It uses: `Random Forest`, `Extra Trees`, `LightGBM`, `Xgboost`, and `CatBoost`. Those algorithms are tuned by `Optuna` framework for `optuna_time_budget` seconds, each. Algorithms are tuned with original data, without advanced feature engineering.
199
+ - It uses advanced feature engineering, stacking and ensembling. The hyperparameters found for original data are reused with those steps.
200
+ - It produces learning curves in the reports.
201
+
202
+
203
+
204
+ ## How to save and load AutoML?
205
+
206
+ All models in the AutoML are saved and loaded automatically. No need to call `save()` or `load()`.
207
+
208
+ ### Example:
209
+
210
+ #### Train AutoML
211
+
212
+ ```python
213
+ automl = AutoML(results_path="AutoML_classifier")
214
+ automl.fit(X, y)
215
+ ```
216
+
217
+ You will have all models saved in the `AutoML_classifier` directory. Each model will have a separate directory with the `README.md` file with all details from the training.
218
+
219
+ #### Compute predictions
220
+ ```python
221
+ automl = AutoML(results_path="AutoML_classifier")
222
+ automl.predict(X)
223
+ ```
224
+
225
+ The AutoML automatically loads models from the `results_path` directory. If you will call `fit()` on already trained AutoML then you will get a warning message that AutoML is already fitted.
226
+
227
+
228
+ ### Why do you automatically save all models?
229
+
230
+ All models are automatically saved to be able to restore the training after interruption. For example, you are training AutoML for 48 hours, and after 47 hours, there is some unexpected interruption. In MLJAR AutoML you just call the same training code after the interruption and AutoML reloads already trained models and finishes the training.
231
+
232
+ ## Supported evaluation metrics (`eval_metric` argument in `AutoML()`)
233
+
234
+ - for binary classification: `logloss`, `auc`, `f1`, `average_precision`, `accuracy`- default is `logloss`
235
+ - for multiclass classification: `logloss`, `f1`, `accuracy` - default is `logloss`
236
+ - for regression: `rmse`, `mse`, `mae`, `r2`, `mape`, `spearman`, `pearson` - default is `rmse`
237
+
238
+ If you don't find the `eval_metric` that you need, please add a new issue. We will add it.
239
+
240
+
241
+ ## Fairness Aware Training
242
+
243
+ Starting from version `1.0.0` AutoML can optimize the Machine Learning pipeline with sensitive features. There are the following fairness related arguments in the AutoML constructor:
244
+ - `fairness_metric` - metric which will be used to decide if the model is fair,
245
+ - `fairness_threshold` - threshold used in decision about model fairness,
246
+ - `privileged_groups` - privileged groups used in fairness metrics computation,
247
+ - `underprivileged_groups` - underprivileged groups used in fairness metrics computation.
248
+
249
+ The `fit()` method accepts `sensitive_features`. When sensitive features are passed to AutoML, the best model will be selected among fair models only. In the AutoML reports, additional information about fairness metrics will be added. The MLJAR AutoML supports two methods for bias mitigation:
250
+ - Sample Weighting - assigns weights to samples to treat samples equally,
251
+ - Smart Grid Search - similar to Sample Weighting, where different weights are checked to optimize fairness metric.
252
+
253
+ The fair ML building can be used with all algorithms, including `Ensemble` and `Stacked Ensemble`. We support three Machine Learning tasks:
254
+ - binary classification,
255
+ - mutliclass classification,
256
+ - regression.
257
+
258
+ Example code:
259
+
260
+
261
+ ```python
262
+ from sklearn.model_selection import train_test_split
263
+ from sklearn.datasets import fetch_openml
264
+ from supervised.automl import AutoML
265
+
266
+ data = fetch_openml(data_id=1590, as_frame=True)
267
+ X = data.data
268
+ y = (data.target == ">50K") * 1
269
+ sensitive_features = X[["sex"]]
270
+
271
+ X_train, X_test, y_train, y_test, S_train, S_test = train_test_split(
272
+ X, y, sensitive_features, stratify=y, test_size=0.75, random_state=42
273
+ )
274
+
275
+ automl = AutoML(
276
+ algorithms=[
277
+ "Xgboost"
278
+ ],
279
+ train_ensemble=False,
280
+ fairness_metric="demographic_parity_ratio",
281
+ fairness_threshold=0.8,
282
+ privileged_groups = [{"sex": "Male"}],
283
+ underprivileged_groups = [{"sex": "Female"}],
284
+ )
285
+
286
+ automl.fit(X_train, y_train, sensitive_features=S_train)
287
+ ```
288
+
289
+ You can read more about fairness aware AutoML training in our article https://mljar.com/blog/fairness-machine-learning/
290
+
291
+ ![Fairness aware AutoML](https://raw.githubusercontent.com/mljar/visual-identity/main/automl/fairness-automl.gif)
292
+
293
+
294
+
295
+ # Examples
296
+
297
+ ## :point_right: Binary Classification Example
298
+
299
+ There is a simple interface available with `fit` and `predict` methods.
300
+
301
+ ```python
302
+ import pandas as pd
303
+ from sklearn.model_selection import train_test_split
304
+ from supervised.automl import AutoML
305
+
306
+ df = pd.read_csv(
307
+ "https://raw.githubusercontent.com/pplonski/datasets-for-start/master/adult/data.csv",
308
+ skipinitialspace=True,
309
+ )
310
+ X_train, X_test, y_train, y_test = train_test_split(
311
+ df[df.columns[:-1]], df["income"], test_size=0.25
312
+ )
313
+
314
+ automl = AutoML()
315
+ automl.fit(X_train, y_train)
316
+
317
+ predictions = automl.predict(X_test)
318
+ ```
319
+
320
+ AutoML `fit` will print:
321
+ ```py
322
+ Create directory AutoML_1
323
+ AutoML task to be solved: binary_classification
324
+ AutoML will use algorithms: ['Baseline', 'Linear', 'Decision Tree', 'Random Forest', 'Xgboost', 'Neural Network']
325
+ AutoML will optimize for metric: logloss
326
+ 1_Baseline final logloss 0.5519845471086654 time 0.08 seconds
327
+ 2_DecisionTree final logloss 0.3655910192804364 time 10.28 seconds
328
+ 3_Linear final logloss 0.38139916864708445 time 3.19 seconds
329
+ 4_Default_RandomForest final logloss 0.2975204390214936 time 79.19 seconds
330
+ 5_Default_Xgboost final logloss 0.2731086827200411 time 5.17 seconds
331
+ 6_Default_NeuralNetwork final logloss 0.319812276905242 time 21.19 seconds
332
+ Ensemble final logloss 0.2731086821194617 time 1.43 seconds
333
+ ```
334
+
335
+ - the AutoML results in [Markdown report](https://github.com/mljar/mljar-examples/tree/master/Income_classification/AutoML_1#automl-leaderboard)
336
+ - the Xgboost [Markdown report](https://github.com/mljar/mljar-examples/blob/master/Income_classification/AutoML_1/5_Default_Xgboost/README.md), please take a look at amazing dependence plots produced by SHAP package :sparkling_heart:
337
+ - the Decision Tree [Markdown report](https://github.com/mljar/mljar-examples/blob/master/Income_classification/AutoML_1/2_DecisionTree/README.md), please take a look at beautiful tree visualization :sparkles:
338
+ - the Logistic Regression [Markdown report](https://github.com/mljar/mljar-examples/blob/master/Income_classification/AutoML_1/3_Linear/README.md), please take a look at coefficients table, and you can compare the SHAP plots between (Xgboost, Decision Tree and Logistic Regression) :coffee:
339
+
340
+
341
+ ## :point_right: Multi-Class Classification Example
342
+
343
+ The example code for classification of the optical recognition of handwritten digits dataset. Running this code in less than 30 minutes will result in test accuracy ~98%.
344
+
345
+ ```python
346
+ import pandas as pd
347
+ # scikit learn utilites
348
+ from sklearn.datasets import load_digits
349
+ from sklearn.metrics import accuracy_score
350
+ from sklearn.model_selection import train_test_split
351
+ # mljar-supervised package
352
+ from supervised.automl import AutoML
353
+
354
+ # load the data
355
+ digits = load_digits()
356
+ X_train, X_test, y_train, y_test = train_test_split(
357
+ pd.DataFrame(digits.data), digits.target, stratify=digits.target, test_size=0.25,
358
+ random_state=123
359
+ )
360
+
361
+ # train models with AutoML
362
+ automl = AutoML(mode="Perform")
363
+ automl.fit(X_train, y_train)
364
+
365
+ # compute the accuracy on test data
366
+ predictions = automl.predict_all(X_test)
367
+ print(predictions.head())
368
+ print("Test accuracy:", accuracy_score(y_test, predictions["label"].astype(int)))
369
+ ```
370
+
371
+ ## :point_right: Regression Example
372
+
373
+ Regression example on `California Housing` house prices data.
374
+
375
+ ```python
376
+ import numpy as np
377
+ import pandas as pd
378
+ from sklearn.datasets import fetch_california_housing
379
+ from sklearn.model_selection import train_test_split
380
+ from sklearn.metrics import mean_squared_error
381
+ from supervised.automl import AutoML # mljar-supervised
382
+
383
+ # Load the data
384
+ housing = fetch_california_housing()
385
+ X_train, X_test, y_train, y_test = train_test_split(
386
+ pd.DataFrame(housing.data, columns=housing.feature_names),
387
+ housing.target,
388
+ test_size=0.25,
389
+ random_state=123,
390
+ )
391
+
392
+ # train models with AutoML
393
+ automl = AutoML(mode="Explain")
394
+ automl.fit(X_train, y_train)
395
+
396
+ # compute the MSE on test data
397
+ predictions = automl.predict(X_test)
398
+ print("Test MSE:", mean_squared_error(y_test, predictions))
399
+ ```
400
+
401
+ ## :point_right: More Examples
402
+
403
+ - [**Income classification**](https://github.com/mljar/mljar-examples/tree/master/Income_classification) - it is a binary classification task on census data
404
+ - [**Iris classification**](https://github.com/mljar/mljar-examples/tree/master/Iris_classification) - it is a multiclass classification on Iris flowers data
405
+ - [**House price regression**](https://github.com/mljar/mljar-examples/tree/master/House_price_regression) - it is a regression task on Boston houses data
406
+
407
+ # FAQ
408
+
409
+ <details><summary>What method is used for hyperparameters optimization?</summary>
410
+ - For modes: `Explain`, `Perform`, and `Compete` there is used a random search method combined with hill climbing. In this approach, all checked models are saved and used for building Ensemble.
411
+ - For mode: `Optuna` the Optuna framework is used. It uses using TPE sampler for tuning. Models checked during the Optuna hyperparameters search are not saved, only the best model is saved (the final model from tuning). You can check the details about checked hyperparameters from optuna by checking study files in the `optuna` directory in your AutoML `results_path`.
412
+ </details>
413
+
414
+ <details><summary>How to save and load AutoML?</summary>
415
+
416
+ The save and load of AutoML models is automatic. All models created during AutoML training are saved in the directory set in `results_path` (argument of `AutoML()` constructor). If there is no `results_path` set, then the directory is created based on following name convention: `AutoML_{number}` the `number` will be number from 1 to 1000 (depends which directory name will be free).
417
+
418
+ Example save and load:
419
+
420
+ ```python
421
+ automl = AutoML(results_path='AutoML_1')
422
+ automl.fit(X, y)
423
+ ```
424
+
425
+ The all models from AutoML are saved in `AutoML_1` directory.
426
+
427
+ To load models:
428
+
429
+ ```python
430
+ automl = AutoML(results_path='AutoML_1')
431
+ automl.predict(X)
432
+ ```
433
+
434
+ </details>
435
+
436
+ <details><summary>How to set ML task (select between classification or regression)?</summary>
437
+
438
+ The MLJAR AutoML can work with:
439
+ - binary classification
440
+ - multi-class classification
441
+ - regression
442
+
443
+ The ML task detection is automatic based on target values. There can be situation if you want to manually force AutoML to select the ML task, then you need to set `ml_task` parameter. It can be set to `'binary_classification'`, `'multiclass_classification'`, `'regression'`.
444
+
445
+ Example:
446
+ ```python
447
+ automl = AutoML(ml_task='regression')
448
+ automl.fit(X, y)
449
+ ```
450
+ In the above example the regression model will be fitted.
451
+
452
+ </details>
453
+
454
+ <details><summary>How to reuse Optuna hyperparameters?</summary>
455
+
456
+ You can reuse Optuna hyperparameters that were found in other AutoML training. You need to pass them in `optuna_init_params` argument. All hyperparameters found during Optuna tuning are saved in the `optuna/optuna.json` file (inside `results_path` directory).
457
+
458
+ Example:
459
+
460
+ ```python
461
+ optuna_init = json.loads(open('previous_AutoML_training/optuna/optuna.json').read())
462
+
463
+ automl = AutoML(
464
+ mode='Optuna',
465
+ optuna_init_params=optuna_init
466
+ )
467
+ automl.fit(X, y)
468
+ ```
469
+
470
+ When reusing Optuna hyperparameters the Optuna tuning is simply skipped. The model will be trained with hyperparameters set in `optuna_init_params`. Right now there is no option to continue Optuna tuning with seed parameters.
471
+
472
+
473
+ </details>
474
+
475
+
476
+ <details><summary>How to know the order of classes for binary or multiclass problem when using predict_proba?</summary>
477
+
478
+ To get predicted probabilites with information about class label please use the `predict_all()` method. It returns the pandas DataFrame with class names in the columns. The order of predicted columns is the same in the `predict_proba()` and `predict_all()` methods. The `predict_all()` method will additionaly have the column with the predicted class label.
479
+
480
+ </details>
481
+
482
+ # Documentation
483
+
484
+ For details please check [mljar-supervised docs](https://supervised.mljar.com).
485
+
486
+ # Installation
487
+
488
+ From PyPi repository:
489
+
490
+ ```
491
+ pip install mljar-supervised
492
+ ```
493
+
494
+ To install this package with conda run:
495
+ ```
496
+ conda install -c conda-forge mljar-supervised
497
+ ```
498
+
499
+ From source code:
500
+
501
+ ```
502
+ git clone https://github.com/mljar/mljar-supervised.git
503
+ cd mljar-supervised
504
+ python setup.py install
505
+ ```
506
+
507
+ Installation for development
508
+ ```
509
+ git clone https://github.com/mljar/mljar-supervised.git
510
+ virtualenv venv --python=python3.6
511
+ source venv/bin/activate
512
+ pip install -r requirements.txt
513
+ pip install -r requirements_dev.txt
514
+ ```
515
+
516
+ Running in the docker:
517
+ ```
518
+ FROM python:3.7-slim-buster
519
+ RUN apt-get update && apt-get -y update
520
+ RUN apt-get install -y build-essential python3-pip python3-dev
521
+ RUN pip3 -q install pip --upgrade
522
+ RUN pip3 install mljar-supervised jupyter
523
+ CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
524
+ ```
525
+
526
+ Install from GitHub with pip:
527
+ ```
528
+ pip install -q -U git+https://github.com/mljar/mljar-supervised.git@master
529
+ ```
530
+ # Demo
531
+
532
+ In the below demo GIF you will see:
533
+ - MLJAR AutoML trained in Jupyter Notebook on the Titanic dataset
534
+ - overview of created files
535
+ - a showcase of selected plots created during AutoML training
536
+ - algorithm comparison report along with their plots
537
+ - example of README file and CSV file with results
538
+
539
+ ![](https://github.com/mljar/mljar-examples/raw/master/media/mljar_files.gif)
540
+
541
+ # Contributing
542
+
543
+ To get started take a look at our [Contribution Guide](https://supervised.mljar.com/contributing/) for information about our process and where you can fit in!
544
+
545
+ ### Contributors
546
+ <a href="https://github.com/mljar/mljar-supervised/graphs/contributors">
547
+ <img src="https://contributors-img.web.app/image?repo=mljar/mljar-supervised" />
548
+ </a>
549
+
550
+ # Cite
551
+
552
+ Would you like to cite MLJAR? Great! :)
553
+
554
+ You can cite MLJAR as follows:
555
+
556
+ ```
557
+ @misc{mljar,
558
+ author = {Aleksandra P\l{}o\'{n}ska and Piotr P\l{}o\'{n}ski},
559
+ year = {2021},
560
+ publisher = {MLJAR},
561
+ address = {\L{}apy, Poland},
562
+ title = {MLJAR: State-of-the-art Automated Machine Learning Framework for Tabular Data. Version 0.10.3},
563
+ url = {https://github.com/mljar/mljar-supervised}
564
+ }
565
+ ```
566
+
567
+ Would love to hear from you about how have you used MLJAR AutoML in your project.
568
+ Please feel free to let us know at
569
+ ![image](https://user-images.githubusercontent.com/6959032/118103228-f5ea9a00-b3d9-11eb-87ed-8cfb1f873f91.png)
570
+
571
+
572
+ # License
573
+
574
+ The `mljar-supervised` is provided with [MIT license](https://github.com/mljar/mljar-supervised/blob/master/LICENSE).
575
+
576
+ # Commercial support
577
+
578
+ Looking for commercial support? Do you need new feature implementation? Please contact us by [email](https://mljar.com/contact/) for details.
579
+
580
+ # MLJAR
581
+ <p align="center">
582
+ <img src="https://github.com/mljar/mljar-examples/blob/master/media/large_logo.png" width="314" />
583
+ </p>
584
+
585
+ The `mljar-supervised` is an open-source project created by [MLJAR](https://mljar.com). We care about ease of use in Machine Learning.
586
+ The [mljar.com](https://mljar.com) provides a beautiful and simple user interface for building machine learning models.