mlpipe-cli 0.1.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.
- mlpipe_cli-0.1.0/LICENSE +21 -0
- mlpipe_cli-0.1.0/PKG-INFO +264 -0
- mlpipe_cli-0.1.0/README.md +234 -0
- mlpipe_cli-0.1.0/pyproject.toml +51 -0
- mlpipe_cli-0.1.0/setup.cfg +4 -0
- mlpipe_cli-0.1.0/src/mlpipe/__init__.py +43 -0
- mlpipe_cli-0.1.0/src/mlpipe/__main__.py +6 -0
- mlpipe_cli-0.1.0/src/mlpipe/artifacts/__init__.py +23 -0
- mlpipe_cli-0.1.0/src/mlpipe/artifacts/manager.py +246 -0
- mlpipe_cli-0.1.0/src/mlpipe/artifacts/serialization.py +67 -0
- mlpipe_cli-0.1.0/src/mlpipe/cli/__init__.py +5 -0
- mlpipe_cli-0.1.0/src/mlpipe/cli/main.py +667 -0
- mlpipe_cli-0.1.0/src/mlpipe/core/__init__.py +35 -0
- mlpipe_cli-0.1.0/src/mlpipe/core/config.py +76 -0
- mlpipe_cli-0.1.0/src/mlpipe/core/exceptions.py +65 -0
- mlpipe_cli-0.1.0/src/mlpipe/core/pipeline.py +435 -0
- mlpipe_cli-0.1.0/src/mlpipe/core/result.py +50 -0
- mlpipe_cli-0.1.0/src/mlpipe/data/__init__.py +20 -0
- mlpipe_cli-0.1.0/src/mlpipe/data/ingestion.py +138 -0
- mlpipe_cli-0.1.0/src/mlpipe/data/profiling.py +227 -0
- mlpipe_cli-0.1.0/src/mlpipe/data/splitting.py +130 -0
- mlpipe_cli-0.1.0/src/mlpipe/data/validation.py +248 -0
- mlpipe_cli-0.1.0/src/mlpipe/evaluation/__init__.py +11 -0
- mlpipe_cli-0.1.0/src/mlpipe/evaluation/evaluator.py +146 -0
- mlpipe_cli-0.1.0/src/mlpipe/evaluation/metrics.py +53 -0
- mlpipe_cli-0.1.0/src/mlpipe/explainability/__init__.py +5 -0
- mlpipe_cli-0.1.0/src/mlpipe/explainability/importance.py +65 -0
- mlpipe_cli-0.1.0/src/mlpipe/models/__init__.py +13 -0
- mlpipe_cli-0.1.0/src/mlpipe/models/classification.py +156 -0
- mlpipe_cli-0.1.0/src/mlpipe/models/registry.py +32 -0
- mlpipe_cli-0.1.0/src/mlpipe/models/regression.py +126 -0
- mlpipe_cli-0.1.0/src/mlpipe/models/selection.py +24 -0
- mlpipe_cli-0.1.0/src/mlpipe/preprocessing/__init__.py +21 -0
- mlpipe_cli-0.1.0/src/mlpipe/preprocessing/builder.py +163 -0
- mlpipe_cli-0.1.0/src/mlpipe/preprocessing/categorical.py +17 -0
- mlpipe_cli-0.1.0/src/mlpipe/preprocessing/datetime.py +55 -0
- mlpipe_cli-0.1.0/src/mlpipe/preprocessing/numeric.py +17 -0
- mlpipe_cli-0.1.0/src/mlpipe/tuning/__init__.py +10 -0
- mlpipe_cli-0.1.0/src/mlpipe/tuning/search.py +140 -0
- mlpipe_cli-0.1.0/src/mlpipe/tuning/spaces.py +11 -0
- mlpipe_cli-0.1.0/src/mlpipe/utils/__init__.py +13 -0
- mlpipe_cli-0.1.0/src/mlpipe/utils/hashing.py +15 -0
- mlpipe_cli-0.1.0/src/mlpipe/utils/logging.py +37 -0
- mlpipe_cli-0.1.0/src/mlpipe/utils/timing.py +33 -0
- mlpipe_cli-0.1.0/src/mlpipe/version.py +3 -0
- mlpipe_cli-0.1.0/src/mlpipe_cli.egg-info/PKG-INFO +264 -0
- mlpipe_cli-0.1.0/src/mlpipe_cli.egg-info/SOURCES.txt +59 -0
- mlpipe_cli-0.1.0/src/mlpipe_cli.egg-info/dependency_links.txt +1 -0
- mlpipe_cli-0.1.0/src/mlpipe_cli.egg-info/entry_points.txt +2 -0
- mlpipe_cli-0.1.0/src/mlpipe_cli.egg-info/requires.txt +11 -0
- mlpipe_cli-0.1.0/src/mlpipe_cli.egg-info/top_level.txt +1 -0
- mlpipe_cli-0.1.0/tests/test_artifacts.py +57 -0
- mlpipe_cli-0.1.0/tests/test_cli.py +111 -0
- mlpipe_cli-0.1.0/tests/test_e2e.py +106 -0
- mlpipe_cli-0.1.0/tests/test_evaluation.py +71 -0
- mlpipe_cli-0.1.0/tests/test_ingestion.py +48 -0
- mlpipe_cli-0.1.0/tests/test_models.py +41 -0
- mlpipe_cli-0.1.0/tests/test_preprocessing.py +54 -0
- mlpipe_cli-0.1.0/tests/test_profiling.py +59 -0
- mlpipe_cli-0.1.0/tests/test_tuning.py +35 -0
- mlpipe_cli-0.1.0/tests/test_validation.py +50 -0
mlpipe_cli-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MLPipe 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,264 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mlpipe-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Production-ready tabular ML automation library and terminal CLI
|
|
5
|
+
Author: MLPipe Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: pandas>=2.0.0
|
|
20
|
+
Requires-Dist: numpy>=1.24.0
|
|
21
|
+
Requires-Dist: scikit-learn>=1.3.0
|
|
22
|
+
Requires-Dist: joblib>=1.3.0
|
|
23
|
+
Requires-Dist: scipy>=1.10.0
|
|
24
|
+
Requires-Dist: typer[all]>=0.9.0
|
|
25
|
+
Requires-Dist: rich>=13.0.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# MLPipe
|
|
32
|
+
|
|
33
|
+
> **Production-ready tabular ML automation library and terminal CLI.**
|
|
34
|
+
> From raw CSV to evaluated, reproducible, deployable model pipelines in one command.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🚀 Overview
|
|
39
|
+
|
|
40
|
+
**MLPipe** automates the repetitive engineering lifecycle for tabular machine learning models. Simply point MLPipe at your CSV dataset and designate a target column:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
Raw CSV Dataset
|
|
44
|
+
↓
|
|
45
|
+
Data Ingestion (Format validation & SHA-256 integrity hash)
|
|
46
|
+
↓
|
|
47
|
+
Data Profiling (Column types, distributions, missingness & flags)
|
|
48
|
+
↓
|
|
49
|
+
Pre-training Validation (Fatal structural errors & non-blocking warnings)
|
|
50
|
+
↓
|
|
51
|
+
Task Detection (Automatic classification vs. regression inference)
|
|
52
|
+
↓
|
|
53
|
+
Leakage-Free Splitting (Stratified or random train/test split)
|
|
54
|
+
↓
|
|
55
|
+
Automated Preprocessing (ColumnTransformer: imputation, scaling & encoding)
|
|
56
|
+
↓
|
|
57
|
+
Multi-Model Training & Tuning (RandomizedSearchCV strictly on training folds)
|
|
58
|
+
↓
|
|
59
|
+
CV-Based Leaderboard Ranking (Winning model selected by CV, not test set)
|
|
60
|
+
↓
|
|
61
|
+
Held-Out Test Evaluation (Unbiased final metrics & confusion matrix)
|
|
62
|
+
↓
|
|
63
|
+
Model Explainability (Recovered transformed feature importances & coefficients)
|
|
64
|
+
↓
|
|
65
|
+
Artifact Generation (Reusable pipeline, model, metadata & reports)
|
|
66
|
+
↓
|
|
67
|
+
Instant Predictions (CLI & Python inference)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
No hardcoded results. No fake training. Real scikit-learn models and metrics computed on your CPU machine.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 📦 Installation
|
|
75
|
+
|
|
76
|
+
Install locally in editable mode:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
git clone https://github.com/your-org/mlpipe.git
|
|
80
|
+
cd mlpipe
|
|
81
|
+
pip install -e .
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Verify the installation:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
mlpipe --version
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## ⚡ Quick Start
|
|
93
|
+
|
|
94
|
+
### 1. Terminal CLI
|
|
95
|
+
|
|
96
|
+
Train an end-to-end classification pipeline:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
mlpipe train demo_data/customer_churn.csv --target churn
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Train a regression pipeline:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
mlpipe train demo_data/house_prices.csv --target price
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Generate predictions on new data:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
mlpipe predict ./mlpipe_runs/<run_id>/pipeline.joblib demo_data/customer_churn.csv --output predictions.csv
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 2. Python API
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from mlpipe import Pipeline
|
|
118
|
+
|
|
119
|
+
# 1. Initialize pipeline
|
|
120
|
+
pipeline = Pipeline(
|
|
121
|
+
target="churn",
|
|
122
|
+
task="auto", # auto-detects classification vs regression
|
|
123
|
+
mode="balanced", # "fast", "balanced", or "thorough"
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
# 2. Fit pipeline on CSV or DataFrame
|
|
127
|
+
result = pipeline.fit("demo_data/customer_churn.csv")
|
|
128
|
+
|
|
129
|
+
# 3. Inspect results
|
|
130
|
+
print("Best Model:", result.best_model)
|
|
131
|
+
print("Primary Metric:", result.primary_metric)
|
|
132
|
+
print("CV Score:", result.best_cv_score)
|
|
133
|
+
print("Test Score:", result.test_score)
|
|
134
|
+
print("Test Metrics:", result.metrics)
|
|
135
|
+
|
|
136
|
+
# 4. Save and reload pipeline
|
|
137
|
+
pipeline.save("./trained_models/churn_model")
|
|
138
|
+
|
|
139
|
+
loaded_pipeline = Pipeline.load("./trained_models/churn_model")
|
|
140
|
+
predictions = loaded_pipeline.predict("demo_data/customer_churn.csv")
|
|
141
|
+
print("Predictions:", predictions[:5])
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 🛠️ CLI Command Reference
|
|
147
|
+
|
|
148
|
+
### `mlpipe train`
|
|
149
|
+
Train multiple candidate models, tune hyperparameters, rank on leaderboard, and save artifacts.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
mlpipe train <data.csv> --target <target_col> [OPTIONS]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Options:**
|
|
156
|
+
- `--target, -t`: Target column name to predict (required).
|
|
157
|
+
- `--task`: Task type override: `auto` (default), `classification`, or `regression`.
|
|
158
|
+
- `--mode, -m`: Training mode budget: `fast`, `balanced` (default), or `thorough`.
|
|
159
|
+
- `--output, -o`: Base directory to store run artifacts (default: `./mlpipe_runs`).
|
|
160
|
+
- `--format, -f`: Output format: `human` (default) or `json`.
|
|
161
|
+
- `--verbose`: Enable detailed debug logging.
|
|
162
|
+
|
|
163
|
+
### `mlpipe profile`
|
|
164
|
+
Inspect dataset summary, column types, statistics, missingness, and structural issues.
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
mlpipe profile demo_data/customer_churn.csv
|
|
168
|
+
mlpipe profile demo_data/customer_churn.csv --format json
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### `mlpipe validate`
|
|
172
|
+
Run pre-training validation checks on dataset and target.
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
mlpipe validate demo_data/customer_churn.csv --target churn
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### `mlpipe predict`
|
|
179
|
+
Generate predictions on a new CSV dataset using a saved pipeline.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
mlpipe predict ./mlpipe_runs/<run_id>/pipeline.joblib new_data.csv --output preds.csv
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### `mlpipe inspect`
|
|
186
|
+
Inspect metadata, configuration, metrics, and generated artifacts from a previous run directory.
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
mlpipe inspect ./mlpipe_runs/<run_id>
|
|
190
|
+
mlpipe inspect ./mlpipe_runs/<run_id> --format json
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### `mlpipe version`
|
|
194
|
+
Display the current version of MLPipe.
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
mlpipe version
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 🧠 Supported Models
|
|
203
|
+
|
|
204
|
+
### Classification
|
|
205
|
+
- **Logistic Regression** (L2 penalty, liblinear/lbfgs/saga solvers)
|
|
206
|
+
- **Random Forest Classifier** (trees, depth, sample split/leaf tuning)
|
|
207
|
+
- **HistGradientBoosting Classifier** (iterations, learning rate, leaf bounds)
|
|
208
|
+
- **Decision Tree Classifier** (depth, split thresholds, criteria)
|
|
209
|
+
- **K-Nearest Neighbors** (neighbors, weights, distance metrics)
|
|
210
|
+
|
|
211
|
+
### Regression
|
|
212
|
+
- **Ridge Regression** (regularization alpha, solver selection)
|
|
213
|
+
- **Random Forest Regressor** (trees, depth, sample bounds, features)
|
|
214
|
+
- **HistGradientBoosting Regressor** (iterations, rate, regularization)
|
|
215
|
+
- **Decision Tree Regressor** (depth, split criteria, sample leaves)
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## 🔒 Data Leakage Prevention Guarantee
|
|
220
|
+
|
|
221
|
+
MLPipe adheres to strict data integrity standards:
|
|
222
|
+
1. **No Full-Data Transformations:** Preprocessing pipelines are never fitted on the entire dataset.
|
|
223
|
+
2. **Train/Test Split First:** The raw dataset is partitioned (default 80% train, 20% test) before column classification and transformer fitting.
|
|
224
|
+
3. **Cross-Validation Inside Pipelines:** During hyperparameter search, sklearn `Pipeline` objects fit transformers solely on the internal training fold of each split.
|
|
225
|
+
4. **CV-Based Model Selection:** The winning model is selected strictly based on CV score on the training set. The held-out test set is evaluated exactly once for unbiased reporting.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## 📁 Artifact Structure
|
|
230
|
+
|
|
231
|
+
Each completed training run generates a self-contained bundle under `./mlpipe_runs/<run_id>/`:
|
|
232
|
+
|
|
233
|
+
```text
|
|
234
|
+
mlpipe_runs/<run_id>/
|
|
235
|
+
├── pipeline.joblib # Complete fitted pipeline (preprocessor + estimator)
|
|
236
|
+
├── model.joblib # Fitted estimator alone
|
|
237
|
+
├── metrics.json # CV and test evaluation metrics
|
|
238
|
+
├── leaderboard.json # Complete ranked candidate comparison table
|
|
239
|
+
├── metadata.json # Dataset hash, seed, mode, environment & parameters
|
|
240
|
+
├── feature_importance.json # Top features with recovered transformed names
|
|
241
|
+
└── report.txt # Plain text human-readable run summary
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 🧪 Running Tests
|
|
247
|
+
|
|
248
|
+
Run the complete test suite using `pytest`:
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
pytest
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Run with verbose test output:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
pytest -v
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## 📄 License
|
|
263
|
+
|
|
264
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# MLPipe
|
|
2
|
+
|
|
3
|
+
> **Production-ready tabular ML automation library and terminal CLI.**
|
|
4
|
+
> From raw CSV to evaluated, reproducible, deployable model pipelines in one command.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🚀 Overview
|
|
9
|
+
|
|
10
|
+
**MLPipe** automates the repetitive engineering lifecycle for tabular machine learning models. Simply point MLPipe at your CSV dataset and designate a target column:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
Raw CSV Dataset
|
|
14
|
+
↓
|
|
15
|
+
Data Ingestion (Format validation & SHA-256 integrity hash)
|
|
16
|
+
↓
|
|
17
|
+
Data Profiling (Column types, distributions, missingness & flags)
|
|
18
|
+
↓
|
|
19
|
+
Pre-training Validation (Fatal structural errors & non-blocking warnings)
|
|
20
|
+
↓
|
|
21
|
+
Task Detection (Automatic classification vs. regression inference)
|
|
22
|
+
↓
|
|
23
|
+
Leakage-Free Splitting (Stratified or random train/test split)
|
|
24
|
+
↓
|
|
25
|
+
Automated Preprocessing (ColumnTransformer: imputation, scaling & encoding)
|
|
26
|
+
↓
|
|
27
|
+
Multi-Model Training & Tuning (RandomizedSearchCV strictly on training folds)
|
|
28
|
+
↓
|
|
29
|
+
CV-Based Leaderboard Ranking (Winning model selected by CV, not test set)
|
|
30
|
+
↓
|
|
31
|
+
Held-Out Test Evaluation (Unbiased final metrics & confusion matrix)
|
|
32
|
+
↓
|
|
33
|
+
Model Explainability (Recovered transformed feature importances & coefficients)
|
|
34
|
+
↓
|
|
35
|
+
Artifact Generation (Reusable pipeline, model, metadata & reports)
|
|
36
|
+
↓
|
|
37
|
+
Instant Predictions (CLI & Python inference)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
No hardcoded results. No fake training. Real scikit-learn models and metrics computed on your CPU machine.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 📦 Installation
|
|
45
|
+
|
|
46
|
+
Install locally in editable mode:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone https://github.com/your-org/mlpipe.git
|
|
50
|
+
cd mlpipe
|
|
51
|
+
pip install -e .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Verify the installation:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
mlpipe --version
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## ⚡ Quick Start
|
|
63
|
+
|
|
64
|
+
### 1. Terminal CLI
|
|
65
|
+
|
|
66
|
+
Train an end-to-end classification pipeline:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
mlpipe train demo_data/customer_churn.csv --target churn
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Train a regression pipeline:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
mlpipe train demo_data/house_prices.csv --target price
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Generate predictions on new data:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
mlpipe predict ./mlpipe_runs/<run_id>/pipeline.joblib demo_data/customer_churn.csv --output predictions.csv
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2. Python API
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from mlpipe import Pipeline
|
|
88
|
+
|
|
89
|
+
# 1. Initialize pipeline
|
|
90
|
+
pipeline = Pipeline(
|
|
91
|
+
target="churn",
|
|
92
|
+
task="auto", # auto-detects classification vs regression
|
|
93
|
+
mode="balanced", # "fast", "balanced", or "thorough"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# 2. Fit pipeline on CSV or DataFrame
|
|
97
|
+
result = pipeline.fit("demo_data/customer_churn.csv")
|
|
98
|
+
|
|
99
|
+
# 3. Inspect results
|
|
100
|
+
print("Best Model:", result.best_model)
|
|
101
|
+
print("Primary Metric:", result.primary_metric)
|
|
102
|
+
print("CV Score:", result.best_cv_score)
|
|
103
|
+
print("Test Score:", result.test_score)
|
|
104
|
+
print("Test Metrics:", result.metrics)
|
|
105
|
+
|
|
106
|
+
# 4. Save and reload pipeline
|
|
107
|
+
pipeline.save("./trained_models/churn_model")
|
|
108
|
+
|
|
109
|
+
loaded_pipeline = Pipeline.load("./trained_models/churn_model")
|
|
110
|
+
predictions = loaded_pipeline.predict("demo_data/customer_churn.csv")
|
|
111
|
+
print("Predictions:", predictions[:5])
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 🛠️ CLI Command Reference
|
|
117
|
+
|
|
118
|
+
### `mlpipe train`
|
|
119
|
+
Train multiple candidate models, tune hyperparameters, rank on leaderboard, and save artifacts.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
mlpipe train <data.csv> --target <target_col> [OPTIONS]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Options:**
|
|
126
|
+
- `--target, -t`: Target column name to predict (required).
|
|
127
|
+
- `--task`: Task type override: `auto` (default), `classification`, or `regression`.
|
|
128
|
+
- `--mode, -m`: Training mode budget: `fast`, `balanced` (default), or `thorough`.
|
|
129
|
+
- `--output, -o`: Base directory to store run artifacts (default: `./mlpipe_runs`).
|
|
130
|
+
- `--format, -f`: Output format: `human` (default) or `json`.
|
|
131
|
+
- `--verbose`: Enable detailed debug logging.
|
|
132
|
+
|
|
133
|
+
### `mlpipe profile`
|
|
134
|
+
Inspect dataset summary, column types, statistics, missingness, and structural issues.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
mlpipe profile demo_data/customer_churn.csv
|
|
138
|
+
mlpipe profile demo_data/customer_churn.csv --format json
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### `mlpipe validate`
|
|
142
|
+
Run pre-training validation checks on dataset and target.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
mlpipe validate demo_data/customer_churn.csv --target churn
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### `mlpipe predict`
|
|
149
|
+
Generate predictions on a new CSV dataset using a saved pipeline.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
mlpipe predict ./mlpipe_runs/<run_id>/pipeline.joblib new_data.csv --output preds.csv
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### `mlpipe inspect`
|
|
156
|
+
Inspect metadata, configuration, metrics, and generated artifacts from a previous run directory.
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
mlpipe inspect ./mlpipe_runs/<run_id>
|
|
160
|
+
mlpipe inspect ./mlpipe_runs/<run_id> --format json
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### `mlpipe version`
|
|
164
|
+
Display the current version of MLPipe.
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
mlpipe version
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 🧠 Supported Models
|
|
173
|
+
|
|
174
|
+
### Classification
|
|
175
|
+
- **Logistic Regression** (L2 penalty, liblinear/lbfgs/saga solvers)
|
|
176
|
+
- **Random Forest Classifier** (trees, depth, sample split/leaf tuning)
|
|
177
|
+
- **HistGradientBoosting Classifier** (iterations, learning rate, leaf bounds)
|
|
178
|
+
- **Decision Tree Classifier** (depth, split thresholds, criteria)
|
|
179
|
+
- **K-Nearest Neighbors** (neighbors, weights, distance metrics)
|
|
180
|
+
|
|
181
|
+
### Regression
|
|
182
|
+
- **Ridge Regression** (regularization alpha, solver selection)
|
|
183
|
+
- **Random Forest Regressor** (trees, depth, sample bounds, features)
|
|
184
|
+
- **HistGradientBoosting Regressor** (iterations, rate, regularization)
|
|
185
|
+
- **Decision Tree Regressor** (depth, split criteria, sample leaves)
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## 🔒 Data Leakage Prevention Guarantee
|
|
190
|
+
|
|
191
|
+
MLPipe adheres to strict data integrity standards:
|
|
192
|
+
1. **No Full-Data Transformations:** Preprocessing pipelines are never fitted on the entire dataset.
|
|
193
|
+
2. **Train/Test Split First:** The raw dataset is partitioned (default 80% train, 20% test) before column classification and transformer fitting.
|
|
194
|
+
3. **Cross-Validation Inside Pipelines:** During hyperparameter search, sklearn `Pipeline` objects fit transformers solely on the internal training fold of each split.
|
|
195
|
+
4. **CV-Based Model Selection:** The winning model is selected strictly based on CV score on the training set. The held-out test set is evaluated exactly once for unbiased reporting.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## 📁 Artifact Structure
|
|
200
|
+
|
|
201
|
+
Each completed training run generates a self-contained bundle under `./mlpipe_runs/<run_id>/`:
|
|
202
|
+
|
|
203
|
+
```text
|
|
204
|
+
mlpipe_runs/<run_id>/
|
|
205
|
+
├── pipeline.joblib # Complete fitted pipeline (preprocessor + estimator)
|
|
206
|
+
├── model.joblib # Fitted estimator alone
|
|
207
|
+
├── metrics.json # CV and test evaluation metrics
|
|
208
|
+
├── leaderboard.json # Complete ranked candidate comparison table
|
|
209
|
+
├── metadata.json # Dataset hash, seed, mode, environment & parameters
|
|
210
|
+
├── feature_importance.json # Top features with recovered transformed names
|
|
211
|
+
└── report.txt # Plain text human-readable run summary
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 🧪 Running Tests
|
|
217
|
+
|
|
218
|
+
Run the complete test suite using `pytest`:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
pytest
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Run with verbose test output:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
pytest -v
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 📄 License
|
|
233
|
+
|
|
234
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mlpipe-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Production-ready tabular ML automation library and terminal CLI"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "MLPipe Contributors" }
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"pandas>=2.0.0",
|
|
28
|
+
"numpy>=1.24.0",
|
|
29
|
+
"scikit-learn>=1.3.0",
|
|
30
|
+
"joblib>=1.3.0",
|
|
31
|
+
"scipy>=1.10.0",
|
|
32
|
+
"typer[all]>=0.9.0",
|
|
33
|
+
"rich>=13.0.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
dev = [
|
|
38
|
+
"pytest>=7.0.0",
|
|
39
|
+
"pytest-cov>=4.0.0",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[project.scripts]
|
|
43
|
+
mlpipe = "mlpipe.cli.main:app"
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.packages.find]
|
|
46
|
+
where = ["src"]
|
|
47
|
+
|
|
48
|
+
[tool.pytest.ini_options]
|
|
49
|
+
testpaths = ["tests"]
|
|
50
|
+
python_files = ["test_*.py"]
|
|
51
|
+
python_functions = ["test_*"]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MLPipe: Automated Machine Learning Library and Terminal CLI.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from mlpipe.core.config import PipelineConfig, TaskType, TrainingMode
|
|
6
|
+
from mlpipe.core.exceptions import (
|
|
7
|
+
ArtifactError,
|
|
8
|
+
ConfigurationError,
|
|
9
|
+
DatasetError,
|
|
10
|
+
EvaluationError,
|
|
11
|
+
MLPipeError,
|
|
12
|
+
PipelineError,
|
|
13
|
+
PredictionError,
|
|
14
|
+
PreprocessingError,
|
|
15
|
+
TrainingError,
|
|
16
|
+
ValidationError,
|
|
17
|
+
)
|
|
18
|
+
from mlpipe.core.pipeline import Pipeline
|
|
19
|
+
from mlpipe.core.result import PipelineResult
|
|
20
|
+
from mlpipe.data.profiling import DatasetProfile
|
|
21
|
+
from mlpipe.data.validation import ValidationReport
|
|
22
|
+
from mlpipe.version import __version__
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"Pipeline",
|
|
26
|
+
"PipelineResult",
|
|
27
|
+
"DatasetProfile",
|
|
28
|
+
"ValidationReport",
|
|
29
|
+
"PipelineConfig",
|
|
30
|
+
"TaskType",
|
|
31
|
+
"TrainingMode",
|
|
32
|
+
"MLPipeError",
|
|
33
|
+
"DatasetError",
|
|
34
|
+
"ValidationError",
|
|
35
|
+
"PreprocessingError",
|
|
36
|
+
"TrainingError",
|
|
37
|
+
"EvaluationError",
|
|
38
|
+
"ArtifactError",
|
|
39
|
+
"ConfigurationError",
|
|
40
|
+
"PredictionError",
|
|
41
|
+
"PipelineError",
|
|
42
|
+
"__version__",
|
|
43
|
+
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Artifact management and serialization for MLPipe."""
|
|
2
|
+
|
|
3
|
+
from mlpipe.artifacts.manager import (
|
|
4
|
+
ArtifactManager,
|
|
5
|
+
inspect_run_directory,
|
|
6
|
+
load_pipeline_artifact,
|
|
7
|
+
)
|
|
8
|
+
from mlpipe.artifacts.serialization import (
|
|
9
|
+
load_joblib,
|
|
10
|
+
load_json,
|
|
11
|
+
save_joblib,
|
|
12
|
+
save_json,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"ArtifactManager",
|
|
17
|
+
"inspect_run_directory",
|
|
18
|
+
"load_pipeline_artifact",
|
|
19
|
+
"load_joblib",
|
|
20
|
+
"load_json",
|
|
21
|
+
"save_joblib",
|
|
22
|
+
"save_json",
|
|
23
|
+
]
|