Skip to main content
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.

Metadata

Release files for mllense 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mllense 0.1.1
File Size Uploaded Provenance Actions
mllense-0.1.1.tar.gz 77.7 kB Without provenance Details for mllense-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mllense 0.1.1
File Interpreter ABI Platform Actions
mllense-0.1.1-py3-none-any.whl Python 3 none any Details for mllense-0.1.1-py3-none-any.whl

Total release size: 220.9 kB

Release files / mllense-0.1.1.tar.gz

Download URL mllense-0.1.1.tar.gz
Size 77.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b56eb28e9733db6b6fdda07fe2c331b75d16f0a5514655619a96144b328d507c
BLAKE2b-256 checksum
How to use checksums
26cd0d907c5335e0103c9fe87551bbb28b10bb6da54f8af17657cfcd42a25e96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / mllense-0.1.1-py3-none-any.whl

Download URL mllense-0.1.1-py3-none-any.whl
Size 143.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7069413418854c7d3b3c22d37fd86b9f86550f31f767dea73bd9a7434afc5551
BLAKE2b-256 checksum
How to use checksums
1941d0a0492af15bc6f8b8dc53128c6cc63145e6dfc5e25e4ebbea240b7eea78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for mllense 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page