Discuss the following questions with your neighbour.
What have you heard about machine learning, or where have you encountered it?
What’s one thing you’re excited or unsure about?
Today’s big questions
What is machine learning, and when is it useful?
How do we represent a prediction problem with features and a target?
How do baselines and decision trees learn and make predictions?
How do we evaluate predictions and control tree complexity?
AI, ML, and DL
Where do AI, ML, and DL fit?
Quick discussion: which of these might use AI, machine learning, or deep learning?
A spam detector 📧
A basic calculator ➕
A chatbot planning your holiday 💬
What are AI, ML, and DL?
Our focus: learning from examples and applying what we learn to new cases.
Image classification
Searching photos for animals involves image classification. Imagine telling cats and foxes apart. How might we do this with traditional programming? With ML?
Image ID
Whiskers Present
Face Shape
Fur Colour
Label
1
Yes
Round
Mixed
Cat
2
Yes
Round
Brown
Cat
3
Yes
Pointed
Red
Fox
4
Yes
Pointed
Red
Fox
5
Yes
Round
Grey
Cat
Who writes the rules?
Traditional programming
We write the rules.
Pointed face + red fur
\(\to\) Predict fox
Machine learning
We provide labeled examples.
Features + cat/fox labels
\(\to\) Learn a prediction rule
What would happen with either approach if we encountered a fox with white fur?
DL approach: example
A neural network automatically learns which features to look at (edges \(\rightarrow\) textures \(\rightarrow\) objects).
No need to even specify face shape or fur colour. It learns relevant features on its own.
Supervised learning: inputs, targets, and predictions
Inputs (\(X\)): observations described by features, such as fur colour and face shape.
Targets (\(y\)): labels or values we want to predict, such as cat or fox.
Training: learn a model \(f\) relating inputs to targets.
Prediction: use the model to predict targets for unseen examples.
When should we use ML?
❓❓ Rules, ML, or human judgment?
Choose a starting point for each problem and explain why. Combinations are possible.
(A) Checking whether an email address ends with @student.ubc.ca
(B) Predicting which songs a listener might enjoy
(C) Awarding a scholarship based on a student’s personal essay
Where could mistakes cause harm, and who should be responsible?
About one in five students in an Ontario study reported seeking emotional support from AI. The association with emotional problems does not establish causation.
What would you want to know before trusting an AI system in either setting?
Formulate a prediction problem
Which job might make you happy?
You’ve graduated and have several job offers. Which one would make you happiest?
Image created by GPT-6 Astra
What job attributes would you record?
What outcome would you predict, and how would you represent it?
Toy job happiness dataset
Supportive
colleagues
Salary ($)
Free
coffee
Boss
vegan
Happy?
0
70,000
0
1
Unhappy
1
60,000
0
0
Unhappy
1
80,000
1
0
Happy
1
110,000
0
1
Happy
1
120,000
1
0
Happy
1
150,000
1
1
Happy
0
150,000
1
0
Unhappy
Each row describes one person in a job. 1 = yes; 0 = no.
Your turn: identify \(X\) and \(y\)
Supportive
colleagues
Salary ($)
Free
coffee
Boss
vegan
Happy?
0
70,000
0
1
Unhappy
1
60,000
0
0
Unhappy
1
80,000
1
0
Happy
First three examples: which columns are inputs, and which is the target?
Features \(X\): the four job attributes Target \(y\):Happy? Example: one row \(n = 7\) examples and \(d = 4\) features
Training vs. Prediction
Training: learn the mapping
Known features \(X\) + known targets \(y\)\(\to\) fitted model \(f\)
Prediction: use the mapping
New features \(X_{\text{new}}\)\(\to\) fitted model \(f\)\(\to\) predictions \(\hat{y}_{\text{new}}\)
We need known targets to train the model, not to make predictions.
Same job features, different targets
Supportive
colleagues
Salary ($)
Free
coffee
Boss
vegan
Happy?
happiness_score
0
70,000
0
1
Unhappy
35
1
60,000
0
0
Unhappy
48
1
80,000
1
0
Happy
85
Happy or unhappy\(\to\) predict a discrete label \(\to\)classification
Happiness score from 0 to 100\(\to\) predict a numerical quantity \(\to\)regression
Other regression examples: predicting temperature, house price, or travel time.
iClicker 1.1: Classification or regression?
Select all regression problems.
A. Predict whether a flight will be delayed.
B. Predict a flight’s delay in minutes
C. Predict a student’s percentage grade in DSCI 571.
D. Predict whether you’ll get a seat on the bus.
E. Predict whether you’ll hit snooze tomorrow morning.
Train, predict, and evaluate models using scikit-learn
Separate the inputs from the target
X = toy_happiness_df.drop(columns=['happy?'])y = toy_happiness_df['happy?']
Object
Contains
Shape
X
Four feature values for each person
(7, 4)
y
One known happiness label per person
(7,)
Keep the answer out of the inputs.
Your turn: predict without the features
If you must predict the same label for everyone, which label should you choose? How many predictions will be correct?
Write preparation notes in the provided box (about 5 minutes). During lab, discuss the question and explain your reasoning in an oral check-in with your TA to earn participation points.