Home / Learn / Data & AI / ML foundations / Lesson 1.1
All lessons

Module 1: Data, models and the maths you need · Lesson 1.1 · about 15 min

What data analytics and machine learning are

Data analytics describes what happened; machine learning finds a rule from examples so it can predict what has not happened yet. See the difference, and let a machine learn its first rule.

Key points, meanings and formulas on one page: choose "Save as PDF" in the print box.

Module 1 · about 15 minutes · no maths needed yet. You’ll be able to say what data analytics and machine learning are, how they differ from normal programming, and what “training a model” means.

Machine learning means showing a computer many examples with their answers, and letting it find the rule by itself.

1. Why this matters

Every day, programs decide which email is spam, which song plays next, what a house might sell for and which words a chatbot writes. Nobody wrote most of these rules by hand. The programs learned them from examples.

Think of how a child learns what a dog is. Nobody gives the child a rule book (“four legs, fur, barks”). The child sees many dogs, hears “dog” each time, and slowly works out the pattern. Machine learning does the same thing with numbers.

This course takes you from the simplest learner (a straight line) to the largest (the language models behind chat assistants), one small step at a time.

2. Three kinds of work with data

People mix up “data analytics”, “data science” and “machine learning”. The easiest way to keep them apart is to ask which question each one answers:

Kind The question Example
Descriptive analytics What happened? A dashboard of last month’s sales by store.
Diagnostic analytics Why did it happen? Sales fell in stores where a competitor opened.
Predictive (machine learning) What will happen, or what is this new thing? Next week’s sales; is this email spam?

The first two look backwards. They use summaries, charts and careful comparisons (Module 2). The third looks forwards. It needs a model: a rule that turns inputs (what you know) into a prediction (what you want to know). Machine learning is the craft of finding that rule from data.

3. Rules written by people, or rules found by the machine

Picture: two ways to get answers from a computer Left, normal programming: a person writes the rules, the computer applies them to data and gives answers. Right, machine learning: the computer is given data and the right answers, and it finds the rule itself. That found rule, the model, then answers new data. Normal programming Rules you write Data Computer Answerspass / fail Machine learning Data Right answers Computer A rule it found= the model a person knows the rule new data → model → answer fibub.com
In normal programming a person writes the rule. In machine learning the computer is shown many examples with the right answers and finds a rule that fits them. That found rule is called the model, and it is then used on new data it has never seen.

In normal programming, a person writes the rule: “if the mark is 40 or more, print pass”. That works when the rule is simple and known. It breaks when nobody can write the rule down. Try writing exact rules for “is this photo a cat?” or “will this customer cancel?” and you’ll soon give up.

Machine learning turns this round. You give the computer many examples together with the right answers: photos labelled cat or not cat, past customers marked “cancelled” or “stayed”. The computer searches for a rule that gets those examples right. The rule it finds is the model. Then you use the model on new cases whose answers you don’t know yet.

“A model that has learned is always right.” No. A model is a summary of past examples, and real life is noisy. Even the best rule in the simulation below gets some students wrong, because hours of study don’t decide everything. A good model is right more often than a simple guess, and you measure how often on cases it has never seen (Lesson 2.5).

4. The smallest possible learning machine

Here are 24 students. For each one, we know how many hours they studied and whether they passed. We want a rule of the form “pass if hours ≥ some cut-off”. Move the slider to try cut-offs yourself, then let the machine do it.

Try it: find the rule from examples

Each mark is a student: circles passed, squares failed. A rule "pass if hours ≥ cut-off" gets some students wrong (shown with a cross). The machine does what you just did, but tries every possible cut-off and keeps the one with the fewest mistakes. That search is training, and the cut-off it keeps is the model. Made-up data.

What the machine did is exactly what “training” means for every model in this course:

  1. Choose a family of rules. Here: “pass if hours ≥ c”, for any number c.
  2. Measure how wrong a rule is on the known examples. Here: count the mistakes.
  3. Search for the setting with the smallest error. Here: try every c in steps of 0.25.

Watch the same three steps with just eight students:

The examples. Eight students studied 1 to 8 hours. P means passed, F means failed. Mostly, more hours means a pass, but student 3 passed with little study and student 5 failed with a lot.
Try c = 2. The rule says everyone with 2 or more hours passes. It is wrong about students 2, 4 and 5, who failed. That is 3 mistakes.
Try c = 4. Now students 1 to 3 are predicted to fail. Student 3 actually passed, and 4 and 5 still failed. Still 3 mistakes.
Try c = 6. Students 1 to 5 are predicted to fail, 6 to 8 to pass. Only student 3 is wrong: 1 mistake.
Keep the best. No other cut-off does better, so training keeps c = 6. Student 3 is still wrong. That is noise, not a bug: no single cut-off can fix it.

The number c is called a parameter: a setting the machine learns. A straight line has 2 parameters, a decision tree a few dozen, and a large language model billions. The three steps stay the same. Only the family of rules and the cleverness of the search change.

Maths and principle

Principle: a model is a function with adjustable parameters. Training picks the parameters that make the error on known examples as small as possible.

Equation: for the cut-off model, the prediction for a student who studied h hours is

yˆ={passif h≥cfailif h<c

and training finds

c∗=arg⁡minc⁡∑i=1n[yˆi(c)≠yi]

Read it as: “c-star is the value of c that makes the count of wrong predictions smallest”. The hat on yˆ means “predicted”; yi is the true answer for student i; the square brackets count 1 when the statement inside is true and 0 when false; ∑ adds those up over all n students.

Analogy: tuning a radio. The dial is the parameter, the static is the error, and you turn the dial until the static is least.

Try it: 5 students studied 1, 3, 4, 6 and 8 hours. Only the last two passed. How many mistakes does c = 5 make? (None: 6 and 8 are at least 5 and passed; the rest are below 5 and failed.)

Model
A rule that turns what you know (hours studied) into a guess about what you want to know (pass or fail).
Parameter (c)
A dial inside the model that training turns. Here, the cut-off number of hours.
Error
How often, or how badly, the model is wrong on examples whose answers you already know.
Training
Turning the dials until the error is as small as possible.
Physical meaning
The model is a compressed memory of experience. A tutor who has seen hundreds of students can guess who will pass; the machine does the same with a written-down rule, and it never gets tired or forgets an example.

5. Worked example

Made-up numbers. A small shop wants to know which online orders will be returned. Writing rules by hand (“if size is XL and colour is beige…”) quickly gets out of control. Instead it takes 2,000 past orders, each with columns such as price, category, delivery days and whether the customer had returned something before, plus the answer: returned or not. A model trained on 1,500 of them is checked on the other 500 it never saw, and gets 82 % right, against 70 % for the simple guess “nothing is ever returned”. That 12-point gain is what the model is worth. The shop then uses it to add a sizing tip to the risky orders. Every step of that story (choosing columns, splitting off 500 rows, comparing with a simple guess) is a lesson in this course.

6. Practice

  1. Is each one descriptive analytics or machine learning? (a) Average delivery time per city last year. (b) Estimating the delivery time of an order placed now.
  2. In the simulation, what is the parameter, and what is the error being made small?
  3. Why can’t the best cut-off get every student right?
Answers
  1. (a) Descriptive: it summarises the past. (b) Machine learning: it predicts an unknown from patterns in past orders.
  2. The parameter is the cut-off c. The error is the number of students predicted wrongly.
  3. Because some students who studied little passed and some who studied a lot failed. Hours alone don’t decide the result, so no single cut-off separates them perfectly.

New words: model (a rule found from data that turns inputs into a prediction), training (searching for the parameter values with the least error), parameter (a setting the machine learns), prediction (the model’s output, written yˆ).

Next: the words used for every dataset: features, labels and examples.

  • Analytics describes the past; machine learning predicts what is not yet known.
  • In machine learning you give examples with answers, and the computer finds the rule (the model).
  • Training has three steps: choose a family of rules, measure the error, search for the settings with the least error.
  • A parameter is a dial the machine sets; big models have billions of them, but the idea is the same.
  • Real data is noisy, so even the best model makes some mistakes.

Check yourself

1In machine learning, what does the computer get, and what does it produce?
2Which of these is descriptive analytics rather than machine learning?
3What is "training" in the cut-off simulation?

Sources

  • Mitchell, T. M. (1997), Machine Learning, McGraw-Hill, Chapter 1 (the "learning from experience" definition)
  • James, G., Witten, D., Hastie, T., Tibshirani, R. and Taylor, J. (2023), An Introduction to Statistical Learning with Applications in Python, Springer, Chapter 2 https://www.statlearning.com/
  • Goodfellow, I., Bengio, Y. and Courville, A. (2016), Deep Learning, MIT Press, Chapter 5 (machine learning basics) https://www.deeplearningbook.org/

Your ticks stay in this browser. Save them as a file on the course home.

Updated 2026-11-22. Numbers in the examples are made up to show the idea unless a source is given. Simulations run in your browser; nothing you type is sent anywhere.