Skip to content

0Jos-hua0/ML-Models-Visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒŸ STELLARBASIN - ML Model Visualizer & Explainer

StellarBasin is an advanced web application that visualizes and explains machine learning models with beautiful, interactive charts and comprehensive explanations.

Version Python React Flask


โœจ Features

๐ŸŽฏ Supported Models

StellarBasin supports 7 major machine learning model types:

  1. ๐ŸŒณ Decision Tree (Classifier & Regressor)

    • Interactive tree structure visualization
    • Node and leaf information
    • Feature importance analysis
  2. ๐Ÿ“ˆ Linear Regression (1D & 2D)

    • 1D: Line plot with slope and intercept
    • 2D: 3D surface visualization
    • Multi-dimensional: Coefficient bar charts
  3. ๐Ÿ“Š Logistic Regression

    • 1D: Sigmoid curve visualization
    • 2D: Decision boundary contour plots
    • Probability distributions
  4. ๐ŸŽฏ Support Vector Machine (SVM)

    • Support vector visualization
    • Kernel information
    • Decision boundary analysis
  5. ๐Ÿ” K-Nearest Neighbors (KNN)

    • Class distribution charts
    • Neighbor configuration
    • Distance metrics
  6. ๐Ÿ”ต K-Means Clustering

    • Cluster center visualization (2D/3D)
    • Cluster heatmaps
    • Inertia and convergence info
  7. ๐ŸŒฒ Hierarchical Clustering

    • Cluster size distribution
    • Linkage method explanation
    • Dendrogram information
  8. ๐ŸŽฒ Naive Bayes (Gaussian, Multinomial, Bernoulli)

    • Prior probability visualization
    • Variant-specific explanations
    • Bayes theorem breakdown

๐Ÿš€ Getting Started

Prerequisites

  • Python 3.8+
  • Node.js 14+
  • npm or yarn

Installation

1. Clone the Repository

git clone <your-repo-url>
cd StellarBasin

2. Backend Setup (Flask)

# Navigate to backend
cd backend

# Create virtual environment (optional but recommended)
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

3. Frontend Setup (React)

# Navigate to frontend
cd frontend

# Install dependencies
npm install

๐ŸŽฎ Running the Application

Start Backend Server

cd backend
python app.py

The Flask server will start on http://localhost:5000

Start Frontend Server

Open a new terminal and run:

cd frontend
npm start

The React app will open automatically on http://localhost:3000


๐Ÿ“– How to Use

Step 1: Prepare Your Model

Train and save your scikit-learn model using joblib:

import joblib
from sklearn.tree import DecisionTreeClassifier

# Train your model
model = DecisionTreeClassifier()
model.fit(X_train, y_train)

# Save the model
joblib.dump(model, 'my_model.pkl')

Step 2: Upload Model

  1. Open the StellarBasin web app
  2. Click "Choose File" and select your .pkl model file
  3. Click "Upload & Analyze"

Step 3: Explore Results

The app will display:

  • ๐Ÿ“Š Interactive Visualizations - Plotly charts or matplotlib images
  • ๐Ÿง  Detailed Explanations - How the model works, parameters, equations
  • ๐Ÿ“ Mathematical Formulas - The underlying equations
  • โš™๏ธ Model Parameters - All hyperparameters and settings
  • ๐Ÿ’ก Interpretations - What the results mean

๐ŸŽจ Visualization Examples

Decision Tree

  • Full tree structure with nodes and leaves
  • Color-coded by class or value
  • Feature importance bars

Linear Regression (2D)

  • 3D surface plot showing prediction plane
  • Interactive rotation and zoom
  • Coefficient annotations

K-Means Clustering

  • 2D/3D scatter plots of cluster centers
  • Heatmaps for high-dimensional data
  • Cluster statistics

SVM

  • Support vector highlights
  • Decision boundary visualization
  • Margin representation

๐Ÿ› ๏ธ Technology Stack

Backend

  • Flask - Web framework
  • scikit-learn - ML model support
  • Plotly - Interactive visualizations
  • Matplotlib - Static visualizations
  • NumPy - Numerical computations

Frontend

  • React 19 - UI framework
  • Plotly.js - Interactive charts
  • Axios - HTTP requests
  • CSS3 - Styling and animations

๐Ÿ“ Project Structure

StellarBasin/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ app.py                 # Flask server
โ”‚   โ”œโ”€โ”€ stellarbasin.py        # Model visualization logic
โ”‚   โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ”‚   โ””โ”€โ”€ uploads/               # Temporary upload folder
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ App.js            # Main application
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ModelUploader.js      # Upload component
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ExplanationPanel.js   # Explanation display
โ”‚   โ”‚   โ””โ”€โ”€ assets/           # Images and resources
โ”‚   โ”œโ”€โ”€ package.json          # Node dependencies
โ”‚   โ””โ”€โ”€ public/               # Static files
โ”œโ”€โ”€ models/                   # Sample models (optional)
โ””โ”€โ”€ README.md                # This file

๐Ÿงช Testing with Sample Models

You can test the app with sample models from the models/ directory or create your own:

# Example: Create a simple Decision Tree
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
import joblib

# Load data
iris = load_iris()
X, y = iris.data, iris.target

# Train model
model = DecisionTreeClassifier(max_depth=3)
model.fit(X, y)

# Save model
joblib.dump(model, 'iris_decision_tree.pkl')

๐ŸŽฏ Supported File Formats

  • .pkl (Pickle)
  • .joblib (Joblib)
  • .pickle (Pickle variant)

๐Ÿ› Troubleshooting

Backend Issues

Problem: ModuleNotFoundError

# Solution: Install missing dependencies
pip install -r backend/requirements.txt

Problem: Port 5000 already in use

# Solution: Change port in app.py
app.run(debug=True, port=5001)

Frontend Issues

Problem: npm start fails

# Solution: Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install

Problem: CORS errors

# Solution: Ensure Flask-CORS is installed
pip install flask-cors

๐Ÿ”ฎ Future Enhancements

  • Support for ensemble models (Random Forest, Gradient Boosting)
  • Neural network visualization
  • Model comparison feature
  • Export visualizations as images
  • Batch model upload
  • Model performance metrics
  • Custom color themes

๐Ÿ“„ License

This project is open source and available under the MIT License.


๐Ÿ‘จโ€๐Ÿ’ป Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


๐Ÿ“ง Contact

For questions or feedback, please open an issue on GitHub.


Made with โค๏ธ for the Machine Learning community

๐ŸŒŸ Star this repo if you find it helpful!

About

A Web based Application that can produce Visualizations and Report for Supervised Learning Models.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published