Skip to main content

A foundational linear algebra and ML modeling framework built with educational traceability.

Project description

ML-Lense Logo

ML-Lense

Understand Machine Learning — Not Just Use It.

Explainable, interpretable, and educational tooling that reveals how ML really works under the hood.

License Python Status


✨ What is ML-Lense?

ML-Lense is an open-source library that helps you see inside machine learning.

Instead of treating ML as a black box, ML-Lense explains:

  • Why a model made a prediction
  • How parameters were learned
  • What math drives each algorithm
  • How features influence outcomes
  • What happens during training step-by-step

It is designed for:

  • Researchers
  • Students
  • Engineers
  • Educators
  • Curious builders

If scikit-learn helps you build models,
ML-Lense helps you understand them.


🧠 Philosophy

Modern ML tooling focuses on:

  • Accuracy
  • Speed
  • Scale

But rarely on:

  • Understanding
  • Interpretability
  • First-principles learning

ML-Lense exists to change that.

ML should be understandable, not mysterious.


🔍 Core Idea

Train any model → Get a deep explanation layer.

from sklearn.linear_model import LinearRegression
from ml_lense import explain

model = LinearRegression().fit(X, y)
report = explain(model, X, y)

report.show()

ML-Lense generates:

  • Parameter reasoning
  • Mathematical derivations
  • Feature importance breakdown
  • Training dynamics
  • Human-readable explanations

🚀 Features

1️⃣ Parameter Transparency

Understand why weights were chosen.

  • Linear models → closed-form math
  • Neural nets → gradient dynamics
  • Tree models → split logic

2️⃣ Math-Aware Explanations

Every output maps back to math.

  • Loss function analysis
  • Gradient flow visualization
  • Optimization reasoning
  • Statistical assumptions

3️⃣ Training Dynamics

See what happens during learning.

  • Convergence behavior
  • Bias vs variance shifts
  • Overfitting detection
  • Learning stability

4️⃣ Feature Attribution

Not just importance — causation-aware insights

  • Local explanations
  • Global influence
  • Interaction effects
  • Feature sensitivity curves

5️⃣ First-Principles Reports

ML-Lense produces structured outputs:

  • Markdown reports
  • PDF summaries
  • Interactive notebooks
  • Teaching-ready visualizations

📚 Supported Domains (Roadmap)

Classical ML

  • Linear Regression
  • Logistic Regression
  • SVM
  • kNN
  • Decision Trees
  • Random Forest
  • Gradient Boosting

Deep Learning

  • MLPs
  • CNNs
  • Transformers (planned)
  • Attention analysis

Statistics

  • Hypothesis testing insights
  • t-tests, chi-square reasoning
  • Distribution assumptions
  • Sampling diagnostics

Time Series

  • ARIMA interpretability
  • Seasonality decomposition
  • Forecast uncertainty analysis

🧪 Example Outputs

ML-Lense produces explanations like:

"Weight w₃ is large because feature variance is high and strongly correlated with the target."

"Model confidence comes from low residual spread across 92% of samples."

"Gradient oscillations indicate suboptimal learning rate."


🎯 Use Cases

🎓 Education

  • Learn ML intuitively
  • Teach algorithms visually
  • Bridge math ↔ implementation

🔬 Research

  • Interpret experimental models
  • Debug training failures
  • Generate explanation reports

🏭 Production ML

  • Model debugging
  • Stakeholder explainability
  • Responsible AI documentation

🆚 How is this different?

Tool Focus
scikit-learn Model building
SHAP/LIME Feature attribution
TensorBoard Training metrics
ML-Lense Full-stack understanding

ML-Lense combines:

  • Math
  • Training behavior
  • Interpretability
  • Intuition

In one unified layer.


� Installation

pip install ml-lense

Or development install:

git clone https://github.com/SANJAYRAM-DS/ml-lense
cd ml-lense
pip install -e .

⚡ Quick Start

from ml_lense import explain
from sklearn.datasets import load_diabetes
from sklearn.linear_model import Ridge

X, y = load_diabetes(return_X_y=True)
model = Ridge().fit(X, y)

lens = explain(model, X, y)

lens.summary()
lens.math()
lens.training_dynamics()
lens.feature_story()

📊 Outputs

ML-Lense can generate:

  • 📄 Markdown reports
  • 📘 Research-ready PDFs
  • 📊 Visual dashboards
  • 🧠 Math walkthroughs

🧱 Design Principles

  • Minimal API
  • Model-agnostic
  • Math-first
  • Research-grade clarity
  • Documentation-friendly

🤝 Contributing

We welcome contributors from:

  • ML researchers
  • Students
  • Educators
  • Open-source developers

Ways to contribute:

  • Add model explainers
  • Improve math modules
  • Create tutorials
  • Expand domains (time series, NLP, CV)

See CONTRIBUTING.md for details.


🌍 Vision

ML-Lense aims to become:

The "NumPy for understanding machine learning."

A universal layer that makes every model:

  • Transparent
  • Learnable
  • Explainable
  • Trustworthy

� License

MIT License — use freely in research and industry.


⭐ If you like ML-Lense

  • Star the repo
  • Share with learners
  • Use in teaching
  • Contribute ideas

Let's make machine learning understandable.


Built with clarity in mind.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mllense-0.1.0.tar.gz (77.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mllense-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file mllense-0.1.0.tar.gz.

File metadata

  • Download URL: mllense-0.1.0.tar.gz
  • Upload date:
  • Size: 77.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for mllense-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e07de8b01422f12471351fbe8f62ceec32de54dedd3f92c2d0ce683340be7f86
MD5 ac4c7778ffdb9513e09c299841d80f0b
BLAKE2b-256 20daada646d29cc6b50b368dbe8d0392c129cc6282371df3a0791991d361ef62

See more details on using hashes here.

File details

Details for the file mllense-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mllense-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for mllense-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c55a390092931b6a1da2786f4c6e33930f9b7f511ebce5fad46f2ae07a7489c
MD5 e13fff221740c92c43405df73d3327b3
BLAKE2b-256 0a4c5cbcdc58bd3502458e9cefe889a26e6b7095a73556fcf2fb4bb51391419f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page