
Machine Learning from Scratch
Learn the math and intuition behind machine learning algorithms, then implement them in Python
The book spans 4 volumes. Read in order, or browse the contents to find the topic you need.
Read Machine Learning from Scratch free online
Machine Learning from Scratch is for readers who want to see how algorithms actually work. We derive each method from the math, build the intuition step by step, and implement it in Python so you can inspect every decision.
Explore the book’s 4 volumes
Machine Learning from Scratch is organised into 4 volumes. Each volume covers a subject, divided into parts and chapters. Read from the beginning, or choose the volume you need.
66 published chapters · Free to read online
Volume 1Statistical Foundations and Hypothesis Testing2 parts · 22 chapters, including planned additionsBuy this volumeBuy PDF · $24
Part I
Statistical Foundations for Machine Learning
11 chaptersPart II
Hypothesis Testing
11 chaptersVolume 2Linear and Generalized Linear Models4 parts · 30 chapters, including planned additionsBuy this volumeBuy PDF · $24
Part III
Model Fundamentals and Diagnostics
8 chaptersPart IV
Model Evaluation and Selection
3 chaptersPart V
Linear and Generalized Linear Models
14 chaptersPart VI
Survival Analysis
5 chaptersVolume 3Trees, Explainability, and Unsupervised Learning6 parts · 25 chapters, including planned additionsBuy this volumeBuy PDF · $24
Part VII
Supervised Learning Beyond Linear Models
5 chaptersPart VIII
Tree-Based Models
7 chaptersPart IX
Unsupervised Learning
6 chaptersPart X
Dimensionality Reduction
3 chaptersPart XI
Model Interpretation
2 chaptersPart XII
Calibration and Prediction Uncertainty
2 chaptersVolume 4Forecasting and Optimization3 parts · 15 chapters, including planned additionsBuy this volumeBuy PDF · $24
Part XIII
Time Series Forecasting
6 chaptersPart XIV
Constrained Optimization
6 chaptersPart XV
Heuristic and Evolutionary Optimization
3 chaptersMore about the book
From the elegant simplicity of linear regression to the sophisticated power of gradient boosting and neural networks, every concept is built from first principles. You won't just learn how to use scikit-learn. You'll understand exactly what happens under the hood when you call fit() and predict(). Each algorithm is derived mathematically, explained intuitively, and implemented in clean, Python code.
Whether you're a data scientist looking to deepen your expertise, an ML engineer preparing for system design interviews, a researcher needing solid foundations, or a quantitative analyst applying machine learning to financial problems, this handbook provides the rigorous yet accessible treatment you need. Every chapter includes derivations you can follow, visualizations that build intuition, and implementations you can run and extend.
Covering statistics fundamentals, regression techniques, tree-based methods, clustering algorithms, dimensionality reduction, time series forecasting, and mathematical optimization, this is the definitive resource for anyone serious about mastering machine learning from the ground up.
The whole book, beautifully typeset, yours forever.
All ~1,717 pages as one beautifully typeset PDF
The complete companion code, every chapter as a runnable notebook
All future expansions, updates, and errata, free, forever
Downloadable editions for durable offline reading
EPUB edition included when it ships
$68
instead of $96 for the 4 volumes bought separately

Secure checkout via Stripe · Individual PDF links delivered to your inbox
Reader verdict
5.0
out of 5
12 five-star reader reviews
Genuine feedback, with names abbreviated for privacy.
Meet the community“I would like to thank you for your work. Specifically, the chapter: 'LIME Explainability: Complete Guide to Local Interpretable Model-Agnostic Explanations' was extremely helpful for me in understanding LIME and communicating to colleagues. Your work is inspiring and valuable. Thank you for doing it.”
“Really appreciate the way you have explained the concepts. Simple to understand, yet builds up knowledge exponentially, all while reinforcing it with examples repeatedly. I've read the last two chapters `74.Self-attention & 75.Q,K,V` and I've to admit, my concepts have never been clearer. You really are doing an amazing job breaking down maths and complex concepts like a story!”
“I am enjoying reading your writings. I appreciate the effort you put into it. I want to drop a note of thanks. Thank you!”
“I found your book Language AI Handbook's explanations of Transformer architectures and production deployment strategies to be exceptionally clear and insightful”
“Your writing feels like a treasure trove of great material. So, thank you for compiling everything on your website!”
“Thanks so much for establishing such an amazing community. I appreciate the opportunity to be a learner and a contributor to the community.”
“Thank you Michael. It's top!”
“I read a few of your blogs on NLP and oh WOW, they really are something, now I exactly know how all of the terms Entropy, Cross-entropy and how it is connected to Perplexity, will definitely read more of your blogs.”
“I came across your collection of online handbooks covering quantitative finance, AI, and machine learning. I wanted to reach out and thank you for making such high-quality material openly available. They are incredibly helpful for my CFA Level II review and for brushing up ahead of ML interviews.”
“I just came across your website where your books are available for free to read. Thank you so much for making this available to the public. This will help a lot of people.”
“Thanks for putting cool stuff out into the world.”
“I came across one of your books, Language AI Handbook, and man, I'm loving it. I've read many books but have never found such a comprehensive book on large models that covers everything from start to finish with such depth.”
Read all 12 reader reviews
“I would like to thank you for your work. Specifically, the chapter: 'LIME Explainability: Complete Guide to Local Interpretable Model-Agnostic Explanations' was extremely helpful for me in understanding LIME and communicating to colleagues. Your work is inspiring and valuable. Thank you for doing it.”
“Really appreciate the way you have explained the concepts. Simple to understand, yet builds up knowledge exponentially, all while reinforcing it with examples repeatedly. I've read the last two chapters `74.Self-attention & 75.Q,K,V` and I've to admit, my concepts have never been clearer. You really are doing an amazing job breaking down maths and complex concepts like a story!”
“Thanks so much for establishing such an amazing community. I appreciate the opportunity to be a learner and a contributor to the community.”
“I just came across your website where your books are available for free to read. Thank you so much for making this available to the public. This will help a lot of people.”
“I am enjoying reading your writings. I appreciate the effort you put into it. I want to drop a note of thanks. Thank you!”
“Thank you Michael. It's top!”
“Thanks for putting cool stuff out into the world.”
“I found your book Language AI Handbook's explanations of Transformer architectures and production deployment strategies to be exceptionally clear and insightful”
“Your writing feels like a treasure trove of great material. So, thank you for compiling everything on your website!”
“I came across your collection of online handbooks covering quantitative finance, AI, and machine learning. I wanted to reach out and thank you for making such high-quality material openly available. They are incredibly helpful for my CFA Level II review and for brushing up ahead of ML interviews.”
“I read a few of your blogs on NLP and oh WOW, they really are something, now I exactly know how all of the terms Entropy, Cross-entropy and how it is connected to Perplexity, will definitely read more of your blogs.”
“I came across one of your books, Language AI Handbook, and man, I'm loving it. I've read many books but have never found such a comprehensive book on large models that covers everything from start to finish with such depth.”
Author and edition details
About the author and this edition

Michael Brenndoerfer
Michael has spent more than a decade working across software engineering, data, AI, and business. He writes to understand difficult ideas more deeply and to share what he learns in a clear, practical way.
- Edition
- First edition
- Published
- Last reviewed
Version history
Kept current, not frozen in time
Each PDF purchase includes future editions. When the book changes, the updated copy appears in My books at no extra cost.
Current release
Edition 2026.08.2
Editorial improvements.
Earlier releases5
2026.08.1
Editorial refinements, restored plot typography, clearer logarithmic axes, and refreshed companion code.
2026.08.0
Editorial improvements throughout the book, with clearer explanations, refined presentation, improved plots and visualizations, and refreshed companion code.
2026.07.2
Improved companion notebooks and validation; removed the obsolete CLT appendix; updated the support contact.
2026.07.1
Validation edition bump: fixed typos in the SSE chapter.
2026.07.0
Initial public PDF and companion-code release.
Cite this book
Reference
Citation details
Cite or share this article.



