š
ML-Math
Open Source
PYTHON
ML Math
No description provided on GitHub.
Created
Feb 2026
Last Updated
Feb 2026
Stars
0 ā
Status
Available
mlmath ā Mathematics for Machine Learning, Interactively
A terminal-based interactive learning tool covering the complete mathematics of machine learning, inspired by Marc Peter Deisenroth's "Mathematics for Machine Learning" (Cambridge University Press, 2020).
Features
- 20 curriculum blocks ā theory, formulas, derivations, worked examples, and code
- 3-layer visualizations ā ASCII (always), plotext terminal plots, matplotlib windows
- Interactive exercises ā beginner / intermediate / advanced, with hints and solutions
- Progress tracker ā marks blocks as completed, shown as a progress bar
- Topic search ā find any block by keyword
Quick Start
1. Install dependencies
pip install -r requirements.txt
2. Run
cd mlmath
python main.py
Requirements
| Package | Purpose |
|---|---|
| numpy | Core numerical computing |
| scipy | Special functions, statistics |
| sympy | Symbolic math, LaTeX rendering |
| scikit-learn | Reference implementations & data |
| rich | Terminal UI (tables, markdown) |
| plotext | Terminal-native plots (Layer 2) |
| matplotlib | GUI plots in separate window (L3) |
Curriculum Overview
| # | Block | Topics |
|---|---|---|
| 01 | Linear Algebra | Vectors, matrices, norms, SVD, PCA |
| 02 | Matrix Decompositions | LU, QR, Cholesky, eigendecomposition |
| 03 | Calculus & Autodiff | Gradients, Jacobians, Taylor, dual numbers |
| 04 | Optimization | GD, Newton, Lagrange multipliers, convexity |
| 05 | Probability Theory | Distributions, Bayes, MLE, conjugate priors |
| 06 | Statistics | Estimators, CI, hypothesis tests, p-values |
| 07 | Information Theory | Entropy, KL divergence, mutual information |
| 08 | Backpropagation | Computational graphs, chain rule, autograd |
| 09 | Activation Functions | ReLU, Sigmoid, GELU, Swish, Mish |
| 10 | Supervised Learning | Linear/logistic regression, SVM, decision trees |
| 11 | Bias-Variance Tradeoff | Decomposition, regularization, cross-validation |
| 12 | Unsupervised Learning | K-means, PCA, DBSCAN, autoencoders |
| 13 | EM Algorithm | Latent variables, E/M steps, GMM |
| 14 | Probabilistic ML | Bayesian inference, GPs, variational inference |
| 15 | RL Mathematics | MDPs, Bellman equations, Q-learning, policy gradient |
| 16 | MDP Solvers | Value/policy iteration, dynamic programming |
| 17 | Deep Learning Math | Attention, batch norm, transformers, residuals |
| 18 | NLP Mathematics | TF-IDF, word2vec, BERT, BPE, BLEU |
| 19 | Kernel Methods | Mercer's theorem, SVM dual, kernel PCA, GPs |
| 20 | Model Evaluation | ROC/AUC, calibration, AIC/BIC, stat tests |
Project Structure
mlmath/
āāā main.py # Entry point ā run this
āāā config.py # Colors, themes, settings
āāā requirements.txt
ā
āāā blocks/ # 20 curriculum blocks
ā āāā __init__.py # BLOCKS registry
ā āāā b01_linear_algebra.py
ā āāā b02_matrix_decomp.py
ā ā ...
ā āāā b20_model_evaluation.py
ā
āāā exercises/ # Interactive exercises
ā āāā __init__.py # all_exercises dict
ā āāā ex01_linear_algebra.py
ā āāā ex03_calculus.py
ā āāā ex05_probability.py
ā āāā ex08_backprop.py
ā āāā ex10_supervised.py
ā āāā ex12_unsupervised.py
ā āāā ex15_rl.py
ā āāā ex17_deep_learning.py
ā
āāā core/ # Math utility library
ā āāā linalg.py
ā āāā calculus.py
ā āāā optimization.py
ā āāā probability.py
ā āāā stats.py
ā
āāā ui/ # Terminal UI components
ā āāā colors.py
ā āāā widgets.py
ā āāā menu.py
ā
āāā viz/ # 3-layer visualization
āāā ascii_plots.py # Layer 1: always available
āāā terminal_plots.py # Layer 2: plotext
āāā matplotlib_plots.py # Layer 3: GUI window
Navigation
Main Menu
[1] Browse Curriculum Blocks ā select 1-20 ā full topic menu ā topics
[2] Practice Exercises ā pick exercise set ā attempt / hint / run
[3] Search Topics ā keyword search across all 20 blocks
[4] Mark Block Complete ā update progress bar
[q] Quit
Within each block:
- Topics listed as a numbered menu ā pick any topic for theory + example + viz
[0]goes back to the previous menu
Within each exercise:
[h]show hint[c]show starter code[s]reveal full solution[r]run solution and print output[b]go back
Adding a New Block
- Create
blocks/b21_your_topic.pywith arun()function:
def run():
topics = [("Topic Name", topic_fn), ...]
while True:
# print menu
# dispatch by number
- Register in
blocks/__init__.py:
from blocks.b21_your_topic import run as b21
BLOCKS.append(("Your Topic", b21, "Short description"))
- Add to
main.py'sBLOCK_METAlist andblock_moduleslist.
Adding a New Exercise Set
- Create
exercises/exXX_topic.pyfollowing theExerciseclass pattern:
class Exercise:
def __init__(self, title, difficulty, description, hint, starter_code, solution_code): ...
exercises = [Exercise(...), Exercise(...), Exercise(...)] # 3 per set
def run(): ...
def _run_exercise(ex): ...
- Register in
exercises/__init__.py:
from exercises.exXX_topic import run as exXX
all_exercises["XX"] = exXX
Reference
- Deisenroth, Faisal, Ong ā Mathematics for Machine Learning (2020) https://mml-book.github.io/ (free PDF)
- Course website: https://mml-book.com
License
MIT License. Educational use encouraged.