mnoorchenar's picture
Sync from GitHub f4d09ab: Rename repo to loss-function-playground; update README links
a354662
|
Raw History Blame Contribute Delete
7.41 kB
metadata
title: ML Loss Function Playground
emoji: 🧠
colorFrom: purple
colorTo: blue
sdk: docker
app_port: 7860
pinned: false

🧠 ML Loss Function Playground

Typing SVG

Python Flask PyTorch Plotly Docker Status


Live Demo Source Code


🧠 ML Loss Function Playground β€” An interactive web application for exploring and comparing loss functions in regression and classification tasks using PyTorch.



Table of Contents


✨ Features

  • Compare multiple loss functions side by side:
    • MSE, MAE, Huber (for regression)
    • BCE, Cross Entropy, Sparse Categorical Cross Entropy (for classification)
  • Switch between:
    • Regression
    • Binary classification
    • Multi-class classification
  • Generate synthetic datasets with adjustable:
    • Noise level
    • Outlier percentage and magnitude
    • Number of samples and features
  • Visualize:
    • Training vs validation loss curves
    • Total training time per loss function
    • Metric tables (Accuracy, F1, RΒ², etc.)
  • View convergence epochs and speed comparisons

🧰 Technical Overview

  • Framework: Flask + PyTorch
  • Frontend: HTML + Plotly.js
  • Dataset Generation: scikit-learn synthetic datasets
  • Metrics:
    • Regression: MSE, MAE, RΒ²
    • Classification: Accuracy, Precision, Recall, F1

πŸš€ Getting Started

Prerequisites

  • Python 3.10+
  • Git
  • Docker (optional)

Local Installation

# 1. Clone the repository
git clone https://github.com/mnoorchenar/loss-function-playground.git
cd loss-function-playground
# 2. Create a virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# 3. Install dependencies
pip install -r requirements.txt

# 4. Run the application
python app.py

Open your browser at http://localhost:7860 πŸŽ‰


🐳 Docker Deployment

docker build -t loss-function-playground .
docker run -p 7860:7860 loss-function-playground

πŸ—οΈ How It Works

  1. The app generates a synthetic dataset for the chosen task.
  2. For each selected loss function:
    • It builds a simple fully connected PyTorch network.
    • Trains it for the specified number of epochs.
    • Tracks loss, convergence, and timing.
  3. The results are visualized interactively in the browser.

πŸ“ Project Structure

loss-function-playground/
β”‚
β”œβ”€β”€ πŸ“„ Dockerfile                 # Container definition (port 7860)
β”œβ”€β”€ πŸ“„ app.py                     # Application entry point
└── πŸ“„ requirements.txt           # Python dependencies

πŸ‘¨β€πŸ’» Author

Mohammad Noorchenarboo

Mohammad Noorchenarboo

Data Scientist  |  AI Researcher  |  Biostatistician

πŸ“  Ontario, Canada    πŸ“§  mohammadnoorchenarboo@gmail.com

──────────────────────────────────────

LinkedIn  Personal Site  HuggingFace  Google Scholar  GitHub


⚠️ Disclaimer

This project is developed strictly for educational purposes and does not constitute professional advice of any kind. All datasets used are either synthetically generated or publicly available. This software is provided "as is" without warranty of any kind; use at your own risk.


πŸ“œ License

Β© 2025 Mohammad Noorchenarboo. All rights reserved.

This project and all associated code are the intellectual property of the author. Reproduction, redistribution, or modification of any part of this repository is strictly prohibited without prior written permission. For permissions or inquiries, contact: LinkedIn


Star on GitHub Fork on GitHub

The name "ML Loss Function Playground" is used purely for academic and research purposes. Any similarity to existing product names or trademarks is entirely coincidental. This project has no affiliation with any commercial entity.