Guide · Open source
How to use python-machine-learning-book: clone, open notebooks, follow chapters
Updated · written with AI from the project's own documentation and checked against our catalogue data
python-machine-learning-book is the MIT-licensed code repository for the 1st edition of Python Machine Learning, a 2015 Packt book by Sebastian Raschka. It holds Jupyter notebooks for each chapter, written mainly with NumPy, scikit-learn, and Theano. This guide shows you how to get the repository, find the chapter notebooks, and decide whether it fits your learning.
Quick start
- 1Confirm the edition. Check that you own the 1st Edition. If you have the 2nd Edition, use its separate repository instead.
- 2Clone the repository. Run git clone https://github.com/rasbt/python-machine-learning-book.git in your terminal.
- 3Install Python and Jupyter. Set up Python and Jupyter Notebook, following the instructions at code/ch01/README.md.
- 4Start Jupyter. Launch Jupyter Notebook from the cloned folder so you can browse the chapter notebooks.
- 5Open the chapter you are reading. Open the matching notebook, such as code/ch01/ch01.ipynb for Chapter 1.
- 6Read the text alongside the code. Use the book's formulae and explanations with the notebook, since the notebooks alone may not be enough.
What is python-machine-learning-book?
This repository contains the code examples of the 1st Edition of the Python Machine Learning book. The author aims to explain machine learning concepts and best practices, then put them into action mainly with NumPy, scikit-learn, and Theano.
The README is clear that these notebooks are meant to be used alongside the book's formulae and descriptive text, and may not be useful without them.
- Chapters 1 to 13, each with a notebook (ch01.ipynb through ch13.ipynb)
- An equation reference available as PDF and TEX
- Links to slides for teaching, and math and NumPy primers
Check that this is the edition you need
The README includes a note that this repository is for the 1st Edition. If you are looking for the 2nd Edition code, the README points to a separate repository, python-machine-learning-book-2nd-edition.
Check the edition on your copy before you start, because the code and text are tied to the book's chapters.
Clone the repository
The README gives one install command: clone the repository with git. The source does not list further installation steps for the repository itself.
git clone https://github.com/rasbt/python-machine-learning-book.gitSet up Python and Jupyter Notebook
You need Python and Jupyter Notebook to run the notebooks. The README excerpt does not specify a Python version, so check the setup instructions linked from the repository before you install anything.
The repository links to a setup guide at code/ch01/README.md, titled Instructions for setting up Python and the Jupiter Notebook.
- Prerequisites: Python and Jupyter Notebook
- Setup instructions: code/ch01/README.md inside the cloned repository
Open a chapter notebook
Each chapter has its own folder and notebook. Pick the chapter you are reading in the book and open its .ipynb file in Jupyter. If you do not want to install anything, the README also links each chapter to an NbViewer version, which renders the notebook in a browser.
The README notes that internal document links only work in the NbViewer version.
- Chapter folder example: code/ch02 with notebook code/ch02/ch02.ipynb
- NbViewer link: provided next to each chapter headline
Use it alongside the book
Read the chapter text and formulae first, then run the matching notebook. The chapter list covers classification, data pre-processing, dimensionality reduction, model evaluation, ensemble learning, sentiment analysis, regression, clustering, neural networks, and parallelizing neural network training via Theano.
Because the notebooks come from 2015 and use Theano, expect to adapt them if you need current library versions.
What people use it for
- Running the chapter 1 to 13 code examples while reading the 1st edition
- Studying how classifiers from scikit-learn are compared in Chapter 3
- Reviewing the equation reference when working through the math
- Using the slides and chapter notebooks as material for an introductory machine learning course
Frequently asked questions
How do I install python-machine-learning-book?
Clone the repository with git clone https://github.com/rasbt/python-machine-learning-book.git. You also need Python and Jupyter Notebook, and the README points to code/ch01/README.md for setup instructions.
What do I need to run the notebooks?
You need Python and Jupyter Notebook. The README excerpt does not specify a Python version, so follow the setup guide in code/ch01/README.md.
Is python-machine-learning-book free?
The repository is released under the MIT licence, as listed on its GitHub page. The book itself is sold separately; the README links to Amazon listings.
Can I use this code without buying the book?
The README says the notebooks may not be useful without the formulae and descriptive text. You can view them through the NbViewer links, but the explanations come from the book.
Does this work with the 2nd edition of Python Machine Learning?
No. The README states this repository is for the 1st Edition and directs readers to a separate repository for the 2nd Edition code.
What are the alternatives?
The README lists the Python Machine Learning 2nd Edition code repository, scikit-learn, and the code repository for Hands-On Machine Learning with Scikit-Learn and TensorFlow as comparable projects.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Choose python-machine-learning-book if you own the 1st edition and want to run its code alongside the explanations, or if you are a beginner or instructor who wants chapter-by-chapter examples. Pick the 2nd edition repository for current material, or scikit-learn and other resources if you want standalone, up-to-date library code without the 2015 context.
Install options & downloads