Algorithms in detail
How each popular machine learning algorithm really works: step by step, with a diagram, a worked example, real-world uses, and what it's good and bad at.
Choosing an algorithm
Start with the question you need answered, then narrow it down.
- How to choose an algorithm: Before picking an algorithm, ask one question: what kind of answer do I need?
- A decision map for choosing an algorithm: Two questions narrow down the choice quickly.
- Machine learning algorithms cheat sheet: 17 side by side: This page puts the most common machine learning algorithms side by side: what type of learning they use, what they are best at, what to watch out for, and a real example.
Predicting numbers and categories
Supervised algorithms, from straight lines to forests of trees.
- Linear regression: Supervised · Regression Linear regression predicts a number by finding the straight line that best fits past data.
- Logistic regression: Supervised · Classification Despite its name, logistic regression is used to answer yes/no questions.
- Decision tree: Supervised · Classification & regression A decision tree makes a prediction by asking a series of yes/no questions, like a flowchart.
- Random forest: Supervised · Classification & regression A random forest builds hundreds of decision trees, each trained on a slightly different random sample of the data and features.
- Gradient boosting (XGBoost, LightGBM): Supervised · Classification & regression Gradient boosting also uses many small decision trees, but builds them one after another.
- K-nearest neighbours (KNN): Supervised · Classification & regression KNN predicts by finding the K most similar past examples (the nearest neighbours) and going with their majority answer, or their average for numbers.
- Naive Bayes: Supervised · Classification Naive Bayes uses probability.
- Support vector machine (SVM): Supervised · Classification An SVM finds the boundary that separates two groups with the widest possible margin, the biggest empty gap on both sides.
Finding groups and recommending
Unsupervised clustering, shrinking big tables into simple pictures, and how recommendations work.
- K-means clustering: Unsupervised · Clustering K-means groups data into K clusters without any labels.
- Dimensionality reduction: PCA, t-SNE, UMAP and LDA: Real data often has dozens or thousands of columns (called dimensions or features).
- How recommendation systems work: Recommendation systems decide what to show you next: films, products, videos, songs.
Rewards and neural networks
Learning by trial and reward, and neural networks as an algorithm.
- Q-learning: Reinforcement learning Q-learning is a reinforcement learning algorithm.
- Neural networks as a machine learning algorithm: Supervised, unsupervised & reinforcement A neural network is a flexible algorithm made of layers of connected neurons.
Measuring success and going live
How to know if an algorithm is good, and the full journey from data to a model in production.
- How do we know an algorithm is good?: After training, a model is tested on data it has never seen.
- From data to deployment: the end-to-end ML workflow: Building a machine learning model is only one part of the job.