PProtokol
Machine Learning Foundations/What Learning From Data Actually Means
outline — lesson 1 of 10

Level 1 · Complete beginner · 10 min

What Learning From Data Actually Means

Machine learning finds patterns in examples instead of being told exact rules.

What you will learn

  • Explain the difference between rule-based programming and learning from data
  • Describe what a 'model' is in plain terms
  • Recognize the basic ingredients of a machine learning system: data, model, and a way to measure error

The idea

Normal programming means a human writes exact rules: 'if the email contains this word, mark it spam'. Machine learning flips this around. Instead of writing the rules, you show the computer many examples (emails already labeled spam or not-spam), and an algorithm searches for a rule that fits those examples well. The computer is not 'thinking' — it is fitting a mathematical function to data so it can make good guesses on new, unseen examples.

Why does this matter?

Many real problems have rules too complex, too numerous, or too unclear for a human to write down directly — recognizing handwriting, predicting who will click an ad, detecting fraud. When you cannot write the rule but you can collect labeled examples, learning from data becomes the practical path. Understanding this distinction tells you when ML is even the right tool.

A real-world analogy

Imagine teaching a child to recognize dogs. You do not hand them a checklist of exact rules ('four legs, fur, a tail, ears of this shape'). You show them hundreds of pictures labeled 'dog' or 'not dog', and over time they build their own internal sense of what makes something dog-like. A trained ML model works the same way: it builds an internal, numeric 'sense' from examples, rather than following a rule list.

See it in code

A rule-based approach vs a data-fit approach
// Rule-based: a human decides the exact cutoff
function isTallRuleBased(heightCm) {
  return heightCm > 180;
}

// Data-driven: the cutoff comes from examples, not a guess
const examples = [
  { height: 165, tall: false },
  { height: 190, tall: true },
  { height: 178, tall: false },
  { height: 185, tall: true }
];

function learnThreshold(data) {
  const tallHeights = data.filter(d => d.tall).map(d => d.height);
  const shortHeights = data.filter(d => !d.tall).map(d => d.height);
  const minTall = Math.min(...tallHeights);
  const maxShort = Math.max(...shortHeights);
  return (minTall + maxShort) / 2; // a simple learned midpoint
}

console.log(learnThreshold(examples)); // a threshold discovered from the data, not chosen by hand

Line by line

  • function isTallRuleBased(heightCm) { return heightCm > 180; }

    The number 180 was picked by a human. It never changes no matter what real people look like.

  • const examples = [ ... ]

    Labeled data: each example has an input (height) and the correct answer (tall or not). This is exactly the shape of data ML training uses.

  • function learnThreshold(data) { ... }

    Instead of a human choosing the cutoff, this function derives it from the examples themselves — a tiny, honest example of 'fitting a model to data'.

  • console.log(learnThreshold(examples));

    The output is a number discovered by looking at the data, which is the core idea behind every ML model, just wildly simplified here.

What do you think happens?

You have thousands of photos labeled 'cat' or 'not cat' but no way to describe exact pixel rules for 'catness'. What approach fits best?

Have a guess before you read on. Guessing wrong is part of learning it.

Try it yourself

Modify the examples array below: add a person with height 172 who is NOT tall, and one with height 176 who IS tall (borderline data), then rerun learnThreshold. Notice how the learned threshold shifts as the data changes — this is the essence of 'learning'.

Worth knowing

Common mistake: thinking a trained model 'understands' the concept the way a person does. It only captures statistical patterns present in the data you gave it. If your data is biased, incomplete, or mislabeled, the model will faithfully learn those flaws too.

The proper words for it

Machine learning
Building a model by fitting it to example data, instead of hand-writing rules.
Model
The mathematical object (a function with adjustable numbers) that turns an input into a prediction.
Training data
The labeled examples used to fit the model.

Where you'll meet this

Spam filters, product recommendations, credit scoring, and voice assistants are all built this way: engineers gather labeled examples, train a model, and deploy it to make predictions on new data it has never seen.

Lesson recap

  • Machine learning fits a model to example data instead of relying on hand-written rules
  • A model is a function with adjustable numbers, tuned to match the data
  • The quality of a model is entirely dependent on the quality of the data it learned from

Still fuzzy on any of this?

That's normal, and it's not a dead end. Pick a different way to hear it.

Quick check

1. What is the key difference between rule-based programming and machine learning?

2. Why might a trained model reproduce biases present in its training data?

3. Which of these best describes a 'model' in machine learning?

First, pass the quick check to unlock "Features and Labels: The Raw Material of ML".

Your tutor

patient by design

No question is too basic here. Ask anything — I'll explain it in plain words and guide you rather than handing over answers.