Artificial Intelligence Tutorials: Machine Learning in Python

These tutorials teach machine learning and artificial intelligence algorithms the way MYCPLUS teaches sorting and data structures: the idea first, then the math, then code you can run. Each algorithm is implemented from scratch in Python, checked against a standard library such as scikit-learn or PyTorch, and tested on a real dataset. The code and tests are in the MYCPLUS Python examples repository on GitHub, and how we test machine learning code explains the seeds, splits and baselines behind every result.

Start here: What Is Machine Learning? explains supervised, unsupervised and reinforcement learning and trains a first model end to end. New to Python for data work? Set up first with Python for machine learning, then NumPy and pandas.

Supervised learning, in reading order

  1. Linear regression: least squares, the closed-form solution and gradient descent.
  2. Logistic regression: the sigmoid, log loss and how the decision threshold trades precision for recall.
  3. K-nearest neighbors: distance metrics, feature scaling and choosing k, with a C++ distance kernel.
  4. Decision trees: entropy, information gain and Gini impurity on the same split.

Unsupervised learning

Search and game-playing algorithms

Minimax and alpha-beta pruning and other search algorithms are in the algorithms section, with code in C, C++, Java and Python. For running trained models from C++, see machine learning with C++.

Scroll to Top