🚀 MultiModel Analysis
Train • Evaluate • Compare • Visualize Multiple Machine Learning Models in Minutes
A lightweight, robust Python library that automates model benchmarking, metric evaluation, and visualization for both Classification and Regression tasks.
Created & Maintained by Uditya Narayan Tiwari
📖 Table of Contents
- Overview
- Why MultiModel Analysis?
- Key Features
- Supported Models
- Installation
- Quick Start
- End-to-End Workflow
- API Reference
- Requirements
- License & Citation
📖 Overview
Selecting the optimal Machine Learning model requires training, tuning, and comparing multiple algorithms. Traditionally, this process demands writing repetitive boilerplate code for:
- Splitting datasets and feature scaling
- Fitting each estimator individually
- Extracting evaluation metrics (Accuracy, F1, MAE, R², etc.)
- Generating figures (Confusion Matrices, ROC Curves, Scatter plots)
- Ranking models to recommend the best performer
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.
💡 Why MultiModel Analysis?
Instead of writing repetitive, error-prone code like this:
# Traditional Workflow (100+ lines of repetitive code)
model1.fit(X_train, y_train)
model2.fit(X_train, y_train)
pred1 = model1.predict(X_test)
pred2 = model2.predict(X_test)
acc1 = accuracy_score(y_test, pred1)
f1_1 = f1_score(y_test, pred1, average='weighted')
# ... Repeat for every model & plot manually
Simply write:
from multimodel_analysis import MultiModelClassifier
# Automated Benchmarking Workflow
classifier = MultiModelClassifier(X, y, scaled_data=True)
results = classifier.run_all_models()
classifier.get_summary(results)
✨ Key Features
- ⚡ Automated Multi-Model Benchmarking: Train up to 8 classifiers or 7 regressors simultaneously.
- 🎯 Multiclass & String Target Support: Built-in
LabelEncoderhandles string targets (e.g.'Cat','Dog'), multi-class target variables, and binary targets smoothly. - 📊 Multiclass ROC-AUC Calculation: Accurate One-vs-Rest ROC-AUC computation (
multi_class='ovr') for multiclass classification without silent metric failures. - 📏 DataFrame Feature Integrity: Preserves pandas DataFrame column names and indices during standard scaling.
- 🛡️ Fault-Tolerant Execution: Exception handling insulates model fitting so a single failing estimator will not crash the overall benchmark.
- 🖥️ Cross-Platform Safe: Unicode print fallbacks prevent
charmap/ terminal encoding errors on Windows, macOS, and Linux console environments. - 📈 Publication-Ready Visualizations: Automatically generates styled Confusion Matrices with class names, ROC curves, Regression error scatter plots, and metric bar charts.
🤖 Supported Models
🎯 Classification Models (MultiModelClassifier)
- Logistic Regression
- Support Vector Machine (SVC)
- K-Nearest Neighbors (KNN)
- Decision Tree Classifier
- Random Forest Classifier
- Gaussian Naive Bayes
- Gradient Boosting Classifier
- AdaBoost Classifier
📈 Regression Models (MultiModelRegressor)
- Linear Regression
- Lasso Regression
- Ridge Regression
- Support Vector Regression (SVR)
- Decision Tree Regressor
- Random Forest Regressor
- Gradient Boosting Regressor
(Note: MultiModelRegressior is retained as a backwards-compatible alias for legacy code).
📦 Installation
From PyPI (Recommended)
pip install multimodel-analysis
Upgrade to the latest version:
pip install --upgrade multimodel-analysis
From GitHub Source
pip install git+https://github.com/udityamerit/Multimodel-Analysis-Pacakge.git
🚀 Quick Start
Classification Workflow
import pandas as pd
from multimodel_analysis import MultiModelClassifier
# 1. Load your dataset
df = pd.read_csv("dataset.csv")
X = df.drop("target", axis=1)
y = df["target"] # Can be numeric or strings like 'Class_A', 'Class_B', 'Class_C'
# 2. Initialize classifier with feature scaling & stratified train/test split
classifier = MultiModelClassifier(
X=X,
y=y,
test_size=0.3,
scaled_data=True,
random_state=42
)
# 3. Train all classification models
results = classifier.run_all_models()
# 4. Show tabular summary and visualizations
classifier.show_tabular_report(results)
classifier.plot_confusion_matrices(results)
classifier.plot_roc_curves(results)
classifier.plot_comparison(results)
# Or run all reporting functions in one call:
# classifier.get_summary(results)
Regression Workflow
import pandas as pd
from multimodel_analysis import MultiModelRegressor
# 1. Load housing dataset
df = pd.read_csv("housing.csv")
X = df.drop("Price", axis=1)
y = df["Price"]
# 2. Initialize regressor
regressor = MultiModelRegressor(
X=X,
y=y,
test_size=0.3,
scaled_data=True,
random_state=42
)
# 3. Train all regression models
results = regressor.run_all_models()
# 4. Display report table & plots
regressor.show_tabular_report(results)
regressor.plot_true_vs_predicted(results)
regressor.plot_comparison(results)
🏗 End-to-End Workflow
flowchart LR
A["📂 Load Dataset (X, y)"] --> B["🧹 Target & Data Preprocessing"]
B --> C["🏷 LabelEncoder (String & Multiclass)"]
C --> D{"⚙️ Feature Scaling?"}
D -->|Enabled| E["📏 StandardScaler (Preserves Columns)"]
D -->|Disabled| F["➡️ Raw Features"]
E --> G["✂️ Stratified Train / Test Split"]
F --> G
G --> H{"🎯 Machine Learning Task"}
H -->|Classification| I["🤖 Train 8 Classifiers"]
H -->|Regression| J["📈 Train 7 Regressors"]
I --> K["📊 Compute Accuracy, F1, ROC-AUC (OVR)"]
J --> L["📈 Compute MAE, MSE, RMSE, R² Score"]
K --> M["📈 Generate Figures & Tabular Benchmark"]
L --> M
M --> N["🏆 Recommend Best Model"]
📚 API Reference
MultiModelClassifier
MultiModelClassifier(X, y, test_size=0.3, scaled_data=False, random_state=42, stratify=True)
Parameters:
X: DataFrame or array-like of shape (n_samples, n_features) — Feature matrix.y: Series or array-like of shape (n_samples,) — Target labels (numeric or categorical strings).test_size: float, default=0.3 — Proportion of dataset for test split.scaled_data: bool, default=False — Fits and appliesStandardScalerto features.random_state: int, default=42 — Random seed for reproducibility.stratify: bool, default=True — Enables stratified splitting for balanced class ratios.
Key Methods:
.run_all_models(): Fits all classification algorithms and returns evaluated metric tuples..show_tabular_report(models): Prints clean comparison table sorted by Accuracy and recommends the top model..plot_confusion_matrices(models): Displays styled confusion matrix heatmaps with actual class labels..plot_roc_curves(models): Plots combined ROC curves and AUC scores..plot_comparison(models): Generates metric comparison bar plots (Accuracy, Precision, Recall, F1)..get_summary(models): Runs complete reporting and plotting pipeline.
MultiModelRegressor
MultiModelRegressor(X, y, test_size=0.3, scaled_data=False, random_state=42)
Parameters:
X: DataFrame or array-like of shape (n_samples, n_features) — Feature matrix.y: Series or array-like of shape (n_samples,) — Continuous target variable.test_size: float, default=0.3 — Proportion of dataset for test split.scaled_data: bool, default=False — Fits and appliesStandardScalerto features.random_state: int, default=42 — Random seed for reproducibility.
Key Methods:
.run_all_models(): Fits all regressor algorithms and returns evaluation metric tuples..show_tabular_report(models): Displays tabular report sorted by $R^2$ Score and recommends the top regressor..plot_true_vs_predicted(models): Displays True vs Predicted value scatter plots with perfect prediction reference line..plot_comparison(models): Displays $R^2$ score bar plot comparison across models..get_summary(models): Runs complete reporting pipeline.
📚 Requirements
| Requirement | Supported Version |
|---|---|
| Python | >= 3.8 |
| NumPy | * |
| Pandas | * |
| Matplotlib | * |
| Seaborn | * |
| Scikit-Learn | * |
📜 License & Author
Distributed under the Apache 2.0 License. See LICENSE for more information.
Author & Maintainer:
Uditya Narayan Tiwari
📧 Email: tiwarimerit@gmail.com
🌐 GitHub: @udityamerit
📦 PyPI: multimodel-analysis
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file multimodel_analysis-0.0.4.tar.gz.
File metadata
- Download URL: multimodel_analysis-0.0.4.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f807e0530f7e959b55c48042b7c6362793fd99feab66c02d45dcb5c6d9d46f0
|
|
| MD5 |
521ac7c650ba9d28c1c59693564cfcbb
|
|
| BLAKE2b-256 |
c0d0ebb2f3baca69d10c0aba72ef8d35aa2a53dfb6d46a554797bfc8cbb497ba
|
File details
Details for the file multimodel_analysis-0.0.4-py3-none-any.whl.
File metadata
- Download URL: multimodel_analysis-0.0.4-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2652cf539917b246f28337af8382c60292b56d558884ea311cee1084ca20367
|
|
| MD5 |
1c66215ac90ee987ea68dbf477af2a1a
|
|
| BLAKE2b-256 |
abe53ff4488db197559abd0f25f4a015adc219704e7c0e2f44e00ea36070ab2d
|