multimodel-analysis 0.0.2__tar.gz → 0.0.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.
- multimodel_analysis-0.0.4/PKG-INFO +337 -0
- multimodel_analysis-0.0.4/README.md +308 -0
- {multimodel_analysis-0.0.2 → multimodel_analysis-0.0.4}/multimodel_analysis/__init__.py +7 -6
- multimodel_analysis-0.0.4/multimodel_analysis/multimodel.py +581 -0
- multimodel_analysis-0.0.4/multimodel_analysis.egg-info/PKG-INFO +337 -0
- {multimodel_analysis-0.0.2 → multimodel_analysis-0.0.4}/setup.py +29 -29
- multimodel_analysis-0.0.2/PKG-INFO +0 -211
- multimodel_analysis-0.0.2/README.md +0 -182
- multimodel_analysis-0.0.2/multimodel_analysis/multimodel.py +0 -407
- multimodel_analysis-0.0.2/multimodel_analysis.egg-info/PKG-INFO +0 -211
- {multimodel_analysis-0.0.2 → multimodel_analysis-0.0.4}/LICENSE +0 -0
- {multimodel_analysis-0.0.2 → multimodel_analysis-0.0.4}/MANIFEST.in +0 -0
- {multimodel_analysis-0.0.2 → multimodel_analysis-0.0.4}/multimodel_analysis.egg-info/SOURCES.txt +0 -0
- {multimodel_analysis-0.0.2 → multimodel_analysis-0.0.4}/multimodel_analysis.egg-info/dependency_links.txt +0 -0
- {multimodel_analysis-0.0.2 → multimodel_analysis-0.0.4}/multimodel_analysis.egg-info/requires.txt +0 -0
- {multimodel_analysis-0.0.2 → multimodel_analysis-0.0.4}/multimodel_analysis.egg-info/top_level.txt +0 -0
- {multimodel_analysis-0.0.2 → multimodel_analysis-0.0.4}/requirements.txt +0 -0
- {multimodel_analysis-0.0.2 → multimodel_analysis-0.0.4}/setup.cfg +0 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: multimodel_analysis
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: A Python Package for Automatic Multi-Model Analysis (Classification & Regression)
|
|
5
|
+
Author: Uditya Narayan Tiwari
|
|
6
|
+
Author-email: tiwarimerit@gmail.com
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: numpy
|
|
16
|
+
Requires-Dist: pandas
|
|
17
|
+
Requires-Dist: matplotlib
|
|
18
|
+
Requires-Dist: seaborn
|
|
19
|
+
Requires-Dist: scikit-learn
|
|
20
|
+
Dynamic: author
|
|
21
|
+
Dynamic: author-email
|
|
22
|
+
Dynamic: classifier
|
|
23
|
+
Dynamic: description
|
|
24
|
+
Dynamic: description-content-type
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
Dynamic: requires-dist
|
|
27
|
+
Dynamic: requires-python
|
|
28
|
+
Dynamic: summary
|
|
29
|
+
|
|
30
|
+
# 🚀 MultiModel Analysis
|
|
31
|
+
|
|
32
|
+
<div align="center">
|
|
33
|
+
|
|
34
|
+
<img src="multi_modelml.png" alt="MultiModel Analysis Banner" width="100%"/>
|
|
35
|
+
|
|
36
|
+
### **Train • Evaluate • Compare • Visualize Multiple Machine Learning Models in Minutes**
|
|
37
|
+
|
|
38
|
+
A lightweight, robust Python library that automates model benchmarking, metric evaluation, and visualization for both **Classification** and **Regression** tasks.
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
|
|
42
|
+
[](https://pypi.org/project/multimodel-analysis/)
|
|
43
|
+
[](https://pypi.org/project/multimodel-analysis/)
|
|
44
|
+
[](https://pypi.org/project/multimodel-analysis/)
|
|
45
|
+
[](LICENSE)
|
|
46
|
+
[](https://scikit-learn.org/)
|
|
47
|
+
[]()
|
|
48
|
+
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
**Created & Maintained by [Uditya Narayan Tiwari](https://github.com/udityamerit)**
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 📖 Table of Contents
|
|
58
|
+
|
|
59
|
+
- [Overview](#-overview)
|
|
60
|
+
- [Why MultiModel Analysis?](#-why-multimodel-analysis)
|
|
61
|
+
- [Key Features](#-key-features)
|
|
62
|
+
- [Supported Models](#-supported-models)
|
|
63
|
+
- [Installation](#-installation)
|
|
64
|
+
- [Quick Start](#-quick-start)
|
|
65
|
+
- [Classification Example](#classification-workflow)
|
|
66
|
+
- [Regression Example](#regression-workflow)
|
|
67
|
+
- [End-to-End Workflow](#-end-to-end-workflow)
|
|
68
|
+
- [API Reference](#-api-reference)
|
|
69
|
+
- [MultiModelClassifier](#multimodelclassifier)
|
|
70
|
+
- [MultiModelRegressor](#multimodelregressor)
|
|
71
|
+
- [Requirements](#-requirements)
|
|
72
|
+
- [License & Citation](#-license--author)
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 📖 Overview
|
|
77
|
+
|
|
78
|
+
Selecting the optimal Machine Learning model requires training, tuning, and comparing multiple algorithms. Traditionally, this process demands writing repetitive boilerplate code for:
|
|
79
|
+
- Splitting datasets and feature scaling
|
|
80
|
+
- Fitting each estimator individually
|
|
81
|
+
- Extracting evaluation metrics (Accuracy, F1, MAE, R², etc.)
|
|
82
|
+
- Generating figures (Confusion Matrices, ROC Curves, Scatter plots)
|
|
83
|
+
- Ranking models to recommend the best performer
|
|
84
|
+
|
|
85
|
+
**MultiModel Analysis** automates this entire pipeline into a clean, intuitive, production-grade interface. With just a few lines of code, you can train 8 classifiers or 7 regressors, evaluate their performance, generate publication-ready plots, and receive an instant recommendation for the best model.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 💡 Why MultiModel Analysis?
|
|
90
|
+
|
|
91
|
+
Instead of writing repetitive, error-prone code like this:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
# Traditional Workflow (100+ lines of repetitive code)
|
|
95
|
+
model1.fit(X_train, y_train)
|
|
96
|
+
model2.fit(X_train, y_train)
|
|
97
|
+
pred1 = model1.predict(X_test)
|
|
98
|
+
pred2 = model2.predict(X_test)
|
|
99
|
+
|
|
100
|
+
acc1 = accuracy_score(y_test, pred1)
|
|
101
|
+
f1_1 = f1_score(y_test, pred1, average='weighted')
|
|
102
|
+
# ... Repeat for every model & plot manually
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Simply write:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from multimodel_analysis import MultiModelClassifier
|
|
109
|
+
|
|
110
|
+
# Automated Benchmarking Workflow
|
|
111
|
+
classifier = MultiModelClassifier(X, y, scaled_data=True)
|
|
112
|
+
results = classifier.run_all_models()
|
|
113
|
+
classifier.get_summary(results)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## ✨ Key Features
|
|
119
|
+
|
|
120
|
+
- ⚡ **Automated Multi-Model Benchmarking**: Train up to 8 classifiers or 7 regressors simultaneously.
|
|
121
|
+
- 🎯 **Multiclass & String Target Support**: Built-in `LabelEncoder` handles string targets (e.g. `'Cat'`, `'Dog'`), multi-class target variables, and binary targets smoothly.
|
|
122
|
+
- 📊 **Multiclass ROC-AUC Calculation**: Accurate One-vs-Rest ROC-AUC computation (`multi_class='ovr'`) for multiclass classification without silent metric failures.
|
|
123
|
+
- 📏 **DataFrame Feature Integrity**: Preserves pandas DataFrame column names and indices during standard scaling.
|
|
124
|
+
- 🛡️ **Fault-Tolerant Execution**: Exception handling insulates model fitting so a single failing estimator will not crash the overall benchmark.
|
|
125
|
+
- 🖥️ **Cross-Platform Safe**: Unicode print fallbacks prevent `charmap` / terminal encoding errors on Windows, macOS, and Linux console environments.
|
|
126
|
+
- 📈 **Publication-Ready Visualizations**: Automatically generates styled Confusion Matrices with class names, ROC curves, Regression error scatter plots, and metric bar charts.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 🤖 Supported Models
|
|
131
|
+
|
|
132
|
+
### 🎯 Classification Models (`MultiModelClassifier`)
|
|
133
|
+
1. **Logistic Regression**
|
|
134
|
+
2. **Support Vector Machine (SVC)**
|
|
135
|
+
3. **K-Nearest Neighbors (KNN)**
|
|
136
|
+
4. **Decision Tree Classifier**
|
|
137
|
+
5. **Random Forest Classifier**
|
|
138
|
+
6. **Gaussian Naive Bayes**
|
|
139
|
+
7. **Gradient Boosting Classifier**
|
|
140
|
+
8. **AdaBoost Classifier**
|
|
141
|
+
|
|
142
|
+
### 📈 Regression Models (`MultiModelRegressor`)
|
|
143
|
+
1. **Linear Regression**
|
|
144
|
+
2. **Lasso Regression**
|
|
145
|
+
3. **Ridge Regression**
|
|
146
|
+
4. **Support Vector Regression (SVR)**
|
|
147
|
+
5. **Decision Tree Regressor**
|
|
148
|
+
6. **Random Forest Regressor**
|
|
149
|
+
7. **Gradient Boosting Regressor**
|
|
150
|
+
|
|
151
|
+
*(Note: `MultiModelRegressior` is retained as a backwards-compatible alias for legacy code).*
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 📦 Installation
|
|
156
|
+
|
|
157
|
+
### From PyPI (Recommended)
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pip install multimodel-analysis
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Upgrade to the latest version:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
pip install --upgrade multimodel-analysis
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### From GitHub Source
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
pip install git+https://github.com/udityamerit/Multimodel-Analysis-Pacakge.git
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 🚀 Quick Start
|
|
178
|
+
|
|
179
|
+
### Classification Workflow
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
import pandas as pd
|
|
183
|
+
from multimodel_analysis import MultiModelClassifier
|
|
184
|
+
|
|
185
|
+
# 1. Load your dataset
|
|
186
|
+
df = pd.read_csv("dataset.csv")
|
|
187
|
+
X = df.drop("target", axis=1)
|
|
188
|
+
y = df["target"] # Can be numeric or strings like 'Class_A', 'Class_B', 'Class_C'
|
|
189
|
+
|
|
190
|
+
# 2. Initialize classifier with feature scaling & stratified train/test split
|
|
191
|
+
classifier = MultiModelClassifier(
|
|
192
|
+
X=X,
|
|
193
|
+
y=y,
|
|
194
|
+
test_size=0.3,
|
|
195
|
+
scaled_data=True,
|
|
196
|
+
random_state=42
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
# 3. Train all classification models
|
|
200
|
+
results = classifier.run_all_models()
|
|
201
|
+
|
|
202
|
+
# 4. Show tabular summary and visualizations
|
|
203
|
+
classifier.show_tabular_report(results)
|
|
204
|
+
classifier.plot_confusion_matrices(results)
|
|
205
|
+
classifier.plot_roc_curves(results)
|
|
206
|
+
classifier.plot_comparison(results)
|
|
207
|
+
|
|
208
|
+
# Or run all reporting functions in one call:
|
|
209
|
+
# classifier.get_summary(results)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
### Regression Workflow
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
import pandas as pd
|
|
218
|
+
from multimodel_analysis import MultiModelRegressor
|
|
219
|
+
|
|
220
|
+
# 1. Load housing dataset
|
|
221
|
+
df = pd.read_csv("housing.csv")
|
|
222
|
+
X = df.drop("Price", axis=1)
|
|
223
|
+
y = df["Price"]
|
|
224
|
+
|
|
225
|
+
# 2. Initialize regressor
|
|
226
|
+
regressor = MultiModelRegressor(
|
|
227
|
+
X=X,
|
|
228
|
+
y=y,
|
|
229
|
+
test_size=0.3,
|
|
230
|
+
scaled_data=True,
|
|
231
|
+
random_state=42
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
# 3. Train all regression models
|
|
235
|
+
results = regressor.run_all_models()
|
|
236
|
+
|
|
237
|
+
# 4. Display report table & plots
|
|
238
|
+
regressor.show_tabular_report(results)
|
|
239
|
+
regressor.plot_true_vs_predicted(results)
|
|
240
|
+
regressor.plot_comparison(results)
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 🏗 End-to-End Workflow
|
|
246
|
+
|
|
247
|
+
```mermaid
|
|
248
|
+
flowchart LR
|
|
249
|
+
A["📂 Load Dataset (X, y)"] --> B["🧹 Target & Data Preprocessing"]
|
|
250
|
+
B --> C["🏷 LabelEncoder (String & Multiclass)"]
|
|
251
|
+
C --> D{"⚙️ Feature Scaling?"}
|
|
252
|
+
D -->|Enabled| E["📏 StandardScaler (Preserves Columns)"]
|
|
253
|
+
D -->|Disabled| F["➡️ Raw Features"]
|
|
254
|
+
E --> G["✂️ Stratified Train / Test Split"]
|
|
255
|
+
F --> G
|
|
256
|
+
G --> H{"🎯 Machine Learning Task"}
|
|
257
|
+
H -->|Classification| I["🤖 Train 8 Classifiers"]
|
|
258
|
+
H -->|Regression| J["📈 Train 7 Regressors"]
|
|
259
|
+
I --> K["📊 Compute Accuracy, F1, ROC-AUC (OVR)"]
|
|
260
|
+
J --> L["📈 Compute MAE, MSE, RMSE, R² Score"]
|
|
261
|
+
K --> M["📈 Generate Figures & Tabular Benchmark"]
|
|
262
|
+
L --> M
|
|
263
|
+
M --> N["🏆 Recommend Best Model"]
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## 📚 API Reference
|
|
269
|
+
|
|
270
|
+
### `MultiModelClassifier`
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
MultiModelClassifier(X, y, test_size=0.3, scaled_data=False, random_state=42, stratify=True)
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### Parameters:
|
|
277
|
+
- `X`: *DataFrame or array-like of shape (n_samples, n_features)* — Feature matrix.
|
|
278
|
+
- `y`: *Series or array-like of shape (n_samples,)* — Target labels (numeric or categorical strings).
|
|
279
|
+
- `test_size`: *float, default=0.3* — Proportion of dataset for test split.
|
|
280
|
+
- `scaled_data`: *bool, default=False* — Fits and applies `StandardScaler` to features.
|
|
281
|
+
- `random_state`: *int, default=42* — Random seed for reproducibility.
|
|
282
|
+
- `stratify`: *bool, default=True* — Enables stratified splitting for balanced class ratios.
|
|
283
|
+
|
|
284
|
+
#### Key Methods:
|
|
285
|
+
- `.run_all_models()`: Fits all classification algorithms and returns evaluated metric tuples.
|
|
286
|
+
- `.show_tabular_report(models)`: Prints clean comparison table sorted by Accuracy and recommends the top model.
|
|
287
|
+
- `.plot_confusion_matrices(models)`: Displays styled confusion matrix heatmaps with actual class labels.
|
|
288
|
+
- `.plot_roc_curves(models)`: Plots combined ROC curves and AUC scores.
|
|
289
|
+
- `.plot_comparison(models)`: Generates metric comparison bar plots (Accuracy, Precision, Recall, F1).
|
|
290
|
+
- `.get_summary(models)`: Runs complete reporting and plotting pipeline.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
### `MultiModelRegressor`
|
|
295
|
+
|
|
296
|
+
```python
|
|
297
|
+
MultiModelRegressor(X, y, test_size=0.3, scaled_data=False, random_state=42)
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
#### Parameters:
|
|
301
|
+
- `X`: *DataFrame or array-like of shape (n_samples, n_features)* — Feature matrix.
|
|
302
|
+
- `y`: *Series or array-like of shape (n_samples,)* — Continuous target variable.
|
|
303
|
+
- `test_size`: *float, default=0.3* — Proportion of dataset for test split.
|
|
304
|
+
- `scaled_data`: *bool, default=False* — Fits and applies `StandardScaler` to features.
|
|
305
|
+
- `random_state`: *int, default=42* — Random seed for reproducibility.
|
|
306
|
+
|
|
307
|
+
#### Key Methods:
|
|
308
|
+
- `.run_all_models()`: Fits all regressor algorithms and returns evaluation metric tuples.
|
|
309
|
+
- `.show_tabular_report(models)`: Displays tabular report sorted by $R^2$ Score and recommends the top regressor.
|
|
310
|
+
- `.plot_true_vs_predicted(models)`: Displays True vs Predicted value scatter plots with perfect prediction reference line.
|
|
311
|
+
- `.plot_comparison(models)`: Displays $R^2$ score bar plot comparison across models.
|
|
312
|
+
- `.get_summary(models)`: Runs complete reporting pipeline.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## 📚 Requirements
|
|
317
|
+
|
|
318
|
+
| Requirement | Supported Version |
|
|
319
|
+
|-------------|-------------------|
|
|
320
|
+
| **Python** | `>= 3.8` |
|
|
321
|
+
| **NumPy** | `*` |
|
|
322
|
+
| **Pandas** | `*` |
|
|
323
|
+
| **Matplotlib** | `*` |
|
|
324
|
+
| **Seaborn** | `*` |
|
|
325
|
+
| **Scikit-Learn** | `*` |
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## 📜 License & Author
|
|
330
|
+
|
|
331
|
+
Distributed under the **Apache 2.0 License**. See `LICENSE` for more information.
|
|
332
|
+
|
|
333
|
+
**Author & Maintainer:**
|
|
334
|
+
Uditya Narayan Tiwari
|
|
335
|
+
📧 Email: [tiwarimerit@gmail.com](mailto:tiwarimerit@gmail.com)
|
|
336
|
+
🌐 GitHub: [@udityamerit](https://github.com/udityamerit)
|
|
337
|
+
📦 PyPI: [multimodel-analysis](https://pypi.org/project/multimodel-analysis/)
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# 🚀 MultiModel Analysis
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<img src="multi_modelml.png" alt="MultiModel Analysis Banner" width="100%"/>
|
|
6
|
+
|
|
7
|
+
### **Train • Evaluate • Compare • Visualize Multiple Machine Learning Models in Minutes**
|
|
8
|
+
|
|
9
|
+
A lightweight, robust Python library that automates model benchmarking, metric evaluation, and visualization for both **Classification** and **Regression** tasks.
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
|
|
13
|
+
[](https://pypi.org/project/multimodel-analysis/)
|
|
14
|
+
[](https://pypi.org/project/multimodel-analysis/)
|
|
15
|
+
[](https://pypi.org/project/multimodel-analysis/)
|
|
16
|
+
[](LICENSE)
|
|
17
|
+
[](https://scikit-learn.org/)
|
|
18
|
+
[]()
|
|
19
|
+
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
**Created & Maintained by [Uditya Narayan Tiwari](https://github.com/udityamerit)**
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 📖 Table of Contents
|
|
29
|
+
|
|
30
|
+
- [Overview](#-overview)
|
|
31
|
+
- [Why MultiModel Analysis?](#-why-multimodel-analysis)
|
|
32
|
+
- [Key Features](#-key-features)
|
|
33
|
+
- [Supported Models](#-supported-models)
|
|
34
|
+
- [Installation](#-installation)
|
|
35
|
+
- [Quick Start](#-quick-start)
|
|
36
|
+
- [Classification Example](#classification-workflow)
|
|
37
|
+
- [Regression Example](#regression-workflow)
|
|
38
|
+
- [End-to-End Workflow](#-end-to-end-workflow)
|
|
39
|
+
- [API Reference](#-api-reference)
|
|
40
|
+
- [MultiModelClassifier](#multimodelclassifier)
|
|
41
|
+
- [MultiModelRegressor](#multimodelregressor)
|
|
42
|
+
- [Requirements](#-requirements)
|
|
43
|
+
- [License & Citation](#-license--author)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 📖 Overview
|
|
48
|
+
|
|
49
|
+
Selecting the optimal Machine Learning model requires training, tuning, and comparing multiple algorithms. Traditionally, this process demands writing repetitive boilerplate code for:
|
|
50
|
+
- Splitting datasets and feature scaling
|
|
51
|
+
- Fitting each estimator individually
|
|
52
|
+
- Extracting evaluation metrics (Accuracy, F1, MAE, R², etc.)
|
|
53
|
+
- Generating figures (Confusion Matrices, ROC Curves, Scatter plots)
|
|
54
|
+
- Ranking models to recommend the best performer
|
|
55
|
+
|
|
56
|
+
**MultiModel Analysis** automates this entire pipeline into a clean, intuitive, production-grade interface. With just a few lines of code, you can train 8 classifiers or 7 regressors, evaluate their performance, generate publication-ready plots, and receive an instant recommendation for the best model.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 💡 Why MultiModel Analysis?
|
|
61
|
+
|
|
62
|
+
Instead of writing repetitive, error-prone code like this:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
# Traditional Workflow (100+ lines of repetitive code)
|
|
66
|
+
model1.fit(X_train, y_train)
|
|
67
|
+
model2.fit(X_train, y_train)
|
|
68
|
+
pred1 = model1.predict(X_test)
|
|
69
|
+
pred2 = model2.predict(X_test)
|
|
70
|
+
|
|
71
|
+
acc1 = accuracy_score(y_test, pred1)
|
|
72
|
+
f1_1 = f1_score(y_test, pred1, average='weighted')
|
|
73
|
+
# ... Repeat for every model & plot manually
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Simply write:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from multimodel_analysis import MultiModelClassifier
|
|
80
|
+
|
|
81
|
+
# Automated Benchmarking Workflow
|
|
82
|
+
classifier = MultiModelClassifier(X, y, scaled_data=True)
|
|
83
|
+
results = classifier.run_all_models()
|
|
84
|
+
classifier.get_summary(results)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## ✨ Key Features
|
|
90
|
+
|
|
91
|
+
- ⚡ **Automated Multi-Model Benchmarking**: Train up to 8 classifiers or 7 regressors simultaneously.
|
|
92
|
+
- 🎯 **Multiclass & String Target Support**: Built-in `LabelEncoder` handles string targets (e.g. `'Cat'`, `'Dog'`), multi-class target variables, and binary targets smoothly.
|
|
93
|
+
- 📊 **Multiclass ROC-AUC Calculation**: Accurate One-vs-Rest ROC-AUC computation (`multi_class='ovr'`) for multiclass classification without silent metric failures.
|
|
94
|
+
- 📏 **DataFrame Feature Integrity**: Preserves pandas DataFrame column names and indices during standard scaling.
|
|
95
|
+
- 🛡️ **Fault-Tolerant Execution**: Exception handling insulates model fitting so a single failing estimator will not crash the overall benchmark.
|
|
96
|
+
- 🖥️ **Cross-Platform Safe**: Unicode print fallbacks prevent `charmap` / terminal encoding errors on Windows, macOS, and Linux console environments.
|
|
97
|
+
- 📈 **Publication-Ready Visualizations**: Automatically generates styled Confusion Matrices with class names, ROC curves, Regression error scatter plots, and metric bar charts.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 🤖 Supported Models
|
|
102
|
+
|
|
103
|
+
### 🎯 Classification Models (`MultiModelClassifier`)
|
|
104
|
+
1. **Logistic Regression**
|
|
105
|
+
2. **Support Vector Machine (SVC)**
|
|
106
|
+
3. **K-Nearest Neighbors (KNN)**
|
|
107
|
+
4. **Decision Tree Classifier**
|
|
108
|
+
5. **Random Forest Classifier**
|
|
109
|
+
6. **Gaussian Naive Bayes**
|
|
110
|
+
7. **Gradient Boosting Classifier**
|
|
111
|
+
8. **AdaBoost Classifier**
|
|
112
|
+
|
|
113
|
+
### 📈 Regression Models (`MultiModelRegressor`)
|
|
114
|
+
1. **Linear Regression**
|
|
115
|
+
2. **Lasso Regression**
|
|
116
|
+
3. **Ridge Regression**
|
|
117
|
+
4. **Support Vector Regression (SVR)**
|
|
118
|
+
5. **Decision Tree Regressor**
|
|
119
|
+
6. **Random Forest Regressor**
|
|
120
|
+
7. **Gradient Boosting Regressor**
|
|
121
|
+
|
|
122
|
+
*(Note: `MultiModelRegressior` is retained as a backwards-compatible alias for legacy code).*
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 📦 Installation
|
|
127
|
+
|
|
128
|
+
### From PyPI (Recommended)
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pip install multimodel-analysis
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Upgrade to the latest version:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
pip install --upgrade multimodel-analysis
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### From GitHub Source
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
pip install git+https://github.com/udityamerit/Multimodel-Analysis-Pacakge.git
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 🚀 Quick Start
|
|
149
|
+
|
|
150
|
+
### Classification Workflow
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
import pandas as pd
|
|
154
|
+
from multimodel_analysis import MultiModelClassifier
|
|
155
|
+
|
|
156
|
+
# 1. Load your dataset
|
|
157
|
+
df = pd.read_csv("dataset.csv")
|
|
158
|
+
X = df.drop("target", axis=1)
|
|
159
|
+
y = df["target"] # Can be numeric or strings like 'Class_A', 'Class_B', 'Class_C'
|
|
160
|
+
|
|
161
|
+
# 2. Initialize classifier with feature scaling & stratified train/test split
|
|
162
|
+
classifier = MultiModelClassifier(
|
|
163
|
+
X=X,
|
|
164
|
+
y=y,
|
|
165
|
+
test_size=0.3,
|
|
166
|
+
scaled_data=True,
|
|
167
|
+
random_state=42
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
# 3. Train all classification models
|
|
171
|
+
results = classifier.run_all_models()
|
|
172
|
+
|
|
173
|
+
# 4. Show tabular summary and visualizations
|
|
174
|
+
classifier.show_tabular_report(results)
|
|
175
|
+
classifier.plot_confusion_matrices(results)
|
|
176
|
+
classifier.plot_roc_curves(results)
|
|
177
|
+
classifier.plot_comparison(results)
|
|
178
|
+
|
|
179
|
+
# Or run all reporting functions in one call:
|
|
180
|
+
# classifier.get_summary(results)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
### Regression Workflow
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
import pandas as pd
|
|
189
|
+
from multimodel_analysis import MultiModelRegressor
|
|
190
|
+
|
|
191
|
+
# 1. Load housing dataset
|
|
192
|
+
df = pd.read_csv("housing.csv")
|
|
193
|
+
X = df.drop("Price", axis=1)
|
|
194
|
+
y = df["Price"]
|
|
195
|
+
|
|
196
|
+
# 2. Initialize regressor
|
|
197
|
+
regressor = MultiModelRegressor(
|
|
198
|
+
X=X,
|
|
199
|
+
y=y,
|
|
200
|
+
test_size=0.3,
|
|
201
|
+
scaled_data=True,
|
|
202
|
+
random_state=42
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
# 3. Train all regression models
|
|
206
|
+
results = regressor.run_all_models()
|
|
207
|
+
|
|
208
|
+
# 4. Display report table & plots
|
|
209
|
+
regressor.show_tabular_report(results)
|
|
210
|
+
regressor.plot_true_vs_predicted(results)
|
|
211
|
+
regressor.plot_comparison(results)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 🏗 End-to-End Workflow
|
|
217
|
+
|
|
218
|
+
```mermaid
|
|
219
|
+
flowchart LR
|
|
220
|
+
A["📂 Load Dataset (X, y)"] --> B["🧹 Target & Data Preprocessing"]
|
|
221
|
+
B --> C["🏷 LabelEncoder (String & Multiclass)"]
|
|
222
|
+
C --> D{"⚙️ Feature Scaling?"}
|
|
223
|
+
D -->|Enabled| E["📏 StandardScaler (Preserves Columns)"]
|
|
224
|
+
D -->|Disabled| F["➡️ Raw Features"]
|
|
225
|
+
E --> G["✂️ Stratified Train / Test Split"]
|
|
226
|
+
F --> G
|
|
227
|
+
G --> H{"🎯 Machine Learning Task"}
|
|
228
|
+
H -->|Classification| I["🤖 Train 8 Classifiers"]
|
|
229
|
+
H -->|Regression| J["📈 Train 7 Regressors"]
|
|
230
|
+
I --> K["📊 Compute Accuracy, F1, ROC-AUC (OVR)"]
|
|
231
|
+
J --> L["📈 Compute MAE, MSE, RMSE, R² Score"]
|
|
232
|
+
K --> M["📈 Generate Figures & Tabular Benchmark"]
|
|
233
|
+
L --> M
|
|
234
|
+
M --> N["🏆 Recommend Best Model"]
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## 📚 API Reference
|
|
240
|
+
|
|
241
|
+
### `MultiModelClassifier`
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
MultiModelClassifier(X, y, test_size=0.3, scaled_data=False, random_state=42, stratify=True)
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
#### Parameters:
|
|
248
|
+
- `X`: *DataFrame or array-like of shape (n_samples, n_features)* — Feature matrix.
|
|
249
|
+
- `y`: *Series or array-like of shape (n_samples,)* — Target labels (numeric or categorical strings).
|
|
250
|
+
- `test_size`: *float, default=0.3* — Proportion of dataset for test split.
|
|
251
|
+
- `scaled_data`: *bool, default=False* — Fits and applies `StandardScaler` to features.
|
|
252
|
+
- `random_state`: *int, default=42* — Random seed for reproducibility.
|
|
253
|
+
- `stratify`: *bool, default=True* — Enables stratified splitting for balanced class ratios.
|
|
254
|
+
|
|
255
|
+
#### Key Methods:
|
|
256
|
+
- `.run_all_models()`: Fits all classification algorithms and returns evaluated metric tuples.
|
|
257
|
+
- `.show_tabular_report(models)`: Prints clean comparison table sorted by Accuracy and recommends the top model.
|
|
258
|
+
- `.plot_confusion_matrices(models)`: Displays styled confusion matrix heatmaps with actual class labels.
|
|
259
|
+
- `.plot_roc_curves(models)`: Plots combined ROC curves and AUC scores.
|
|
260
|
+
- `.plot_comparison(models)`: Generates metric comparison bar plots (Accuracy, Precision, Recall, F1).
|
|
261
|
+
- `.get_summary(models)`: Runs complete reporting and plotting pipeline.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
### `MultiModelRegressor`
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
MultiModelRegressor(X, y, test_size=0.3, scaled_data=False, random_state=42)
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
#### Parameters:
|
|
272
|
+
- `X`: *DataFrame or array-like of shape (n_samples, n_features)* — Feature matrix.
|
|
273
|
+
- `y`: *Series or array-like of shape (n_samples,)* — Continuous target variable.
|
|
274
|
+
- `test_size`: *float, default=0.3* — Proportion of dataset for test split.
|
|
275
|
+
- `scaled_data`: *bool, default=False* — Fits and applies `StandardScaler` to features.
|
|
276
|
+
- `random_state`: *int, default=42* — Random seed for reproducibility.
|
|
277
|
+
|
|
278
|
+
#### Key Methods:
|
|
279
|
+
- `.run_all_models()`: Fits all regressor algorithms and returns evaluation metric tuples.
|
|
280
|
+
- `.show_tabular_report(models)`: Displays tabular report sorted by $R^2$ Score and recommends the top regressor.
|
|
281
|
+
- `.plot_true_vs_predicted(models)`: Displays True vs Predicted value scatter plots with perfect prediction reference line.
|
|
282
|
+
- `.plot_comparison(models)`: Displays $R^2$ score bar plot comparison across models.
|
|
283
|
+
- `.get_summary(models)`: Runs complete reporting pipeline.
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 📚 Requirements
|
|
288
|
+
|
|
289
|
+
| Requirement | Supported Version |
|
|
290
|
+
|-------------|-------------------|
|
|
291
|
+
| **Python** | `>= 3.8` |
|
|
292
|
+
| **NumPy** | `*` |
|
|
293
|
+
| **Pandas** | `*` |
|
|
294
|
+
| **Matplotlib** | `*` |
|
|
295
|
+
| **Seaborn** | `*` |
|
|
296
|
+
| **Scikit-Learn** | `*` |
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## 📜 License & Author
|
|
301
|
+
|
|
302
|
+
Distributed under the **Apache 2.0 License**. See `LICENSE` for more information.
|
|
303
|
+
|
|
304
|
+
**Author & Maintainer:**
|
|
305
|
+
Uditya Narayan Tiwari
|
|
306
|
+
📧 Email: [tiwarimerit@gmail.com](mailto:tiwarimerit@gmail.com)
|
|
307
|
+
🌐 GitHub: [@udityamerit](https://github.com/udityamerit)
|
|
308
|
+
📦 PyPI: [multimodel-analysis](https://pypi.org/project/multimodel-analysis/)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
# Entry level code and import for Multi-Model Analysis
|
|
2
|
-
|
|
3
|
-
from .multimodel import MultiModelClassifier
|
|
4
|
-
from .multimodel import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
# Entry level code and import for Multi-Model Analysis
|
|
2
|
+
|
|
3
|
+
from .multimodel import MultiModelClassifier
|
|
4
|
+
from .multimodel import MultiModelRegressor
|
|
5
|
+
from .multimodel import MultiModelRegressior
|
|
6
|
+
|
|
7
|
+
__version__ = '0.0.4'
|
|
7
8
|
__author__ = 'Uditya Narayan Tiwari'
|