Professional Documents
Culture Documents
Lecture 02
Lecture 02
Lecture 2
Ali Raza
Topics
• Machine Learning:
– Definition
– Important Tasks
• Neural Network Basis:
– Perceptron
– Binary Classification with Perceptron
– Training Perceptron
What is Machine Learning ?
• Field of study that gives
computer the ability to learn
without being explicitly
programmed (Arthur Samuel,
1956)
• Study of algorithms that improve
their performance P at some task
T: Play checkers
T with experience E (Tom P: % of games won
Mitchell, 1998) E: Playing against self
Weights of
positive class: 1.0 1.2 1.7 -1.0 -2.1 -1.3 … … …
Parameters / weights
Sentiment Classification with
Perceptron
Test example: “Mubeen was great, the food was
awesome. But the service was terrible”
ₓ ₊ ₓ ₊ ₓ ₊ ₓ ₊ ₓ ₊ ₓ ₌
Weights of
positive class: 1.0 1.2 1.7 -1.0 -2.1 -1.3 … … …
0
Awfl
…
Fast Sentiment Classification with
Perceptron
1
Good
Test example: “Mubeen was great, the food was
awesome. But the service was terrible” 0
Great
x:
1
Asm
0
Bad
W: 1.0 1.2 1.7 -1.0 -2.1 -1.3 … … …
1 Trbl
0
Awfl
𝑓 𝑥, 𝑊 = 𝑊𝑥
…
…
Fast Sentiment Classification with
Perceptron
1
Good
Test example: “Mubeen was great, the food was
awesome. But the service was terrible” 0
Great
x:
1
Asm
0
Bad
W: 1.0 1.2 1.7 -1.0 -2.1 -1.3 … … …
1 Trbl
0
Awfl
𝑓 𝑥, 𝑊 = 𝑊𝑥 + 𝑏
…
Bias …
Image Classification with Perceptron
𝑓 𝑥, 𝑊 = 𝑊𝑥 + 𝑏
Image Classification with Perceptron
<0
Not Cate
Image Classification with Perceptron
<0
Not Cate
What to do?
Image Classification with Perceptron
<0
Not Cate
<0
Not Cate
<0
Not Cate
<0
Not Cate
ො 2
𝐿 𝑊, 𝑏 = (𝑦 − 𝑦)
𝑖=1
Training a Perceptron
• Learning algorithm:
– Initialize weights randomly
– Take one sample 𝑥𝑖 and predict 𝑦𝑖
– For wrong predictions, update weights
• If the output was 𝑦ො𝑖 = 0 𝑎𝑛𝑑 𝑦𝑖 = 1, increase weights
• If the output was 𝑦ො𝑖 = 1 𝑎𝑛𝑑 𝑦𝑖 = 0, decrease weights
– Repeat until no errors are made Predicted
Actual
class
𝑚 class
What is Cost function?
ො 2
𝐿 𝑊, 𝑏 = (𝑦 − 𝑦)
𝑖=1