rasbt/machine-learning-book: what the companion notebooks actually contain
Code Repository for Machine Learning with PyTorch and Scikit-Learn
At a glance
- What is it?
- The repository holds the 19 chapter notebooks for Machine Learning with PyTorch and Scikit-Learn, not a library. The README itself warns the notebooks may not be useful without the book's formulae and descriptive text.
- Who is it for?
- Adopt the notebooks if you already own Machine Learning with PyTorch and Scikit-Learn and want executable versions of its chapters, or if you are evaluating the book before buying. Skip it if you need a maintained library, a current PyTorch tutorial set, or code you can read standalone: the README states the notebooks may not be useful without the book's formulae and descriptive text.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 92 days ago.
- What is it written in?
- Mainly Jupyter Notebook, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
A book's code appendix, not a project you install
The repository exists to hold the code examples for Machine Learning with PyTorch and Scikit-Learn, published by Packt in 2022 by Sebastian Raschka, Yuxi (Hayden) Liu and Vahid Mirjalili. The README is explicit about what that means: these are just the code examples accompanying the book, uploaded for convenience, and the notebooks may not be useful without the formulae and descriptive text. That sentence is the whole adoption question. There is no package to pip install, no API to import, no versioned interface to depend on. What you get is nineteen directories, ch01 through ch19, each holding Jupyter notebooks that track a chapter. The audience is a reader with the book open beside the screen, or someone deciding whether to buy it. If you want a maintained machine learning library, this is the wrong repository, and the README says so before you clone anything.
Nineteen chapters, from perceptrons to graph networks and RL
The table of contents maps the repository's scope cleanly. The early chapters are scikit-learn territory: classification algorithms in ch02 and ch03, data preprocessing in ch04, dimensionality reduction in ch05, model evaluation and hyperparameter optimization in ch06, ensembles in ch07, sentiment analysis in ch08, regression in ch09, clustering in ch10. Then the book pivots. Chapter 11 implements a multi-layer artificial neural network from scratch, chapter 12 moves training to PyTorch, and chapter 13 covers PyTorch mechanics. Chapters 14 through 19 run through convolutional networks for images, recurrent networks for sequences, transformers for language, generative adversarial networks, graph neural networks, and reinforcement learning. That order matters for how you use the repository. If you only need scikit-learn preprocessing or model selection patterns, chapters 3 through 6 are where the code lives, and you never touch the PyTorch half. If you want the from-scratch network in ch11 before the framework version in ch12, the sequence is deliberate and worth following in order.
Getting a chapter running: ch01/README.md is the entry point
The README does not list environment setup itself. It points twice to a single file: helpful installation and setup instructions can be found in the README.md file of Chapter 1, and again under Coding Environment, please see the ch01/README.md file for setup recommendations. So the first real step is opening ch01/README.md, not the root README. There is also a supplementary guide, running-on-colab.pdf, contributed by Zbynek Bazanowski, which explains how to run the code examples on Google Colab. That is the path of least resistance if you do not want to build a local environment at all, since Colab supplies the runtime. The repository itself is Jupyter Notebook first, so any local route means a Python environment plus Jupyter, with the package versions taken from ch01/README.md rather than assumed. Because the book shipped in 2022 and the last release is v1.1 from 2022-02-25, the pinned versions in that setup file are the thing to check against your current Python before you spend time debugging a notebook that fails on import.
The maintenance model is a frozen snapshot, and that is the main risk
Two releases exist: v1.0 on 2022-01-25 and v1.1 on 2022-02-25. Both landed within a month of each other, years before the last push date of 2026-06-15 shown for the repository. Nothing in the supplied material describes what changed between v1.0 and v1.1, or what the later pushes touched. Practically, you should treat the notebooks as a snapshot of the library versions current when the book was written. PyTorch and scikit-learn have both moved since, and a notebook that constructs a model one way in 2022 may emit deprecation warnings or fail outright on a current release. This is not a defect unique to this repository; it is the nature of code that accompanies a printed book. The failure mode is concrete: you clone, you open ch13 or ch14, and the first cell that imports and instantiates something breaks. The fix is to install the versions ch01/README.md recommends, not to patch the notebooks forward, because patching them detaches the code from the text that explains it.
What the MIT licence does and does not cover here
The repository is MIT licensed, which is permissive and familiar: reuse, modification and redistribution of the code are allowed under the usual terms. What the licence does not do is grant you the book. The prose, the formulae, the figures and the chapter text belong to the publisher and the authors, and the notebooks are the companion material, not a substitute for the purchase. That distinction is worth stating plainly because the README's own warning cuts the same way: code without the explanatory text is incomplete. If you are planning to lift a notebook wholesale into a course or a product, MIT covers the code, and you should read the licence file rather than take this summary as legal advice. If you are planning to redistribute the book's explanations alongside it, that is a different question and not one this repository's licence answers.
The alternative is a maintained library, and the difference is the point
The obvious comparison is scikit-learn itself, or PyTorch's own tutorials. The difference in approach is structural. scikit-learn is a library with a stable API, semantic versioning, release notes and a deprecation policy; you depend on it and upgrade it on a schedule. This repository is teaching material: it shows one author's chosen path through a topic, with the reasoning in the book and the code in the notebook. A scikit-learn tutorial page will be revised when the API changes. These notebooks will not be, because revising them would desynchronise them from a printed page. So the choice is not which is better. It is whether you want something to build on or something to learn from. If you want to build, install scikit-learn and read its documentation. If you want the worked sequence from perceptron to transformer with the derivation attached, this repository is the code half of that, and you need the other half.
Who should clone this, and what to check on the first run
Clone it if you own the book and want the notebooks locally instead of typing them out, or if you are weighing the purchase and want to see whether the code style and chapter coverage suit you. Use the Colab guide if you would rather not manage an environment at all. Do not clone it expecting a library to import, a current PyTorch reference, or code that stands alone without explanation, because the README pre-empts all three. The first thing to open is ch01/README.md, since the root README delegates setup there and nowhere else. The second is the v1.1 release, to see whether the chapters you care about were touched after the initial upload. The third is your Python version against whatever that setup file pins. If the pins no longer resolve on your interpreter, decide then whether to build a separate environment for the book or to read the notebooks without executing them, which is a legitimate way to use a repository like this one.
Editorial conclusion
Adopt the notebooks if you already own Machine Learning with PyTorch and Scikit-Learn and want executable versions of its chapters, or if you are evaluating the book before buying. Skip it if you need a maintained library, a current PyTorch tutorial set, or code you can read standalone: the README states the notebooks may not be useful without the book's formulae and descriptive text. Before cloning, open ch01/README.md, confirm the pinned package versions still install on your Python release, and check the v1.1 release from 2022-02-25 against the chapters you plan to run.
Community notes