Skip to main content

GlassBoxML

Machine Learning you can actually see.

Python Tests License PyPI

Overview

GlassBoxML is a theory-first machine learning library built from scratch using pure NumPy.

Unlike traditional libraries that prioritize abstraction and convenience, GlassBoxML emphasizes transparency and understanding. Every model exposes:

what it learns how it learns where it fails

This project bridges the gap between mathematical learning theory and practical implementation.

Philosophy

Most ML libraries behave like black boxes:

model.fit(X, y)
# magic happens

GlassBoxML is different:

model.fit(X, y)

model.loss_history
model.gradients
model.assumptions
model.failure_modes
model.generalization_estimate

You don't just train models — you inspect learning itself.

Goals Implement core ML algorithms from first principles Expose optimization behavior during training Make model assumptions explicit Demonstrate overfitting and generalization Provide educational transparency without sacrificing code quality Non-Goals Competing with high-performance libraries like scikit-learn GPU acceleration Massive algorithm coverage Production deployment pipelines

This is a learning and reasoning library, not a benchmarking tool.


Implemented / Planned Algorithms

Core Models

  • Linear Regression
  • Logistic Regression
  • k‑Nearest Neighbors
  • Ridge Regression
  • Lasso Regression
  • Decision Trees
  • Random Forest
  • SVM

Optimization

  • Batch Gradient Descent
  • Stochastic Gradient Descent
  • Momentum

Diagnostics

  • Loss curves
  • Bias–variance indicators
  • Overfitting detection
  • Condition number warnings

Theory Tools

  • Generalization estimates — implemented as model.generalization_estimate, a lightweight, capacity-vs-sample-size heuristic that works without a held-out validation set
  • Capacity indicators
  • Noise sensitivity analysis

Feature Extraction & Pipelines

  • TF-IDF Vectorizer (sparse and dense modes)
  • Sparse Random Projection
  • Pipeline for chaining preprocessing and models

Example

from glassboxml import LinearRegression

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

print(model.loss_history)
print(model.explain())
print(model.diagnose())  # dataset profile, training error, failure modes, and generalization_estimate

Project Structure

glassboxml/
│
├── core/               # optimizers, model selection, Pipeline, base classes
├── models/             # ML algorithms
├── diagnostics/        # overfitting & model insights
├── datasets/           # synthetic data generators
├── metrics/            # evaluation metrics
├── preprocessing/      # scaling and transformations
├── feature_extraction/ # TF-IDF vectorizer
├── tuning/             # hyperparameter search
└── examples/           # demos & experiments

Installation

From PyPI:

pip install glassboxml

From source:

git clone https://github.com/hogwarts-coder10/GlassBox-ML.git
cd GlassBox-ML
pip install -r requirements.txt

Dependencies are intentionally minimal:

  • numpy
  • matplotlib
  • scipy

Why This Project Exists

Modern ML education often teaches usage before understanding.

This creates developers who can:

train models ❌ but not explain, debug, or trust them ❌

GlassBoxML reverses that:

Understand → Implement → Experiment → Trust


Contributing

This project values clarity over cleverness.

Contributions should:

Prefer readable, math-aligned code Include explanation comments Demonstrate failure cases, not just success


Metadata

Release files for glassboxml 0.2.2

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

Source distribution (sdist)

Source distribution for glassboxml 0.2.2
File Size Uploaded Provenance Actions
glassboxml-0.2.2.tar.gz 56.6 kB Without provenance Details for glassboxml-0.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 122.6 kB

Release files / glassboxml-0.2.2.tar.gz

Download URL glassboxml-0.2.2.tar.gz
Size 56.6 kB
Tags Source
SHA-256 checksum
How to use checksums
387be56d1d336b8be030cbb40076467571df58913ed317558dbe0c93774320cd
BLAKE2b-256 checksum
How to use checksums
75ef93b63c32e9f0e8f8400d9893dc062ed858e09fb3dad2334287065ce7083c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / glassboxml-0.2.2-py3-none-any.whl

Download URL glassboxml-0.2.2-py3-none-any.whl
Size 66.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5121020b3abf369093748065c37de03642b095613445091bdf42c873146590f4
BLAKE2b-256 checksum
How to use checksums
d52f897ad001ff1499816d8a52faf1bd0eb8546b9dbe760d93d0949c38f40e3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for glassboxml 0.2.2

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.

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