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?).
Common algorithms, in plain words
Linear regression
SupervisedPredicts a number by drawing the best straight line through past data.
e.g. flat price from its size in sq. ft.
Logistic regression
SupervisedPredicts the chance of a yes/no outcome.
e.g. will this customer cancel their subscription?
Decision tree
SupervisedAsks a series of yes/no questions, like a flowchart, to reach an answer.
e.g. loan approval (see the diagram below)
Random forest
SupervisedBuilds many decision trees and lets them vote. More reliable than one tree.
e.g. spotting fraudulent card payments
Gradient boosting (e.g. XGBoost)
SupervisedBuilds trees one after another, each fixing the mistakes of the last.
e.g. credit scoring, sales forecasting
K-nearest neighbours (KNN)
SupervisedLooks at the most similar past examples and copies their answer.
e.g. "customers like you also bought…"
Naive Bayes
SupervisedUses probability: how often certain words or signs appear with each answer.
e.g. classic email spam filters
Support vector machine (SVM)
SupervisedFinds the widest gap that separates two groups.
e.g. telling handwritten digits apart
K-means clustering
UnsupervisedPuts data into K groups of similar items, with no answers given.
e.g. customer segments for marketing
Q-learning
ReinforcementLearns the best action in each situation from rewards.
e.g. an AI learning to play a game
Neural networks
All typesLayers 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 minMatch the problem to the algorithm type
- Write 5 questions from work or life, e.g. How many units will we sell? or Is this email spam?
- Label each one: predict a number, choose a category, find groups, or learn by reward.
- 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.