Skip to main content
Tokenline

Line 1 · Station 2 of 6

Machine Learning Basics

See how computers learn from labeled examples, and how a trained model makes predictions about things it has never seen.

  • 7 min
  • +50 XP
  • 2 knowledge checks

By the end of this station, you can:

  • Compare writing rules by hand with learning from examples
  • Describe the difference between training a model and using it
  • Explain what labels and features are in supervised learning

Try writing the rules for “cat”

Imagine writing a program that recognizes cats in photos. Pointy ears? Some dogs have those. Whiskers? So do seals. Four legs? So does a table. The list of rules never ends.

Machine learning flips the approach. Instead of writing the rules, you show the computer thousands of photos labeled “cat” or “not cat” and let it find the patterns itself.

Traditional programming compared with machine learningIn traditional programming, people write rules, the program applies them to data, and answers come out. In machine learning, data plus the correct answers (labels) go into training, and what comes out is a model — a set of learned rules.Traditional programmingRules (by people)Data+Program runsAnswersPeople figure out the rulesMachine learningDataAnswers (labels)+TrainingRules (a model)The computer finds the rules
DiagramTraditional programming: rules + data → answers. Machine learning: data + answers (labels) → a model that captures the rules.

Key terms

Model
The result of training: a set of learned patterns (stored as numbers) that turns an input into a prediction.
Training
The process of adjusting a model using example data so its predictions get better.
Inference
Using an already-trained model to make a prediction on new input.
Label
The correct answer attached to a training example, such as “spam” or “not spam.”
Feature
A measurable piece of information the model uses as input, like a song's tempo or an email's number of links.
Supervised learning
Machine learning from examples that come with labels, so the model can compare its guesses to the right answers.

How supervised learning works

  1. Collect examples

    Gather data, like thousands of past emails.

  2. Add labels

    Mark each example with the correct answer: spam or not spam.

  3. Train

    The model guesses, checks its guess against the label, and adjusts to make fewer mistakes.

  4. Test

    Check the model on examples it has never seen to see if it learned real patterns.

  5. Use it (inference)

    The trained model now sorts brand-new emails as they arrive.

Knowledge check 1

+10 XP on first try
A music app wants to predict whether you'll skip a song. Which of these is a label in its training data?

Interactive lab

Train a Classifier

Pick a label, then click the chart (or use the sliders and “Add example”) to add labeled songs. The shaded background shows what the model would predict everywhere.

Energy →

?

Tempo →

Workout example Chill example Mystery song

Label for new examples

Model prediction

The mystery song looks like Chill — 2 of 3 nearest examples agree (unsure).

6 training examples

What to notice: The model never learned a rule like “fast = workout.” It only compares new songs to the labeled examples you gave it — so adding examples, or mislabeling some, changes every prediction nearby.

ExampleTraining vs. inference in real life

You

A photo app is trained on millions of labeled pictures of dogs, cats, food and beaches.

AI assistant (sample)

Later, you snap a picture of your lunch and the app tags it as “food” in a split second.

Why it matters: The slow, expensive part (training) happened once, before you downloaded the app. What happens on your phone is inference — applying what the model already learned.

Learn moreOther kinds of machine learning

Unsupervised learning looks for structure in data that has no labels — for example, grouping shoppers with similar habits without being told what the groups are.

Reinforcement learning learns by trial and error, earning rewards for good outcomes. It's often used to train systems to play games or control robots.

Knowledge check 2

+10 XP on first try
A school trains a model to predict which students need extra math help, using grades from the past five years. Next fall, the model flags a new student. What is happening in the fall?

Key takeaways

  • Machine learning finds patterns in examples instead of relying only on hand-written rules.
  • Features are the inputs; labels are the correct answers the model learns to predict.
  • Training builds the model; inference uses it on new data.
  • Model outputs are predictions that can be wrong.

Sources for this lesson

  • Google for Developers. Machine Learning Crash Course. Full citation
  • University of Helsinki and MinnaLearn. Elements of AI. Full citation

Finish this station

Answer every knowledge check (right or wrong) to unlock completion.

  • Knowledge check 1 — not answered yet
  • Knowledge check 2 — not answered yet

0/2 checks answered