Machine learning algorithms

An algorithm is a step-by-step recipe. In machine learning, the algorithm is the method a computer uses to learn patterns from data. Different problems need different algorithms, just like different dishes need different recipes.

Everyday analogy

A kitchen has a knife, a mixer, a pressure cooker and an oven. Each is best for a certain job. Data scientists pick the algorithm that suits the problem in the same way.

Example

Predicting a number (a house price) needs a different algorithm from answering yes/no (will this customer leave?) or grouping things (which customers are alike?).

📈Predict anumbere.g. next month'ssales🏷️Pick acategorye.g. spam or notspam🫧Find groupse.g. customersegments🎮Learn byrewarde.g. a game-playingAI
Four kinds of problems, four families of algorithms.

Common algorithms, in plain words

Linear regression

Supervised

Predicts a number by drawing the best straight line through past data.

e.g. flat price from its size in sq. ft.

Logistic regression

Supervised

Predicts the chance of a yes/no outcome.

e.g. will this customer cancel their subscription?

Decision tree

Supervised

Asks a series of yes/no questions, like a flowchart, to reach an answer.

e.g. loan approval (see the diagram below)

Random forest

Supervised

Builds many decision trees and lets them vote. More reliable than one tree.

e.g. spotting fraudulent card payments

Gradient boosting (e.g. XGBoost)

Supervised

Builds trees one after another, each fixing the mistakes of the last.

e.g. credit scoring, sales forecasting

K-nearest neighbours (KNN)

Supervised

Looks at the most similar past examples and copies their answer.

e.g. "customers like you also bought…"

Naive Bayes

Supervised

Uses probability: how often certain words or signs appear with each answer.

e.g. classic email spam filters

Support vector machine (SVM)

Supervised

Finds the widest gap that separates two groups.

e.g. telling handwritten digits apart

K-means clustering

Unsupervised

Puts data into K groups of similar items, with no answers given.

e.g. customer segments for marketing

Q-learning

Reinforcement

Learns the best action in each situation from rewards.

e.g. an AI learning to play a game

Neural networks

All types

Layers of connected "neurons" that learn very complex patterns. The engine of deep learning.

e.g. face recognition, ChatGPT (see the next lesson)

Want to know how each of these really works, with diagrams and worked examples? Read every algorithm in detail →

Try it yourself

About 10 min

Match the problem to the algorithm type

  1. Write 5 questions from work or life, e.g. How many units will we sell? or Is this email spam?
  2. Label each one: predict a number, choose a category, find groups, or learn by reward.
  3. Ask an AI chatbot to check your labels and explain any you got wrong.

What you should see: Most real questions fall into just four kinds of problem.

Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.

Build it for real · guided projectYour first machine learning model: predict house pricesAbout 75 min · Copy-paste code · step by step
Test what you learned

Take a quick quiz, or look up any word in the glossary.