Artificial Intelligence and Machine Learning · Lecture 07 of 16
Introduction to machine learning · Part 1

How does a
machine learn?

Start with examples. Understand the feedback. Choose what to learn.

Learning settings and applications

01 · How learning works

Think about learning with a teacher

Four roles in learning: study material, learner, teacher and assessment.
Examples support practice. Feedback helps us improve. New questions check whether we can use what we learned.
01 · How learning works

Machine learning has four corresponding roles

Study material

Data

Examples and measurements.

Learner

Model

A fixed structure; adjustable settings.

Teacher

Training algorithm

A procedure for improving the settings.

Assessment

Evaluation

Check on examples kept out of training.

Data quality matters. Training updates the model’s adjustable settings (parameters).
01 · How learning works

Can examples help predict the next harvest?

A golden wheat field
Earlier field trials: record fertilizer amount and the harvest size (yield).

Estimate a harvest before measuring it

Input: fertilizer amount for a field.

Output: predicted harvest size (yield).

Past field trials provide examples where both are already known.

Recorded examplesPast examplesFertilizer + measured yield
Adjust model parametersLearn a relationshipFit the model to those examples
Use a fitted model for predictionPredict a new harvestUse the new field’s fertilizer amount
A field trial means growing a crop with a recorded fertilizer amount, then measuring its harvest.
Photos: Max Ronnersjö (CC BY-SA 3.0) · Teaching overlays; full credits.
01 · How learning works

Learning a rule and using it are different steps

Adjust model parameters

Training

Examples
Adjust model
Fitted model

Parameters change as the model learns.

Use a fitted model for prediction

Inference

New input
Fitted model
Prediction

Parameters stay fixed during this prediction.

Training updates parameters; inference applies the fitted model to an input.
01 · How learning works
01 · How learning works

The key question: where does feedback come from?

Supplied answers

Input + reference target

Supervised

The observations

Find patterns without task labels

Unsupervised

Consequences of actions

Act, observe a reward, improve

Reinforcement

The boundaries overlap: some methods combine labels, derive targets or use several learning stages.
02 · Supervised learning

Supervised learning: compare with a known answer

A golden wheat field
Fertilizer level → measured yield
A black Labrador resting on a patterned couch
Animal image → supplied label “dog”
Make a prediction
Compare with the target
Adjust model parametersUpdate the model
Prediction: ŷ = fθ(x).
x = input · y = target · ŷ = prediction · θ = adjustable model parameters.
Ground truth: the reference answer or measurement; it can contain errors.
Photos: Max Ronnersjö (CC BY-SA 3.0) · Melbelle (CC BY-SA 3.0) · Teaching overlays; full credits.
02 · Supervised learning / 2.1 · Regression

Regression predicts a numerical magnitude

A golden wheat field
Input: fertilizer level

Output: estimated yield

An illustrative crop-yield output of 3.2 kilograms on a numerical scale.

A value on a numerical scale, such as yield, temperature or travel time.

Regression predicts a magnitude. Differences between its numerical output values have quantitative meaning.
Photos: Max Ronnersjö (CC BY-SA 3.0) · Teaching overlays; full credits.
02 · Supervised learning / 2.2 · Classification

Classification predicts one of the named categories

A tabby cat walking on snow
Input: an animal image

Output: a class label

{ cat, dog }

Image
Use a fitted model for predictionClassifier
Predicted class
Reveal the recorded label

cat

This supplied answer is the training reference.

Labels are supplied during training. For a new image, the model must predict the label.
Photos: Von.grzanka (CC BY-SA 3.0) · Teaching overlays; full credits.
02 · Supervised learning / 2.3 · Compare the targets

The target’s meaning decides the task

2.1 · Regression

A golden wheat field
A magnitude
yield: 3.2 kg

Differences between values have quantitative meaning.

2.2 · Classification

A black Labrador resting on a patterned couch
A category
species: dog

Codes 0, 1, 2 can name categories too.

Ask what the target means: category codes are labels, not measurements.
Photos: Max Ronnersjö (CC BY-SA 3.0) · Melbelle (CC BY-SA 3.0) · Teaching overlays; full credits.
02 · Supervised learning / 2.4 · The cost of labels

Useful examples need useful labels

A black Labrador resting on a patterned couchlabel: ?
An image is available. Is the right annotation available too?

Labeling can be the bottleneck

Someone may need to identify an object, draw its boundary or measure an outcome.

Many inputs
Fewer reliable targets

Next: what can we learn without these task labels?

Missing or expensive task labels motivate learning from unlabeled observations.
Photos: Melbelle (CC BY-SA 3.0) · Teaching overlays; full credits.
03 · Unsupervised learning

Unsupervised learning: start without task labels

A tabby cat walking on snow
A black Labrador resting on a patterned couch

What can we learn?

Observations
Useful structure

Clustering: group similar observations.

Generative modeling: learn patterns to produce new examples.

Without task labels does not mean without a training objective.
Photos: Von.grzanka (CC BY-SA 3.0) · Melbelle (CC BY-SA 3.0) · Teaching overlays; full credits.
03 · Unsupervised learning / 3.1 · Clustering

Clustering groups similar observations

Two groups of similar points in a schematic representation; no class names were supplied.
Choose features to compare observations. Similarity depends on those features; clusters need not match human categories.
03 · Unsupervised learning / 3.2 · Generative modeling

Generative modeling learns patterns for new samples

Several example house drawings lead to learned patterns and a different new house drawing.
Generate a new sample with learned patterns; assigning a label is a different task.
03 · Unsupervised learning / 3.3 · Self-supervised learning

Self-supervised learning: create a target from the data

A black Labrador resting on a patterned couch?
Training input: visible pixels, with a region hidden.

The original supplies the answer

Hide part of an observation
Predict the hidden part

Compare the prediction with the content you withheld.

Next-token prediction:
“The crop needs” → “water”

Tokens are units of text, such as words or word parts. Self-supervision derives its targets from recorded observations.
Photos: Melbelle (CC BY-SA 3.0) · Teaching overlays; full credits.
03 · Unsupervised learning / 3.3.1 · Construct a target

Build a self-supervised training pair

Choose a sentence and which token to hide. Reveal the target that the original sentence supplies.

03 · Unsupervised learning / 3.3.2 · Pretraining and adaptation

Learn broadly first; adapt to a task next

A tabby cat walking on snow
Unlabeled observations
A black Labrador resting on a patterned couch
Task-specific examples
Adjust model parametersPretrainingLearn reusable patterns
Adjust model parametersFine-tuningContinue training for the task
New taskEvaluate the adapted model
Fine-tuning continues training on the target task; successful transfer still needs evaluation.
Photos: Von.grzanka (CC BY-SA 3.0) · Melbelle (CC BY-SA 3.0) · Teaching overlays; full credits.
04 · Semi-supervised learning

Few labels, many examples: semi-supervised learning

Labeling every photo takes time. Can the unlabeled photos help too?

A tabby cat walking on snow
100 labeled photos: image + species
+
A black Labrador resting on a patterned couch
10,000 unlabeled photos: image only
→
Train togetherUse labels and patterns in both pools
Semi-supervised learning trains on labeled and unlabeled examples for the same task. Unlabeled data helps when its patterns are relevant to the labels.
Photos: Von.grzanka (CC BY-SA 3.0) · Melbelle (CC BY-SA 3.0) · Teaching overlays; full credits.
04 · Semi-supervised learning / 4.1 · Prediction goals

Two goals: label this batch, or label future photos

Start with 100 labeled photos and 10,000 unlabeled photos.

Transductive learning

These 10,000 photos→Labels for this batch

The objective of the learning is to classify the unlabeled data only, without the necessity of generalizing over unseen data.

Inductive learning

Learn a classifier→Label tomorrow’s photos

The objective is to teach the model to label also unobserved data.

Semi-supervised describes the training data. Transductive and inductive describe which cases we want to predict.
04 · Semi-supervised learning / 4.2 · Weak supervision

Weak supervision: learn from imperfect labels

Accurate, detailed labels can be costly. We may have only partial, coarse or unreliable answers.

Incomplete

A black Labrador resting on a patterned couch?

Some examples have no label.

Coarse

A black Labrador resting on a patterned couchdog present

The label does not locate the dog.

Noisy

A black Labrador resting on a patterned couchcat ✕

The supplied label can be wrong.

Weak supervision uses incomplete, coarse or noisy signals. Semi-supervised learning addresses the incomplete-label case by also using unlabeled data.
Photos: Melbelle (CC BY-SA 3.0) · Teaching overlays; full credits.
04 · Semi-supervised learning / 4.3 · Domain shift

The same task can arrive in different-looking data

A black Labrador resting on a patterned couch
Training appearance · website A
A black Labrador resting on a patterned couch
Deployment appearance · website B (simulated)
Changed lighting / compression
Adapt and evaluate on the target domain
Domain shift changes the input distribution. Weak supervision describes label quality.
Photos: Melbelle (CC BY-SA 3.0) · Teaching overlays; full credits.
05 · Reinforcement learning

Reinforcement learning: improve by acting

Chess pieces on a board
A move changes what happens next.

Feedback comes from consequences

Agent sends an action to an environment; the environment returns a next state and reward.

The goal is accumulated reward. A useful reward may arrive several moves later.

Policy = action-selection rule · reward = outcome feedback · state = current situation.
Photos: Shixart1985 (CC BY 2.0) · Teaching overlays; full credits.
05 · Reinforcement learning / 5.1 · Exploration and exploitation

Use what you know—or try what you do not?

A decision branches toward exploiting the current best estimate or exploring an alternative.
ε-greedyExplore with probability ε
Otherwise exploit with probability 1 − ε
ε (epsilon) = exploration probability. An exploratory choice need not give a higher immediate reward.
05 · Reinforcement learning / 5.2 · Bandit setup

What is a bandit arm?

A bandit problem: repeatedly choose an action and observe its uncertain reward.

Three lever machines labeled Arm A, Arm B and Arm C; each gives a reward of 0 or 1.

One round

1. Choose an arm: select action A, B or C.

2. Observe its reward: in our example, 1 or 0.

3. Update its estimate: use what that choice taught you.

An arm is an action; a pull is choosing it once. The name comes from a slot-machine lever.

You see only the chosen arm’s reward. The same arm can give 1 now and 0 next time. The goal is to maximize total reward across many rounds.
05 · Reinforcement learning / 5.3 · Bandit example

Explore or exploit? Try three uncertain actions

Each arm is an action with an unknown reward chance; n counts how many times that arm was pulled.

Learning settings · Compare and apply

Identify the signal, then reveal the reasoning

Choose a scenario and a learning setting. Check your answer to see why it fits.

06 · Application domains

The learning setting and the data domain are different

Computer vision

A black Labrador resting on a patterned couch

Images and video.

Natural language

Thecropgrows.

Text and token sequences.

Multimodal

A tabby cat walking on snow

“A cat walking on snow.”

Combine image and text.

Ask two questions: what kind of data, and what kind of training feedback?
Photos: Von.grzanka (CC BY-SA 3.0) · Melbelle (CC BY-SA 3.0) · Teaching overlays; full credits.
06 · Application domains / 6.1 · Computer vision

One scene, three kinds of visual output

Classification of the same house scene
ClassificationWhich category is present?
Detection of the same house scene
DetectionWhich objects, and where?
Semantic segmentation of the same house scene
Semantic segmentationWhich class at each pixel?
06 · Application domains / 6.2 · Natural language

Context changes both a word’s role and its meaning

Part-of-speech tagging

Theybankthe aircraft.
bank → verb

Word-sense disambiguation

the riverbank
bank → edge of a river
“A late goal decided the final.”
Document topic → sports
Document classification, grammatical tagging and word meaning ask different questions.
06 · Application domains / 6.3 · Multimodal learning

Multimodal learning connects different kinds of data

A tabby cat walking on snow
Image input

Text input

A cat walking on snow.
Image + text
Learn their relationship

Example task: match an image with the appropriate caption.

Image/text and audio/video are data combinations; they do not specify the learning setting.
Photos: Von.grzanka (CC BY-SA 3.0) · Teaching overlays; full credits.
Lecture 07 · Wrap-up

Before you leave this part

  • Distinguish learning from examples from making a prediction.
  • Identify the learning signal in a familiar task.
  • Separate the learning setting from the application domain.

Choose one idea and explain it in your own words. Use an example or an interactive experiment to support your explanation.

Sources & further reading

Continue exploring

Primary course resource

AIML 2025/26 · Lesson 03 — Introduction to Machine Learning

Original examples, terminology and both fertilizer plots.

Teaching notes and source mapping are included in the notes folder.
Use the HTML deck for interactivity. The PDF is a static handout.

Photograph sources, authors and Creative Commons licenses ↗

Continue learning
AIML · Lecture 07 · Introduction to machine learning · Part 1
Course home