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).
- 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
pip install -r requirements.txtcd mlmath
python main.py| 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) |
| # | 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 |
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
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
- 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.
- 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- Deisenroth, Faisal, Ong — Mathematics for Machine Learning (2020) https://mml-book.github.io/ (free PDF)
- Course website: https://mml-book.com
MIT License. Educational use encouraged.