mlfox 1.0.1__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.
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ Release notes for MLFOX / the `mlfox` Python distribution.
4
+
5
+ ## 1.0.1 — 2026-11-02
6
+
7
+ - Made the `mlfox` distribution and `from mlfox import mlfox` the recommended installation and public import.
8
+ - Added bounded tuning, model evaluation, prediction, persistence, explainability, and report export to the release workflow.
9
+ - Added CPU XGBoost dependencies selected by platform: `xgboost-cpu` on Windows/Linux and `xgboost` on macOS.
10
+ - Added CI coverage for tests, integration, package building, and clean-wheel smoke tests.
11
+
12
+ ## 1.0.0
13
+
14
+ - Initial MLFOX v1.0 release with tabular classification and regression workflows, fold-aware preprocessing, model selection, reporting, and holdout evaluation.
mlfox-1.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MLFOX Contributors
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,12 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ recursive-include mlfox *.py
5
+ recursive-include examples *.py
6
+ prune tests
7
+ prune .venv_test
8
+ prune .venv_release
9
+ prune .tmp
10
+ prune build
11
+ prune dist
12
+ global-exclude *.py[cod]
mlfox-1.0.1/PKG-INFO ADDED
@@ -0,0 +1,274 @@
1
+ Metadata-Version: 2.4
2
+ Name: mlfox
3
+ Version: 1.0.1
4
+ Summary: CPU-only MLFOX model selection, evaluation, explainability, and inference toolkit
5
+ Author: vprojectx
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/viraj-salunke/Vprojectx
8
+ Project-URL: Repository, https://github.com/viraj-salunke/Vprojectx
9
+ Project-URL: Issues, https://github.com/viraj-salunke/Vprojectx/issues
10
+ Project-URL: Changelog, https://github.com/viraj-salunke/Vprojectx/blob/main/CHANGELOG.md
11
+ Keywords: machine-learning,automl,tabular,scikit-learn,xgboost,classification,regression
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Operating System :: MacOS
19
+ Classifier: Operating System :: Microsoft :: Windows
20
+ Classifier: Operating System :: POSIX :: Linux
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: numpy>=1.24
25
+ Requires-Dist: pandas>=2.0
26
+ Requires-Dist: scikit-learn>=1.3
27
+ Requires-Dist: joblib>=1.3
28
+ Requires-Dist: xgboost-cpu<3.2,>=3.1.3; sys_platform == "win32" or sys_platform == "linux"
29
+ Requires-Dist: xgboost<3.2,>=3.1.3; sys_platform == "darwin"
30
+ Provides-Extra: test
31
+ Requires-Dist: pytest>=8; extra == "test"
32
+ Provides-Extra: rich
33
+ Requires-Dist: rich>=13; extra == "rich"
34
+ Provides-Extra: excel
35
+ Requires-Dist: openpyxl>=3.1; extra == "excel"
36
+ Requires-Dist: xlrd>=2.0; extra == "excel"
37
+ Dynamic: license-file
38
+
39
+ # MLFOX
40
+
41
+ [![PyPI version](https://img.shields.io/pypi/v/mlfox)](https://pypi.org/project/mlfox/)
42
+ [![Python versions](https://img.shields.io/pypi/pyversions/mlfox)](https://pypi.org/project/mlfox/)
43
+ [![CI](https://github.com/viraj-salunke/Vprojectx/actions/workflows/ci.yml/badge.svg)](https://github.com/viraj-salunke/Vprojectx/actions/workflows/ci.yml)
44
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
45
+
46
+ Source code: [github.com/viraj-salunke/Vprojectx](https://github.com/viraj-salunke/Vprojectx)
47
+
48
+ By **vprojectx**.
49
+
50
+ MLFOX is a CPU-based Python library for training tabular classification and regression models. Give it a CSV file or pandas DataFrame; it profiles the data, builds fold-aware preprocessing, compares eligible models, evaluates the selected pipeline on a holdout set, and produces a report.
51
+
52
+ ## Install
53
+
54
+ ```bash
55
+ python -m pip install mlfox
56
+ ```
57
+
58
+ For a local checkout before the PyPI release:
59
+
60
+ ```bash
61
+ python -m pip install -e .
62
+ ```
63
+
64
+ XGBoost is installed as a required dependency: Windows/Linux use `xgboost-cpu`; macOS uses `xgboost` with CPU execution. Optional extras are available for terminal formatting, Excel files, and development tests:
65
+
66
+ ```bash
67
+ python -m pip install "mlfox[rich]" # Rich progress and report formatting
68
+ python -m pip install "mlfox[excel]" # .xlsx/.xls input support
69
+ python -m pip install "mlfox[test]" # pytest
70
+ ```
71
+
72
+ MLFOX requires Python 3.11 or later. The current CI configuration exercises Python 3.11–3.13. Install the `mlfox` distribution and use `from mlfox import mlfox`. `MLFOX` is also exported as a class-name alias for code that prefers capitalization.
73
+
74
+ ## Quick start
75
+
76
+ ```python
77
+ from mlfox import mlfox
78
+
79
+ model = mlfox(task="auto", cv=5, random_state=42)
80
+ model.fit("customers.csv", target="Churn")
81
+
82
+ report = model.report()
83
+ print("Selected model:", report["best_estimator"])
84
+ print("Holdout metrics:", report["holdout_metrics"])
85
+ ```
86
+
87
+ The target column is the value to predict. MLFOX accepts CSV, Excel (`.xlsx`/`.xls`) files, or a pandas DataFrame.
88
+
89
+ ## Classification example
90
+
91
+ ```python
92
+ import pandas as pd
93
+ from mlfox import mlfox
94
+
95
+ data = pd.read_csv("customers.csv")
96
+ model = mlfox(task="binary_classification", cv=5, random_state=42)
97
+ model.fit(data, target="Churn")
98
+
99
+ predictions = model.predict(data.drop(columns="Churn"))
100
+ print(predictions.head())
101
+
102
+ # Probability output is available when the selected classifier supports it.
103
+ probabilities = model.predict_proba(data.drop(columns="Churn"))
104
+ print(probabilities.head())
105
+ ```
106
+
107
+ For three or more target classes, set `task="multiclass_classification"` when you know the target type. `task="auto"` detects common binary and multiclass targets, including repeated integer-coded labels with modest cardinality. Numeric target detection is heuristic; use an explicit task when integer values represent a continuous or discrete-valued regression target.
108
+
109
+ ## Regression example
110
+
111
+ ```python
112
+ import pandas as pd
113
+ from mlfox import mlfox
114
+
115
+ data = pd.read_csv("sales.csv")
116
+ model = mlfox(task="regression", metric="rmse", cv=5, random_state=42)
117
+ model.fit(data, target="Sales")
118
+
119
+ predictions = model.predict(data.drop(columns="Sales"))
120
+ print(predictions.head())
121
+ ```
122
+
123
+ ## What `fit()` does
124
+
125
+ 1. Loads and validates the input, profiles columns, and detects or checks the task.
126
+ 2. Splits the data into training and holdout partitions.
127
+ 3. Benchmarks eligible candidate models with cross-validation on the training partition.
128
+ 4. Fits preprocessing separately inside each CV fold: column decisions, imputation, feature engineering, encoding/scaling, and feature selection are learned only from that fold’s training rows.
129
+ 5. Selects the best candidate using the primary CV metric, refits its pipeline on the training partition, then evaluates once on the untouched holdout partition.
130
+
131
+ The holdout metrics are for final evaluation only; they are not used to select the model. Classification uses stratified CV and defaults to balanced accuracy for selection. Regression uses K-fold CV and defaults to RMSE. Set `cv`, `metric`, `test_size`, and `random_state` in `mlfox(...)` to configure the run.
132
+
133
+ ## Models
134
+
135
+ Default classification candidates:
136
+
137
+ - Logistic Regression
138
+ - Decision Tree
139
+ - Random Forest
140
+ - Extra Trees
141
+ - XGBoost
142
+ - HistGradientBoosting when eligible
143
+ - Calibrated SVM within configured size limits
144
+
145
+ Default regression candidates:
146
+
147
+ - Linear Regression
148
+ - Ridge
149
+ - ElasticNet
150
+ - Decision Tree Regressor
151
+ - Random Forest Regressor
152
+ - Extra Trees Regressor
153
+ - XGBoost Regressor
154
+ - HistGradientBoosting Regressor when eligible
155
+
156
+ MLFOX runs sequentially on CPU. Some candidates are skipped for size or dimensionality limits. Candidate failures include the exception and fold in the structured model-selection report:
157
+
158
+ ```python
159
+ report = model.report(display=False)
160
+ print(report["model_selection"]["failed_models"])
161
+ ```
162
+
163
+ Each eligible candidate is evaluated across CV folds, so training can take several minutes. In these benchmark runs, 48k Adult rows took about 2.2 minutes, 54k Diamonds rows about 3.3 minutes, and full Covertype (581k rows) about 18 minutes. Timing depends on hardware and dataset features.
164
+
165
+ ## Benchmarks
166
+
167
+ Results below are from the repository's [benchmark runner](https://github.com/viraj-salunke/Vprojectx/blob/main/test2.py). It uses an external holdout; fit time is the time spent in `model.fit()`. Runs used default five-fold CV and three seeds except full Covertype, which used one.
168
+
169
+ | Dataset | Rows | Accuracy | Macro F1 | R² | RMSE | Mean fit time |
170
+ | --- | ---: | ---: | ---: | ---: | ---: | ---: |
171
+ | Adult | 48,842 | 0.8732 | 0.8149 | — | — | 132.6 s |
172
+ | Credit-g | 1,000 | 0.7667 | 0.6995 | — | — | 8.5 s |
173
+ | Covertype (full) | 581,012 | 0.9582 | 0.9309 | — | — | 1,079.2 s |
174
+ | California Housing | 20,640 | — | — | 0.8291 | 0.4751 | 62.0 s |
175
+ | Diamonds | 53,940 | — | — | 0.9762 | 612.62 | 195.8 s |
176
+
177
+ These are example runs, not guarantees; hardware, dependency versions, random splits, and dataset characteristics affect results. Credit-g varied more across seeds than the other classification runs.
178
+
179
+ ## Metrics
180
+
181
+ Classification reports accuracy, balanced accuracy, weighted precision, weighted recall, weighted F1, and ROC-AUC when supported. Available primary metrics are `balanced_accuracy`, `accuracy`, `precision`, `recall`, `f1`, and `roc_auc`.
182
+
183
+ Regression reports R², MAE, and RMSE. Available primary metrics are `rmse`, `mae`, and `r2`.
184
+
185
+ ## Bounded tuning
186
+
187
+ Tuning is optional and bounded; it is not an unbounded search:
188
+
189
+ ```python
190
+ from mlfox import mlfox
191
+
192
+ model = mlfox(
193
+ task="binary_classification",
194
+ tune=True,
195
+ max_tuning_trials=8,
196
+ cv=3,
197
+ random_state=42,
198
+ )
199
+ model.fit("customers.csv", target="Churn")
200
+ print(model.report()["best_hyperparameters"])
201
+ ```
202
+
203
+ Use an explicit task value of `binary_classification`, `multiclass_classification`, or `regression` when configuring manually. The default `task="auto"` asks MLFOX to infer the task.
204
+
205
+ ## Reports, saving, and loading
206
+
207
+ `report()` prints a terminal summary and returns structured report data. Call `report(display=False)` to get the data without printing. HTML and JSON exports are supported:
208
+
209
+ ```python
210
+ model.export_report("training_report.html")
211
+ model.export_report("training_report.json")
212
+ ```
213
+
214
+ Save and reload a fitted pipeline:
215
+
216
+ ```python
217
+ from mlfox import load_model, mlfox
218
+
219
+ model = mlfox().fit("training.csv", target="target")
220
+ model.save("model.joblib")
221
+
222
+ loaded = load_model("model.joblib")
223
+ predictions = loaded.predict("new_rows.csv")
224
+ ```
225
+
226
+ `fit()` returns the same model object, so chaining is supported. `predict()` returns a one-dimensional pandas Series named `prediction`, with shape `(n_rows,)` and the input index preserved. Example:
227
+
228
+ ```text
229
+ 0 yes
230
+ 1 no
231
+ Name: prediction, dtype: object
232
+ ```
233
+
234
+ `predict_proba()` returns a DataFrame with shape `(n_rows, n_classes)` when the selected classifier supports probabilities.
235
+
236
+ **Security:** Joblib uses pickle-based deserialization and can execute code embedded in an artifact. Load only model files from sources you trust.
237
+
238
+ ## Explainability
239
+
240
+ Global permutation importance and single-row perturbation explanations are available:
241
+
242
+ ```python
243
+ importance = model.feature_importance(
244
+ data="labeled_evaluation.csv", target="target", n_repeats=10
245
+ )
246
+ explanation = model.explain_prediction(
247
+ data="one_customer.csv", background_data="reference_rows.csv"
248
+ )
249
+ ```
250
+
251
+ These describe model sensitivity, not causal effects. The current implementation does not provide SHAP explanations.
252
+
253
+ ## Limitations
254
+
255
+ - MLFOX targets tabular data. It does not automatically vectorize free-form text.
256
+ - Automatic task detection treats integer-valued numeric targets as multiclass when there are at least 3 distinct labels, at least 2 rows per label, and no more labels than `min(100, max(20, int(2 * sqrt(n_valid_targets))))`. Continuous or higher-cardinality numeric targets are treated as regression. This is heuristic; explicitly configure ambiguous tasks.
257
+ - Splitting is random/stratified. Time-aware and group-aware holdout/CV strategies are not currently supported.
258
+ - Duplicate rows are reported but not automatically removed. Outliers are not automatically clipped or removed.
259
+ - High-cardinality categorical features can expand memory during one-hot encoding.
260
+ - No GPU training or parallel model benchmarking is provided.
261
+ - Windows/Linux install `xgboost-cpu`; macOS installs `xgboost`, which MLFOX configures for CPU execution.
262
+
263
+ ## Examples and development
264
+
265
+ Runnable examples are in [`examples/`](examples/). See [CHANGELOG.md](CHANGELOG.md) for release notes. For local development:
266
+
267
+ ```bash
268
+ python -m pip install -e ".[test,rich,excel]"
269
+ python -m compileall -q mlfox tests
270
+ python -m pytest -vv
271
+ python -m mlfox.test
272
+ ```
273
+
274
+ The package is released under the MIT License; see [LICENSE](LICENSE).
mlfox-1.0.1/README.md ADDED
@@ -0,0 +1,236 @@
1
+ # MLFOX
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/mlfox)](https://pypi.org/project/mlfox/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/mlfox)](https://pypi.org/project/mlfox/)
5
+ [![CI](https://github.com/viraj-salunke/Vprojectx/actions/workflows/ci.yml/badge.svg)](https://github.com/viraj-salunke/Vprojectx/actions/workflows/ci.yml)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
7
+
8
+ Source code: [github.com/viraj-salunke/Vprojectx](https://github.com/viraj-salunke/Vprojectx)
9
+
10
+ By **vprojectx**.
11
+
12
+ MLFOX is a CPU-based Python library for training tabular classification and regression models. Give it a CSV file or pandas DataFrame; it profiles the data, builds fold-aware preprocessing, compares eligible models, evaluates the selected pipeline on a holdout set, and produces a report.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ python -m pip install mlfox
18
+ ```
19
+
20
+ For a local checkout before the PyPI release:
21
+
22
+ ```bash
23
+ python -m pip install -e .
24
+ ```
25
+
26
+ XGBoost is installed as a required dependency: Windows/Linux use `xgboost-cpu`; macOS uses `xgboost` with CPU execution. Optional extras are available for terminal formatting, Excel files, and development tests:
27
+
28
+ ```bash
29
+ python -m pip install "mlfox[rich]" # Rich progress and report formatting
30
+ python -m pip install "mlfox[excel]" # .xlsx/.xls input support
31
+ python -m pip install "mlfox[test]" # pytest
32
+ ```
33
+
34
+ MLFOX requires Python 3.11 or later. The current CI configuration exercises Python 3.11–3.13. Install the `mlfox` distribution and use `from mlfox import mlfox`. `MLFOX` is also exported as a class-name alias for code that prefers capitalization.
35
+
36
+ ## Quick start
37
+
38
+ ```python
39
+ from mlfox import mlfox
40
+
41
+ model = mlfox(task="auto", cv=5, random_state=42)
42
+ model.fit("customers.csv", target="Churn")
43
+
44
+ report = model.report()
45
+ print("Selected model:", report["best_estimator"])
46
+ print("Holdout metrics:", report["holdout_metrics"])
47
+ ```
48
+
49
+ The target column is the value to predict. MLFOX accepts CSV, Excel (`.xlsx`/`.xls`) files, or a pandas DataFrame.
50
+
51
+ ## Classification example
52
+
53
+ ```python
54
+ import pandas as pd
55
+ from mlfox import mlfox
56
+
57
+ data = pd.read_csv("customers.csv")
58
+ model = mlfox(task="binary_classification", cv=5, random_state=42)
59
+ model.fit(data, target="Churn")
60
+
61
+ predictions = model.predict(data.drop(columns="Churn"))
62
+ print(predictions.head())
63
+
64
+ # Probability output is available when the selected classifier supports it.
65
+ probabilities = model.predict_proba(data.drop(columns="Churn"))
66
+ print(probabilities.head())
67
+ ```
68
+
69
+ For three or more target classes, set `task="multiclass_classification"` when you know the target type. `task="auto"` detects common binary and multiclass targets, including repeated integer-coded labels with modest cardinality. Numeric target detection is heuristic; use an explicit task when integer values represent a continuous or discrete-valued regression target.
70
+
71
+ ## Regression example
72
+
73
+ ```python
74
+ import pandas as pd
75
+ from mlfox import mlfox
76
+
77
+ data = pd.read_csv("sales.csv")
78
+ model = mlfox(task="regression", metric="rmse", cv=5, random_state=42)
79
+ model.fit(data, target="Sales")
80
+
81
+ predictions = model.predict(data.drop(columns="Sales"))
82
+ print(predictions.head())
83
+ ```
84
+
85
+ ## What `fit()` does
86
+
87
+ 1. Loads and validates the input, profiles columns, and detects or checks the task.
88
+ 2. Splits the data into training and holdout partitions.
89
+ 3. Benchmarks eligible candidate models with cross-validation on the training partition.
90
+ 4. Fits preprocessing separately inside each CV fold: column decisions, imputation, feature engineering, encoding/scaling, and feature selection are learned only from that fold’s training rows.
91
+ 5. Selects the best candidate using the primary CV metric, refits its pipeline on the training partition, then evaluates once on the untouched holdout partition.
92
+
93
+ The holdout metrics are for final evaluation only; they are not used to select the model. Classification uses stratified CV and defaults to balanced accuracy for selection. Regression uses K-fold CV and defaults to RMSE. Set `cv`, `metric`, `test_size`, and `random_state` in `mlfox(...)` to configure the run.
94
+
95
+ ## Models
96
+
97
+ Default classification candidates:
98
+
99
+ - Logistic Regression
100
+ - Decision Tree
101
+ - Random Forest
102
+ - Extra Trees
103
+ - XGBoost
104
+ - HistGradientBoosting when eligible
105
+ - Calibrated SVM within configured size limits
106
+
107
+ Default regression candidates:
108
+
109
+ - Linear Regression
110
+ - Ridge
111
+ - ElasticNet
112
+ - Decision Tree Regressor
113
+ - Random Forest Regressor
114
+ - Extra Trees Regressor
115
+ - XGBoost Regressor
116
+ - HistGradientBoosting Regressor when eligible
117
+
118
+ MLFOX runs sequentially on CPU. Some candidates are skipped for size or dimensionality limits. Candidate failures include the exception and fold in the structured model-selection report:
119
+
120
+ ```python
121
+ report = model.report(display=False)
122
+ print(report["model_selection"]["failed_models"])
123
+ ```
124
+
125
+ Each eligible candidate is evaluated across CV folds, so training can take several minutes. In these benchmark runs, 48k Adult rows took about 2.2 minutes, 54k Diamonds rows about 3.3 minutes, and full Covertype (581k rows) about 18 minutes. Timing depends on hardware and dataset features.
126
+
127
+ ## Benchmarks
128
+
129
+ Results below are from the repository's [benchmark runner](https://github.com/viraj-salunke/Vprojectx/blob/main/test2.py). It uses an external holdout; fit time is the time spent in `model.fit()`. Runs used default five-fold CV and three seeds except full Covertype, which used one.
130
+
131
+ | Dataset | Rows | Accuracy | Macro F1 | R² | RMSE | Mean fit time |
132
+ | --- | ---: | ---: | ---: | ---: | ---: | ---: |
133
+ | Adult | 48,842 | 0.8732 | 0.8149 | — | — | 132.6 s |
134
+ | Credit-g | 1,000 | 0.7667 | 0.6995 | — | — | 8.5 s |
135
+ | Covertype (full) | 581,012 | 0.9582 | 0.9309 | — | — | 1,079.2 s |
136
+ | California Housing | 20,640 | — | — | 0.8291 | 0.4751 | 62.0 s |
137
+ | Diamonds | 53,940 | — | — | 0.9762 | 612.62 | 195.8 s |
138
+
139
+ These are example runs, not guarantees; hardware, dependency versions, random splits, and dataset characteristics affect results. Credit-g varied more across seeds than the other classification runs.
140
+
141
+ ## Metrics
142
+
143
+ Classification reports accuracy, balanced accuracy, weighted precision, weighted recall, weighted F1, and ROC-AUC when supported. Available primary metrics are `balanced_accuracy`, `accuracy`, `precision`, `recall`, `f1`, and `roc_auc`.
144
+
145
+ Regression reports R², MAE, and RMSE. Available primary metrics are `rmse`, `mae`, and `r2`.
146
+
147
+ ## Bounded tuning
148
+
149
+ Tuning is optional and bounded; it is not an unbounded search:
150
+
151
+ ```python
152
+ from mlfox import mlfox
153
+
154
+ model = mlfox(
155
+ task="binary_classification",
156
+ tune=True,
157
+ max_tuning_trials=8,
158
+ cv=3,
159
+ random_state=42,
160
+ )
161
+ model.fit("customers.csv", target="Churn")
162
+ print(model.report()["best_hyperparameters"])
163
+ ```
164
+
165
+ Use an explicit task value of `binary_classification`, `multiclass_classification`, or `regression` when configuring manually. The default `task="auto"` asks MLFOX to infer the task.
166
+
167
+ ## Reports, saving, and loading
168
+
169
+ `report()` prints a terminal summary and returns structured report data. Call `report(display=False)` to get the data without printing. HTML and JSON exports are supported:
170
+
171
+ ```python
172
+ model.export_report("training_report.html")
173
+ model.export_report("training_report.json")
174
+ ```
175
+
176
+ Save and reload a fitted pipeline:
177
+
178
+ ```python
179
+ from mlfox import load_model, mlfox
180
+
181
+ model = mlfox().fit("training.csv", target="target")
182
+ model.save("model.joblib")
183
+
184
+ loaded = load_model("model.joblib")
185
+ predictions = loaded.predict("new_rows.csv")
186
+ ```
187
+
188
+ `fit()` returns the same model object, so chaining is supported. `predict()` returns a one-dimensional pandas Series named `prediction`, with shape `(n_rows,)` and the input index preserved. Example:
189
+
190
+ ```text
191
+ 0 yes
192
+ 1 no
193
+ Name: prediction, dtype: object
194
+ ```
195
+
196
+ `predict_proba()` returns a DataFrame with shape `(n_rows, n_classes)` when the selected classifier supports probabilities.
197
+
198
+ **Security:** Joblib uses pickle-based deserialization and can execute code embedded in an artifact. Load only model files from sources you trust.
199
+
200
+ ## Explainability
201
+
202
+ Global permutation importance and single-row perturbation explanations are available:
203
+
204
+ ```python
205
+ importance = model.feature_importance(
206
+ data="labeled_evaluation.csv", target="target", n_repeats=10
207
+ )
208
+ explanation = model.explain_prediction(
209
+ data="one_customer.csv", background_data="reference_rows.csv"
210
+ )
211
+ ```
212
+
213
+ These describe model sensitivity, not causal effects. The current implementation does not provide SHAP explanations.
214
+
215
+ ## Limitations
216
+
217
+ - MLFOX targets tabular data. It does not automatically vectorize free-form text.
218
+ - Automatic task detection treats integer-valued numeric targets as multiclass when there are at least 3 distinct labels, at least 2 rows per label, and no more labels than `min(100, max(20, int(2 * sqrt(n_valid_targets))))`. Continuous or higher-cardinality numeric targets are treated as regression. This is heuristic; explicitly configure ambiguous tasks.
219
+ - Splitting is random/stratified. Time-aware and group-aware holdout/CV strategies are not currently supported.
220
+ - Duplicate rows are reported but not automatically removed. Outliers are not automatically clipped or removed.
221
+ - High-cardinality categorical features can expand memory during one-hot encoding.
222
+ - No GPU training or parallel model benchmarking is provided.
223
+ - Windows/Linux install `xgboost-cpu`; macOS installs `xgboost`, which MLFOX configures for CPU execution.
224
+
225
+ ## Examples and development
226
+
227
+ Runnable examples are in [`examples/`](examples/). See [CHANGELOG.md](CHANGELOG.md) for release notes. For local development:
228
+
229
+ ```bash
230
+ python -m pip install -e ".[test,rich,excel]"
231
+ python -m compileall -q mlfox tests
232
+ python -m pytest -vv
233
+ python -m mlfox.test
234
+ ```
235
+
236
+ The package is released under the MIT License; see [LICENSE](LICENSE).
@@ -0,0 +1,13 @@
1
+ """Binary classification with the public MLFOX API."""
2
+ import pandas as pd
3
+ from sklearn.datasets import make_classification
4
+ from mlfox import mlfox
5
+
6
+ X, y = make_classification(n_samples=180, n_features=7, n_informative=5,
7
+ n_redundant=0, random_state=10)
8
+ data = pd.DataFrame(X, columns=[f"x{i}" for i in range(X.shape[1])])
9
+ data["target"] = y
10
+ model = mlfox(task="binary_classification", cv=3, random_state=10, progress=False)
11
+ model.fit(data, target="target")
12
+ print(model.report(display=False)["holdout_metrics"])
13
+ print(model.predict_proba(data.drop(columns="target").head()))
@@ -0,0 +1,16 @@
1
+ """Permutation importance, perturbation explanation, and report export."""
2
+ from pathlib import Path
3
+
4
+ import pandas as pd
5
+ from sklearn.datasets import make_classification
6
+ from mlfox import mlfox
7
+
8
+ X, y = make_classification(n_samples=180, n_features=6, n_informative=4,
9
+ n_redundant=0, random_state=14)
10
+ features = pd.DataFrame(X, columns=[f"x{i}" for i in range(X.shape[1])])
11
+ data = features.copy(); data["target"] = y
12
+ model = mlfox(cv=3, random_state=14, progress=False).fit(data, target="target")
13
+ print(model.feature_importance(data, target="target", n_repeats=3).head())
14
+ print(model.explain_prediction(features.iloc[[0]], features.iloc[20:40]))
15
+ model.export_report(Path("mlfox_explainability_report.html"))
16
+ model.export_report(Path("mlfox_explainability_report.json"))
@@ -0,0 +1,17 @@
1
+ """Persist a fitted model and load it for inference."""
2
+ from pathlib import Path
3
+ from tempfile import TemporaryDirectory
4
+
5
+ import pandas as pd
6
+ from sklearn.datasets import make_classification
7
+ from mlfox import load_model, mlfox
8
+
9
+ X, y = make_classification(n_samples=160, n_features=6, n_informative=4,
10
+ n_redundant=0, random_state=13)
11
+ data = pd.DataFrame(X, columns=[f"x{i}" for i in range(X.shape[1])])
12
+ data["target"] = y
13
+ model = mlfox(cv=3, random_state=13, progress=False).fit(data, target="target")
14
+ with TemporaryDirectory(prefix="mlfox-inference-", dir=Path.cwd()) as directory:
15
+ artifact = model.save(Path(directory) / "model.joblib")
16
+ loaded = load_model(artifact)
17
+ print(loaded.predict(data.drop(columns="target").head()))
@@ -0,0 +1,11 @@
1
+ """Regression with the public MLFOX API."""
2
+ import pandas as pd
3
+ from sklearn.datasets import make_regression
4
+ from mlfox import mlfox
5
+
6
+ X, y = make_regression(n_samples=180, n_features=6, noise=5, random_state=11)
7
+ data = pd.DataFrame(X, columns=[f"x{i}" for i in range(X.shape[1])])
8
+ data["target"] = y
9
+ model = mlfox(task="regression", metric="rmse", cv=3, random_state=11, progress=False)
10
+ model.fit(data, target="target")
11
+ print(model.report(display=False)["holdout_metrics"])
@@ -0,0 +1,15 @@
1
+ """Bounded CPU-only hyperparameter tuning."""
2
+ import pandas as pd
3
+ from sklearn.datasets import make_classification
4
+ from mlfox import mlfox
5
+
6
+ X, y = make_classification(n_samples=180, n_features=6, n_informative=4,
7
+ n_redundant=0, random_state=12)
8
+ data = pd.DataFrame(X, columns=[f"x{i}" for i in range(X.shape[1])])
9
+ data["target"] = y
10
+ model = mlfox(task="binary_classification", tune=True, max_tuning_trials=3,
11
+ cv=3, random_state=12, progress=False)
12
+ model.fit(data, target="target")
13
+ report = model.report(display=False)
14
+ print(report["best_hyperparameters"])
15
+ print(report["holdout_metrics"])