toolrota

What is machine learning and how does it work? Supervised, unsupervised and reinforcement learning, with examples

Machine learning is computers learning from examples without rules being written by hand. We explain the main types, the training process, common mistakes and ways to start in plain language.

Serkan Akyürek··6 min read
What is machine learning and how does it work? Supervised, unsupervised and reinforcement learning, with examples – AI

The spam filter in your email, the series recommended to you, credit-card fraud alerts… The rules of these systems weren't written one by one; they learned from examples. This is called machine learning (ML) and it is the most common route to AI. In this guide you learn what machine learning is, how it works, its main types, how a model is trained and the common traps.

What is machine learning?

In traditional programming a person writes the rules and the computer applies them. In machine learning a person gives examples and the computer learns the rules (the model) itself.

Example: solving "is this email spam?" with rules is hard (which words? which patterns?). In machine learning you show the model hundreds of thousands of spam and normal emails; the model learns for itself which features point to spam (see our what is AI guide).

Basic concepts

ConceptMeaning
DatasetThe examples used in training
FeatureAn input used for prediction (such as word count, amount)
LabelThe right answer (such as "spam"/"normal")
ModelA mathematical representation of learned patterns
TrainingThe process of the model learning from data
TestMeasuring the model's success on new data
PredictionThe trained model's output for a new input

Types of machine learning

1. Supervised learning

The data is labelled. The model learns the relationship between the input and the correct output.

  • Classification: predicting a category (spam/not, ill/healthy, which product category).
  • Regression: a numeric prediction (house price, sales quantity).

Examples: predicting loan approval, recognising objects in images, sales forecasting (see our Excel forecast and trend guide).

2. Unsupervised learning

The data is unlabelled. The model discovers the structure itself.

  • Clustering: grouping similar customers.
  • Dimensionality reduction: simplifying data.
  • Anomaly detection: finding unusual transactions.

3. Reinforcement learning

An agent takes actions in an environment, receives rewards or penalties and over time learns the best strategy. It is used in game-playing systems, robotics and some control problems.

4. Deep learning

Learning done with multi-layer artificial neural networks; very successful in images, sound and language. Chatbots and image generators rest on it (see our generative AI guide).

The steps of an ML project
  1. 1

    Define the problem and the success measure

  2. 2

    Collect and clean data

  3. 3

    Prepare the features

  4. 4

    Split the data into training and test

  5. 5

    Train and evaluate the model

  6. 6

    Put it into use, monitor and update

Training and test data

To tell whether the model really learned you split the data:

  • Training set (e.g. 70–80%): the examples the model learns from.
  • Validation/test set (20–30%): examples the model hasn't seen before.

If the model is good on the test too, it can generalise. A model that succeeds only on the training data is useless.

Overfitting and underfitting

SituationSignCauseFix
OverfittingVery good in training, bad in testThe model memorised the dataMore data, simplification, regularisation
UnderfittingBad everywhereThe model is too simple or data insufficientA stronger model, better features

Data quality: the most critical point

"Garbage in, garbage out." Data problems:

  • Missing and wrong data: must be cleaned (see our Excel data cleaning guide).
  • Biased data: data that under-represents some groups can make the model unfair.
  • Label errors.
  • Leakage: using information in training that couldn't be known at prediction time.
  • Data drift: the real world changes over time; the model can go stale.

When working with personal data learn the privacy and legal requirements.

How is success measured?

MeasureWhat it shows
AccuracyThe share of correct predictions (can mislead on imbalanced data)
Precision / RecallThe balance of false alarms and misses
Mean errorIn regression, the gap between prediction and reality

Example: when detecting a very rare disease a model that says "everyone is healthy" can be 99% accurate but is useless. Choosing the right measure matters.

Everyday examples

  • Email: spam/important classification.
  • Shopping: product recommendations, price prediction.
  • Banking: fraud detection, credit risk.
  • Health: support in image analysis.
  • Transport: demand and duration prediction.
  • Business: churn prediction, stock forecasting (see our CRM guide).
  • Phone: face recognition, keyboard suggestions.

A roadmap to start

  1. Learn the concepts: data, feature, model, training, test.
  2. Basic data skills: Excel/spreadsheets, data cleaning, reading charts (see our Excel guides).
  3. Python and basic libraries: data handling and ML libraries.
  4. Start with a small project: for example house price prediction or customer classification.
  5. Practise with ready datasets.
  6. Understand evaluation and errors.
  7. Try no-code tools too: some platforms let you train a model without code (see our no-code tools guide).

Common mistakes

  1. Jumping to the model without examining the data.
  2. Using test data in training.
  3. Looking only at accuracy.
  4. Choosing a complex model; a simple model is often enough.
  5. Ignoring bias.
  6. Training the model once and forgetting it.
  7. Mistaking correlation for causation: a model finds relationships, it doesn't prove cause and effect.

Frequently asked questions

Is maths a must for machine learning? Not for the basic concepts; statistics and linear algebra help to go deeper.

What is the difference between machine learning and deep learning? Deep learning is a sub-branch of machine learning done with multi-layer neural networks.

Is a lot of data needed? It depends on the problem; for simple problems little data can do, deep models want a lot.

Can machine learning be done in Excel? Simple predictions (trend, regression) can; advanced models need special tools.

Who is responsible if the model errs? The organisations and people using it; human oversight is essential in critical decisions.

Summary

Machine learning is the way to build systems that learn from examples and predict. It has supervised, unsupervised and reinforcement types; success depends largely on data quality and proper evaluation. Avoid overfitting, keep the test separate and start learning with a small project.

Share
Published:
Author
Serkan Akyürek

Serkan Akyürek is the founder and author of toolrota; he writes step-by-step guides on Excel, AI, the cloud, personal finance and digital security.

Related guides

AI
AI7 min read

AI for teachers: a guide to productive and responsible use in lesson plans, writing questions and feedback

AI can save teachers time in planning and preparation, but judgement and responsibility stay with the teacher. We explain uses, prompt examples and ethical principles.

AI6 min read

What is generative AI and how does it work? Examples, uses, limits and risks

Generative AI is the general name for systems that can produce text, images, audio and code. We explain how it works, where it helps and what to watch for in plain language.

AI6 min read

ChatGPT alternatives: which AI chat tool should you choose for what? A comparison and selection guide

There is no single best AI tool; it varies with the type of work, privacy needs and budget. We explain the alternatives and how to run your own test.

AI7 min read

Running AI on your own computer: a step-by-step guide to local models with Ollama and LM Studio

Local AI runs without your data leaving your computer and needs no internet. We explain hardware needs, setup, model choice and limits.

AI7 min read

Writing product descriptions with AI: prompts, templates and a quality-control guide for e-commerce

AI speeds up product descriptions, but uncontrolled use produces wrong and samey copy. Prompt templates, a workflow and a quality-control checklist.

Security & Web7 min read

What is social engineering? Attack types, real examples and ways to protect yourself

Attackers often target the person, not the system. We explain social engineering methods, the psychological triggers they use and effective defence steps.