eazypredict 0.2.1__tar.gz → 0.3.0__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 (44) hide show
  1. eazypredict-0.3.0/PKG-INFO +343 -0
  2. eazypredict-0.3.0/README.md +305 -0
  3. eazypredict-0.3.0/pyproject.toml +107 -0
  4. eazypredict-0.3.0/setup.cfg +4 -0
  5. eazypredict-0.3.0/src/eazypredict/__init__.py +46 -0
  6. eazypredict-0.3.0/src/eazypredict/_compat.py +66 -0
  7. eazypredict-0.3.0/src/eazypredict/_legacy.py +141 -0
  8. eazypredict-0.3.0/src/eazypredict/_legacy_classifier.py +11 -0
  9. eazypredict-0.3.0/src/eazypredict/_legacy_regressor.py +11 -0
  10. eazypredict-0.3.0/src/eazypredict/base.py +453 -0
  11. eazypredict-0.3.0/src/eazypredict/classification.py +205 -0
  12. eazypredict-0.3.0/src/eazypredict/estimators.py +231 -0
  13. eazypredict-0.3.0/src/eazypredict/metrics.py +118 -0
  14. eazypredict-0.3.0/src/eazypredict/preprocessing.py +124 -0
  15. eazypredict-0.3.0/src/eazypredict/py.typed +0 -0
  16. eazypredict-0.3.0/src/eazypredict/regression.py +144 -0
  17. eazypredict-0.3.0/src/eazypredict.egg-info/PKG-INFO +343 -0
  18. eazypredict-0.3.0/src/eazypredict.egg-info/SOURCES.txt +32 -0
  19. eazypredict-0.3.0/src/eazypredict.egg-info/requires.txt +16 -0
  20. eazypredict-0.3.0/tests/test_cross_validation.py +160 -0
  21. eazypredict-0.3.0/tests/test_docs.py +83 -0
  22. eazypredict-0.3.0/tests/test_estimators.py +149 -0
  23. eazypredict-0.3.0/tests/test_imports.py +114 -0
  24. eazypredict-0.3.0/tests/test_input_types.py +97 -0
  25. eazypredict-0.3.0/tests/test_legacy_api.py +106 -0
  26. eazypredict-0.3.0/tests/test_metrics.py +213 -0
  27. eazypredict-0.3.0/tests/test_packaging.py +91 -0
  28. eazypredict-0.3.0/tests/test_persistence.py +143 -0
  29. eazypredict-0.3.0/tests/test_preprocessing.py +99 -0
  30. eazypredict-0.3.0/tests/test_regressions.py +332 -0
  31. eazypredict-0.3.0/tests/test_sklearn_compliance.py +177 -0
  32. eazypredict-0.2.1/AUTHORS.md +0 -7
  33. eazypredict-0.2.1/PKG-INFO +0 -165
  34. eazypredict-0.2.1/README.md +0 -149
  35. eazypredict-0.2.1/pyproject.toml +0 -3
  36. eazypredict-0.2.1/setup.cfg +0 -29
  37. eazypredict-0.2.1/src/eazypredict/EazyClassifier.py +0 -237
  38. eazypredict-0.2.1/src/eazypredict/EazyRegressor.py +0 -215
  39. eazypredict-0.2.1/src/eazypredict/__init__.py +0 -3
  40. eazypredict-0.2.1/src/eazypredict.egg-info/PKG-INFO +0 -165
  41. eazypredict-0.2.1/src/eazypredict.egg-info/SOURCES.txt +0 -12
  42. {eazypredict-0.2.1 → eazypredict-0.3.0}/LICENSE.txt +0 -0
  43. {eazypredict-0.2.1 → eazypredict-0.3.0}/src/eazypredict.egg-info/dependency_links.txt +0 -0
  44. {eazypredict-0.2.1 → eazypredict-0.3.0}/src/eazypredict.egg-info/top_level.txt +0 -0
@@ -0,0 +1,343 @@
1
+ Metadata-Version: 2.4
2
+ Name: eazypredict
3
+ Version: 0.3.0
4
+ Summary: Run and compare many scikit-learn models on a dataset in a few lines.
5
+ Author-email: Harshavardhan M <harsha7vardhan@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/codevardhan/EazyPredict
8
+ Project-URL: Changelog, https://github.com/codevardhan/EazyPredict/blob/main/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/codevardhan/EazyPredict/issues
10
+ Keywords: machine-learning,scikit-learn,automl,benchmarking
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE.txt
24
+ Requires-Dist: scikit-learn>=1.4
25
+ Requires-Dist: numpy>=1.24
26
+ Requires-Dist: pandas>=2.0
27
+ Requires-Dist: scipy>=1.10
28
+ Requires-Dist: joblib>=1.3
29
+ Requires-Dist: tqdm>=4.65
30
+ Provides-Extra: boosters
31
+ Requires-Dist: xgboost>=2.0; extra == "boosters"
32
+ Requires-Dist: lightgbm>=4.0; extra == "boosters"
33
+ Provides-Extra: plots
34
+ Requires-Dist: matplotlib>=3.7; extra == "plots"
35
+ Provides-Extra: all
36
+ Requires-Dist: eazypredict[boosters,plots]; extra == "all"
37
+ Dynamic: license-file
38
+
39
+ # EazyPredict
40
+
41
+ Fit a dozen scikit-learn models on your data and compare them on a single leaderboard.
42
+ Useful when you want to know which family of model is worth your time before you commit
43
+ to tuning one.
44
+
45
+ Inspired by [LazyPredict](https://github.com/shankarpandala/lazypredict), with a
46
+ narrower model list and a few things it does differently:
47
+
48
+ - **Cross-validated by default** (`cv=5`), reporting a mean and a standard deviation
49
+ per metric. A single split on a few hundred rows makes the ranking mostly noise.
50
+ - **Automatic preprocessing.** Mixed-dtype frames with missing values and categorical
51
+ columns work as-is. Each model gets its own cloned preprocessor inside a `Pipeline`,
52
+ so cross-validation does not leak.
53
+ - **A model that fails costs one row, not the run.** Check `errors_`.
54
+ - **Reproducible.** `random_state` is threaded into every candidate estimator.
55
+ - **Light core.** xgboost, lightgbm and matplotlib are optional extras.
56
+
57
+ ## Installation
58
+
59
+ ```bash
60
+ pip install eazypredict # core: scikit-learn, pandas, numpy
61
+ pip install 'eazypredict[boosters]' # + xgboost, lightgbm
62
+ pip install 'eazypredict[plots]' # + matplotlib
63
+ pip install 'eazypredict[all]'
64
+ ```
65
+
66
+ Requires Python 3.10+.
67
+
68
+ ## Classification
69
+
70
+ ```python
71
+ from sklearn.datasets import load_breast_cancer
72
+ from eazypredict import EazyClassifier
73
+
74
+ X, y = load_breast_cancer(return_X_y=True)
75
+
76
+ clf = EazyClassifier(random_state=0).fit(X, y)
77
+ print(clf.results_[["accuracy", "f1", "roc_auc", "accuracy_std", "status"]].round(3))
78
+ ```
79
+
80
+ ```
81
+ accuracy f1 roc_auc accuracy_std status
82
+ model
83
+ LogisticRegression 0.981 0.981 0.995 0.012 ok
84
+ SVC 0.981 0.981 0.997 0.012 ok
85
+ HistGradientBoostingClassifier 0.979 0.979 0.994 0.017 ok
86
+ MLPClassifier 0.976 0.976 0.994 0.011 ok
87
+ LGBMClassifier 0.974 0.974 0.996 0.023 ok
88
+ XGBClassifier 0.972 0.972 0.993 0.022 ok
89
+ SGDClassifier 0.969 0.969 0.988 0.024 ok
90
+ KNeighborsClassifier 0.967 0.967 0.989 0.023 ok
91
+ RidgeClassifier 0.962 0.962 0.993 0.020 ok
92
+ RandomForestClassifier 0.962 0.962 0.996 0.009 ok
93
+ DecisionTreeClassifier 0.937 0.937 0.932 0.018 ok
94
+ GaussianNB 0.929 0.929 0.988 0.031 ok
95
+ ```
96
+
97
+ Row 0 is always the best model. It is refit on the full training set and used for
98
+ prediction:
99
+
100
+ ```python
101
+ clf.best_model_name_ # 'LogisticRegression'
102
+ clf.best_estimator_ # the fitted Pipeline, preprocessing included
103
+ clf.models_ # every fitted pipeline, by name
104
+
105
+ clf.predict(X[:5])
106
+ clf.predict_proba(X[:5])
107
+ ```
108
+
109
+ ROC AUC is computed from probabilities — or from `decision_function` where that is all
110
+ a model offers — not from hard class labels. A model that can supply neither reports
111
+ `NaN` for that one metric and keeps its place on the leaderboard.
112
+
113
+ ## Regression
114
+
115
+ ```python
116
+ from sklearn.datasets import load_diabetes
117
+ from eazypredict import EazyRegressor
118
+
119
+ X_reg, y_reg = load_diabetes(return_X_y=True)
120
+
121
+ reg = EazyRegressor(random_state=0).fit(X_reg, y_reg)
122
+ print(reg.results_[["rmse", "mae", "r2", "rmse_std", "status"]].round(3))
123
+ ```
124
+
125
+ ```
126
+ rmse mae r2 rmse_std status
127
+ model
128
+ Ridge 54.084 43.928 0.523 3.867 ok
129
+ LinearRegression 54.093 43.925 0.522 3.864 ok
130
+ ElasticNet 55.462 46.502 0.500 3.995 ok
131
+ RandomForestRegressor 56.913 46.204 0.470 5.752 ok
132
+ KNeighborsRegressor 57.994 46.009 0.455 4.990 ok
133
+ HistGradientBoostingRegressor 59.251 46.638 0.425 6.642 ok
134
+ LGBMRegressor 59.717 47.324 0.418 5.565 ok
135
+ XGBRegressor 63.174 50.158 0.343 5.253 ok
136
+ NuSVR 73.395 63.407 0.129 3.616 ok
137
+ DecisionTreeRegressor 76.806 60.101 0.031 7.736 ok
138
+ MLPRegressor 106.945 86.631 -0.862 7.265 ok
139
+ ```
140
+
141
+ Minimised metrics (`rmse`, `mae`, `mape`, `log_loss`) are reported as positive numbers
142
+ and sorted ascending, so row 0 is the best model whichever metric you sort by.
143
+
144
+ ## Messy data
145
+
146
+ The case most of these tools fall over on: floats with gaps, string columns, nothing
147
+ cleaned.
148
+
149
+ ```python
150
+ import numpy as np
151
+ import pandas as pd
152
+
153
+ rng = np.random.default_rng(0)
154
+ n = 200
155
+ df = pd.DataFrame(
156
+ {
157
+ "age": rng.normal(40, 12, n),
158
+ "city": rng.choice(["London", "Paris", "Tokyo"], n),
159
+ "score": rng.normal(0, 1, n),
160
+ }
161
+ )
162
+ df.loc[rng.choice(n, 20, replace=False), "age"] = np.nan # missing numbers
163
+ df.loc[rng.choice(n, 15, replace=False), "city"] = None # missing categories
164
+ target = (df["score"] + rng.normal(0, 0.5, n) > 0).astype(int)
165
+
166
+ messy = EazyClassifier(
167
+ estimators=[
168
+ "LogisticRegression",
169
+ "RandomForestClassifier",
170
+ "HistGradientBoostingClassifier",
171
+ ],
172
+ random_state=0,
173
+ ).fit(df, target)
174
+ print(messy.results_[["accuracy", "f1", "roc_auc", "status"]].round(3))
175
+ ```
176
+
177
+ ```
178
+ accuracy f1 roc_auc status
179
+ model
180
+ LogisticRegression 0.873 0.873 0.953 ok
181
+ RandomForestClassifier 0.853 0.853 0.930 ok
182
+ HistGradientBoostingClassifier 0.847 0.846 0.943 ok
183
+ ```
184
+
185
+ Numeric columns are median-imputed and scaled; categorical columns are
186
+ most-frequent-imputed and one-hot encoded. Pass `preprocess=False` to turn this off, or
187
+ pass your own transformer to use instead.
188
+
189
+ ## Choosing models
190
+
191
+ ```python
192
+ custom = EazyClassifier(
193
+ estimators=["LinearSVC", "NearestCentroid", "AdaBoostClassifier"],
194
+ sort_by="f1",
195
+ random_state=0,
196
+ ).fit(X, y)
197
+ ```
198
+
199
+ `estimators` accepts `"default"`, `"all"` (every applicable scikit-learn estimator), a
200
+ list of names, bare instances, or `(name, estimator)` pairs — so a model can be
201
+ pre-configured:
202
+
203
+ ```python
204
+ from sklearn.ensemble import RandomForestClassifier
205
+
206
+ EazyClassifier(estimators=[("rf_500", RandomForestClassifier(n_estimators=500))])
207
+ ```
208
+
209
+ A misspelled name fails immediately with a suggestion, rather than after a long run.
210
+
211
+ ## Choosing metrics
212
+
213
+ Defaults are `accuracy, balanced_accuracy, f1, precision, recall, roc_auc, log_loss,
214
+ matthews_corrcoef` for classification and `rmse, mae, r2, mape, explained_variance` for
215
+ regression. Pass a list to keep a subset, in your own order:
216
+
217
+ ```python
218
+ EazyClassifier(metrics=["accuracy", "f1"], sort_by="f1")
219
+ ```
220
+
221
+ Or a mapping of name to any scikit-learn scorer:
222
+
223
+ ```python
224
+ from sklearn.metrics import get_scorer, make_scorer, fbeta_score
225
+
226
+ EazyClassifier(
227
+ metrics={
228
+ "accuracy": "accuracy",
229
+ "f2": make_scorer(fbeta_score, beta=2),
230
+ "auc": get_scorer("roc_auc"),
231
+ }
232
+ )
233
+ ```
234
+
235
+ ## Cross-validation and splits
236
+
237
+ ```python
238
+ from sklearn.model_selection import StratifiedKFold, train_test_split
239
+
240
+ EazyClassifier(cv=10) # more folds
241
+ EazyClassifier(cv=StratifiedKFold(3)) # any splitter
242
+ EazyClassifier(cv=None, test_size=0.25) # a single holdout split, faster
243
+ ```
244
+
245
+ With an explicit test set, every model is scored on exactly that set:
246
+
247
+ ```python
248
+ X_train, X_test, y_train, y_test = train_test_split(
249
+ X, y, test_size=0.25, random_state=0, stratify=y
250
+ )
251
+
252
+ holdout = EazyClassifier(
253
+ estimators=["LogisticRegression", "RandomForestClassifier"],
254
+ cv=None,
255
+ random_state=0,
256
+ ).fit(X_train, y_train, X_test=X_test, y_test=y_test)
257
+ ```
258
+
259
+ ## Ensembles
260
+
261
+ ```python
262
+ top = EazyClassifier(
263
+ estimators=[
264
+ "LogisticRegression",
265
+ "RandomForestClassifier",
266
+ "KNeighborsClassifier",
267
+ "GaussianNB",
268
+ ],
269
+ random_state=0,
270
+ ).fit(X_train, y_train)
271
+
272
+ ensemble = top.fit_voting_ensemble(n_models=3)
273
+ print(ensemble.score(X_test, y_test))
274
+ ```
275
+
276
+ The leading `n_models` from the leaderboard are combined, so the ensemble honours
277
+ `sort_by`. Soft voting is used by default, falling back to hard voting with a warning
278
+ if a selected model has no `predict_proba`. `EazyRegressor.fit_voting_ensemble` is the
279
+ same, minus the voting argument.
280
+
281
+ ## Saving a run
282
+
283
+ ```python
284
+ saved = EazyClassifier(
285
+ estimators=["LogisticRegression", "DecisionTreeClassifier"],
286
+ save_dir="runs/experiment-1",
287
+ random_state=0,
288
+ ).fit(X, y)
289
+ ```
290
+
291
+ ```
292
+ runs/experiment-1/
293
+ ├── LogisticRegression.joblib # the whole pipeline, preprocessing included
294
+ ├── DecisionTreeClassifier.joblib
295
+ ├── results.csv
296
+ └── metadata.json
297
+ ```
298
+
299
+ `metadata.json` records the seed, CV setting, data shape, best model and the versions of
300
+ every library involved, so a leaderboard can be reproduced months later.
301
+
302
+ ## When a model fails
303
+
304
+ It gets a row with `status="failed"` and an entry in `errors_`; the rest of the run
305
+ continues.
306
+
307
+ ```python
308
+ clf.errors_ # {'SomeModel': 'ValueError: ...'}
309
+ EazyClassifier(on_error="raise") # stop at the first failure instead
310
+ ```
311
+
312
+ ## Upgrading to 0.3.0
313
+
314
+ 0.3.0 is a correctness release, and it changes the API:
315
+
316
+ ```
317
+ before: clf.fit(X_train, X_test, y_train, y_test)
318
+ now: clf.fit(X, y)
319
+ ```
320
+
321
+ The old signature took `(X_train, X_test, y_train, y_test)` while every published
322
+ example called it `(X_train, y_train, X_test, y_test)`, so a great many leaderboards
323
+ were quietly computed on the training set. The new `fit(X, y)` follows the scikit-learn
324
+ convention and returns `self`.
325
+
326
+ The old entry points still work and emit a `DeprecationWarning`; they will be removed in
327
+ 0.5.0. They keep their original *implemented* argument order — reinterpreting those
328
+ arguments would silently change what existing code trains on.
329
+
330
+ ```python
331
+ from eazypredict import EazyClassifier, EazyRegressor # the import path to use
332
+ ```
333
+
334
+ See [CHANGELOG.md](CHANGELOG.md) for the full list of fixes.
335
+
336
+ ## Roadmap
337
+
338
+ Hyperparameter tuning, parallel fitting, permutation feature importance, stacking
339
+ ensembles, probability calibration, and leaderboard export to Markdown and LaTeX.
340
+
341
+ ## License
342
+
343
+ MIT
@@ -0,0 +1,305 @@
1
+ # EazyPredict
2
+
3
+ Fit a dozen scikit-learn models on your data and compare them on a single leaderboard.
4
+ Useful when you want to know which family of model is worth your time before you commit
5
+ to tuning one.
6
+
7
+ Inspired by [LazyPredict](https://github.com/shankarpandala/lazypredict), with a
8
+ narrower model list and a few things it does differently:
9
+
10
+ - **Cross-validated by default** (`cv=5`), reporting a mean and a standard deviation
11
+ per metric. A single split on a few hundred rows makes the ranking mostly noise.
12
+ - **Automatic preprocessing.** Mixed-dtype frames with missing values and categorical
13
+ columns work as-is. Each model gets its own cloned preprocessor inside a `Pipeline`,
14
+ so cross-validation does not leak.
15
+ - **A model that fails costs one row, not the run.** Check `errors_`.
16
+ - **Reproducible.** `random_state` is threaded into every candidate estimator.
17
+ - **Light core.** xgboost, lightgbm and matplotlib are optional extras.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install eazypredict # core: scikit-learn, pandas, numpy
23
+ pip install 'eazypredict[boosters]' # + xgboost, lightgbm
24
+ pip install 'eazypredict[plots]' # + matplotlib
25
+ pip install 'eazypredict[all]'
26
+ ```
27
+
28
+ Requires Python 3.10+.
29
+
30
+ ## Classification
31
+
32
+ ```python
33
+ from sklearn.datasets import load_breast_cancer
34
+ from eazypredict import EazyClassifier
35
+
36
+ X, y = load_breast_cancer(return_X_y=True)
37
+
38
+ clf = EazyClassifier(random_state=0).fit(X, y)
39
+ print(clf.results_[["accuracy", "f1", "roc_auc", "accuracy_std", "status"]].round(3))
40
+ ```
41
+
42
+ ```
43
+ accuracy f1 roc_auc accuracy_std status
44
+ model
45
+ LogisticRegression 0.981 0.981 0.995 0.012 ok
46
+ SVC 0.981 0.981 0.997 0.012 ok
47
+ HistGradientBoostingClassifier 0.979 0.979 0.994 0.017 ok
48
+ MLPClassifier 0.976 0.976 0.994 0.011 ok
49
+ LGBMClassifier 0.974 0.974 0.996 0.023 ok
50
+ XGBClassifier 0.972 0.972 0.993 0.022 ok
51
+ SGDClassifier 0.969 0.969 0.988 0.024 ok
52
+ KNeighborsClassifier 0.967 0.967 0.989 0.023 ok
53
+ RidgeClassifier 0.962 0.962 0.993 0.020 ok
54
+ RandomForestClassifier 0.962 0.962 0.996 0.009 ok
55
+ DecisionTreeClassifier 0.937 0.937 0.932 0.018 ok
56
+ GaussianNB 0.929 0.929 0.988 0.031 ok
57
+ ```
58
+
59
+ Row 0 is always the best model. It is refit on the full training set and used for
60
+ prediction:
61
+
62
+ ```python
63
+ clf.best_model_name_ # 'LogisticRegression'
64
+ clf.best_estimator_ # the fitted Pipeline, preprocessing included
65
+ clf.models_ # every fitted pipeline, by name
66
+
67
+ clf.predict(X[:5])
68
+ clf.predict_proba(X[:5])
69
+ ```
70
+
71
+ ROC AUC is computed from probabilities — or from `decision_function` where that is all
72
+ a model offers — not from hard class labels. A model that can supply neither reports
73
+ `NaN` for that one metric and keeps its place on the leaderboard.
74
+
75
+ ## Regression
76
+
77
+ ```python
78
+ from sklearn.datasets import load_diabetes
79
+ from eazypredict import EazyRegressor
80
+
81
+ X_reg, y_reg = load_diabetes(return_X_y=True)
82
+
83
+ reg = EazyRegressor(random_state=0).fit(X_reg, y_reg)
84
+ print(reg.results_[["rmse", "mae", "r2", "rmse_std", "status"]].round(3))
85
+ ```
86
+
87
+ ```
88
+ rmse mae r2 rmse_std status
89
+ model
90
+ Ridge 54.084 43.928 0.523 3.867 ok
91
+ LinearRegression 54.093 43.925 0.522 3.864 ok
92
+ ElasticNet 55.462 46.502 0.500 3.995 ok
93
+ RandomForestRegressor 56.913 46.204 0.470 5.752 ok
94
+ KNeighborsRegressor 57.994 46.009 0.455 4.990 ok
95
+ HistGradientBoostingRegressor 59.251 46.638 0.425 6.642 ok
96
+ LGBMRegressor 59.717 47.324 0.418 5.565 ok
97
+ XGBRegressor 63.174 50.158 0.343 5.253 ok
98
+ NuSVR 73.395 63.407 0.129 3.616 ok
99
+ DecisionTreeRegressor 76.806 60.101 0.031 7.736 ok
100
+ MLPRegressor 106.945 86.631 -0.862 7.265 ok
101
+ ```
102
+
103
+ Minimised metrics (`rmse`, `mae`, `mape`, `log_loss`) are reported as positive numbers
104
+ and sorted ascending, so row 0 is the best model whichever metric you sort by.
105
+
106
+ ## Messy data
107
+
108
+ The case most of these tools fall over on: floats with gaps, string columns, nothing
109
+ cleaned.
110
+
111
+ ```python
112
+ import numpy as np
113
+ import pandas as pd
114
+
115
+ rng = np.random.default_rng(0)
116
+ n = 200
117
+ df = pd.DataFrame(
118
+ {
119
+ "age": rng.normal(40, 12, n),
120
+ "city": rng.choice(["London", "Paris", "Tokyo"], n),
121
+ "score": rng.normal(0, 1, n),
122
+ }
123
+ )
124
+ df.loc[rng.choice(n, 20, replace=False), "age"] = np.nan # missing numbers
125
+ df.loc[rng.choice(n, 15, replace=False), "city"] = None # missing categories
126
+ target = (df["score"] + rng.normal(0, 0.5, n) > 0).astype(int)
127
+
128
+ messy = EazyClassifier(
129
+ estimators=[
130
+ "LogisticRegression",
131
+ "RandomForestClassifier",
132
+ "HistGradientBoostingClassifier",
133
+ ],
134
+ random_state=0,
135
+ ).fit(df, target)
136
+ print(messy.results_[["accuracy", "f1", "roc_auc", "status"]].round(3))
137
+ ```
138
+
139
+ ```
140
+ accuracy f1 roc_auc status
141
+ model
142
+ LogisticRegression 0.873 0.873 0.953 ok
143
+ RandomForestClassifier 0.853 0.853 0.930 ok
144
+ HistGradientBoostingClassifier 0.847 0.846 0.943 ok
145
+ ```
146
+
147
+ Numeric columns are median-imputed and scaled; categorical columns are
148
+ most-frequent-imputed and one-hot encoded. Pass `preprocess=False` to turn this off, or
149
+ pass your own transformer to use instead.
150
+
151
+ ## Choosing models
152
+
153
+ ```python
154
+ custom = EazyClassifier(
155
+ estimators=["LinearSVC", "NearestCentroid", "AdaBoostClassifier"],
156
+ sort_by="f1",
157
+ random_state=0,
158
+ ).fit(X, y)
159
+ ```
160
+
161
+ `estimators` accepts `"default"`, `"all"` (every applicable scikit-learn estimator), a
162
+ list of names, bare instances, or `(name, estimator)` pairs — so a model can be
163
+ pre-configured:
164
+
165
+ ```python
166
+ from sklearn.ensemble import RandomForestClassifier
167
+
168
+ EazyClassifier(estimators=[("rf_500", RandomForestClassifier(n_estimators=500))])
169
+ ```
170
+
171
+ A misspelled name fails immediately with a suggestion, rather than after a long run.
172
+
173
+ ## Choosing metrics
174
+
175
+ Defaults are `accuracy, balanced_accuracy, f1, precision, recall, roc_auc, log_loss,
176
+ matthews_corrcoef` for classification and `rmse, mae, r2, mape, explained_variance` for
177
+ regression. Pass a list to keep a subset, in your own order:
178
+
179
+ ```python
180
+ EazyClassifier(metrics=["accuracy", "f1"], sort_by="f1")
181
+ ```
182
+
183
+ Or a mapping of name to any scikit-learn scorer:
184
+
185
+ ```python
186
+ from sklearn.metrics import get_scorer, make_scorer, fbeta_score
187
+
188
+ EazyClassifier(
189
+ metrics={
190
+ "accuracy": "accuracy",
191
+ "f2": make_scorer(fbeta_score, beta=2),
192
+ "auc": get_scorer("roc_auc"),
193
+ }
194
+ )
195
+ ```
196
+
197
+ ## Cross-validation and splits
198
+
199
+ ```python
200
+ from sklearn.model_selection import StratifiedKFold, train_test_split
201
+
202
+ EazyClassifier(cv=10) # more folds
203
+ EazyClassifier(cv=StratifiedKFold(3)) # any splitter
204
+ EazyClassifier(cv=None, test_size=0.25) # a single holdout split, faster
205
+ ```
206
+
207
+ With an explicit test set, every model is scored on exactly that set:
208
+
209
+ ```python
210
+ X_train, X_test, y_train, y_test = train_test_split(
211
+ X, y, test_size=0.25, random_state=0, stratify=y
212
+ )
213
+
214
+ holdout = EazyClassifier(
215
+ estimators=["LogisticRegression", "RandomForestClassifier"],
216
+ cv=None,
217
+ random_state=0,
218
+ ).fit(X_train, y_train, X_test=X_test, y_test=y_test)
219
+ ```
220
+
221
+ ## Ensembles
222
+
223
+ ```python
224
+ top = EazyClassifier(
225
+ estimators=[
226
+ "LogisticRegression",
227
+ "RandomForestClassifier",
228
+ "KNeighborsClassifier",
229
+ "GaussianNB",
230
+ ],
231
+ random_state=0,
232
+ ).fit(X_train, y_train)
233
+
234
+ ensemble = top.fit_voting_ensemble(n_models=3)
235
+ print(ensemble.score(X_test, y_test))
236
+ ```
237
+
238
+ The leading `n_models` from the leaderboard are combined, so the ensemble honours
239
+ `sort_by`. Soft voting is used by default, falling back to hard voting with a warning
240
+ if a selected model has no `predict_proba`. `EazyRegressor.fit_voting_ensemble` is the
241
+ same, minus the voting argument.
242
+
243
+ ## Saving a run
244
+
245
+ ```python
246
+ saved = EazyClassifier(
247
+ estimators=["LogisticRegression", "DecisionTreeClassifier"],
248
+ save_dir="runs/experiment-1",
249
+ random_state=0,
250
+ ).fit(X, y)
251
+ ```
252
+
253
+ ```
254
+ runs/experiment-1/
255
+ ├── LogisticRegression.joblib # the whole pipeline, preprocessing included
256
+ ├── DecisionTreeClassifier.joblib
257
+ ├── results.csv
258
+ └── metadata.json
259
+ ```
260
+
261
+ `metadata.json` records the seed, CV setting, data shape, best model and the versions of
262
+ every library involved, so a leaderboard can be reproduced months later.
263
+
264
+ ## When a model fails
265
+
266
+ It gets a row with `status="failed"` and an entry in `errors_`; the rest of the run
267
+ continues.
268
+
269
+ ```python
270
+ clf.errors_ # {'SomeModel': 'ValueError: ...'}
271
+ EazyClassifier(on_error="raise") # stop at the first failure instead
272
+ ```
273
+
274
+ ## Upgrading to 0.3.0
275
+
276
+ 0.3.0 is a correctness release, and it changes the API:
277
+
278
+ ```
279
+ before: clf.fit(X_train, X_test, y_train, y_test)
280
+ now: clf.fit(X, y)
281
+ ```
282
+
283
+ The old signature took `(X_train, X_test, y_train, y_test)` while every published
284
+ example called it `(X_train, y_train, X_test, y_test)`, so a great many leaderboards
285
+ were quietly computed on the training set. The new `fit(X, y)` follows the scikit-learn
286
+ convention and returns `self`.
287
+
288
+ The old entry points still work and emit a `DeprecationWarning`; they will be removed in
289
+ 0.5.0. They keep their original *implemented* argument order — reinterpreting those
290
+ arguments would silently change what existing code trains on.
291
+
292
+ ```python
293
+ from eazypredict import EazyClassifier, EazyRegressor # the import path to use
294
+ ```
295
+
296
+ See [CHANGELOG.md](CHANGELOG.md) for the full list of fixes.
297
+
298
+ ## Roadmap
299
+
300
+ Hyperparameter tuning, parallel fitting, permutation feature importance, stacking
301
+ ensembles, probability calibration, and leaderboard export to Markdown and LaTeX.
302
+
303
+ ## License
304
+
305
+ MIT