Uploaded by yeoh Kar Man

# Lec 1

advertisement
```EE2211 Introduction to
Machine Learning
Lecture 1
Wang Xinchao
xinchao@nus.edu.sg
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
Course Contents
• Introduction and Preliminaries (Xinchao)
– Introduction
– Data Engineering
– Introduction to Probability and Statistics
• Fundamental Machine Learning Algorithms I (Helen)
– Systems of linear equations
– Least squares, Linear regression
– Ridge regression, Polynomial regression
• Fundamental Machine Learning Algorithms II (Thomas)
– Over-fitting, bias/variance trade-off
– Optimization, Gradient descent
– Decision Trees, Random Forest
• Performance and More Algorithms (Xinchao)
– Performance Issues
– K-means Clustering
– Neural Networks
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
2
World’s Largest Selfie
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
3
World’s Largest Selfie
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
4
Outline
•
•
•
•
•
•
What is machine learning?
When do we need machine learning?
Applications of machine learning
Types of machine learning
Walking through a toy example on classification
Inductive vs. Deductive Reasoning
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
5
What is machine learning?
Learning is any process by which a system
improves performance from experience.
- Herbert Simon
A computer program is said to learn
- from experience E
- with respect to some class of tasks T
- and performance measure P,
if its performance at tasks in T, as measured
by P, improves with experience E.
- Tom Mitchell
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
6
Machine Learning vs Traditional Approach
Traditional Approach
Data
Computer
Output
Program
Hard-coded
Machine Learning
Data
Computer
Output
Program
Learned
Machine Learning: field of study that gives computers the
ability to learn without being explicitly programmed
- Arthur Samuel
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
7
AI, Machine Learning, and
Deep Learning
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
8
• Human expertise does not exist (navigating on Mars)
• Humans
expertiselearning?
(speech recognition)
When
do can’t
we explain
need their
machine
• Models must be customized (personalized medicine)
Lack of human expertise
Models must be customized
•(Navigating
Modelsonare
based
on
huge amounts
of data (genomics)
Mars)
(Personalized
Medicine)
Involves huge amount of data
(Genomics)
Learning
isn’t always
useful:
Learning is not always useful:
• There is no need to “learn” to calculate payroll
Based on slide by E. Alpaydin
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
No need to “learn” to calculate
payroll!
5
9
Application of Machine Learning
A classic example of a task that requires machine learn
It is very hard to say what makes a 2
Task T, Performance P, Experience E
T: Digit Recognition
P: Classification Accuracy
E: Labelled Images
Labels -&gt; Supervision!
Slide credit: Geoffrey Hinton
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
10
Application of Machine Learning
Task T, Performance P, Experience E
T: Email Categorization
P: Classification Accuracy
E: Email Data, Some Labelled
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
11
Application of Machine Learning
Task T, Performance P, Experience E
T: Playing Go Game
P: Chances of Winning
E: Records of Past Games
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
12
Application of Machine Learning
Task T, Performance P, Experience E
T: Identifying Covid-19 Clusters
P: Small Internal Distances
Larger External Distances
E: Records of Patients
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
13
Web Search Engine
Product Recommendation
Photo Tagging
Virtual Personal Assistant
Traffic Prediction
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
Medical Diagnosis
Language Translation
Portfolio Management
Algorithmic Trading
14
Types of Machine Learning
Supervised Learning
Input:
1) Training Samples,
2) Desired Output
(Teacher/Supervision)
Output:
A rule that maps input to
output
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
Unsupervised Learning
Input:
Samples
Output:
Underlying patterns in
data
Reinforcement Learning
Input:
Sequence of States,
Actions, and
Delayed Rewards
Output:
Action Strategy: a rule
that
maps
the
environment to action
15
Types of Machine Learning
Supervised Learning
Input:
1) Training Samples,
2) Desired Output
(Teacher/Supervision)
Output:
A rule that maps input to
output
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
Unsupervised Learning
Input:
Samples
Output:
Underlying patterns in
data
Reinforcement Learning
Input:
Sequence of States,
Actions, and
Delayed Rewards
Output:
Action Strategy: a rule
that
maps
the
environment to action
16
Supervised
Learning
Regression
# (Continuous)
%
Classification
# (Categorical)
Given !!, #! , ! &quot;, #&quot; , …, ! # , ##
Learn a function \$ ! to predict real-valued # given !
•
•
Regression
%
Acrtic Sea Ice Extent in January (in million sq km)
Arctic Sea Ice Extent in January (in million sq km)
#
16
16
15.5
15.5
15
15
14.5
#
14
14.5
13.5
13.5
13
13
12.5
1970
1980
1990
2000
%
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
2010
2020
2030
! &quot; : line that best aligns
with samples
14
12.5
1970
1980
1990
2000
2010
2020
2030
%
17
Supervised
Learning
•
•
Classification
width
!!
Feature
Space
%
Regression
# (Continuous)
%
Classification
# (Categorical)
Given !!, #! , ! &quot;, #&quot; , …, ! # , ##
Learn a function \$ ! to predict categorical # given !
# = Sea Bass
!&quot;
!!
# = Sea Bass
!&quot;
# = Salmon
?
# = Salmon
lightness
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
width
lightness
\$ % : line that separates
two classes
18
Types of Machine Learning
Supervised Learning
Input:
1) Training Samples,
2) Desired Output
(Teacher/Supervision)
Output:
A rule that maps input to
output
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
Unsupervised Learning
Input:
Samples
Output:
Underlying patterns in
data
Reinforcement Learning
Input:
Sequence of States,
Actions, and
Delayed Rewards
Output:
Action Strategy: a rule
that
maps
the
environment to action
19
Unsupervised Learning
Clustering
• Given !!, ! &quot;, …, ! # , without labels
• Output Hidden Structure Behind
!!
!!
!&quot;
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
!&quot;
20
Types of Machine Learning
Supervised Learning
Input:
1) Training Samples,
2) Desired Output
(Teacher/Supervision)
Output:
A rule that maps input to
output
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
Unsupervised Learning
Input:
Samples
Output:
Underlying patterns in
data
Reinforcement Learning
Input:
Sequence of States,
Actions, and
Delayed Rewards
Output:
Action Strategy: a rule
that
maps
the
environment to action
21
Reinforcement Learning
Breakout Game
Initial Performance
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
Training 15 minutes
Training 30 minutes
22
Reinforcement Learning
• Given sequence of states ! and actions &quot; with (delayed)
rewards #
• Output a policy \$(&amp;, (), to guide us what action &amp; to take in
state (
%: Ball Location,
Paddle Location, Bricks
#: left, right
&amp;:
positive reward
Knocking a brick,
clearing all bricks
negative reward
Missing the ball
zero reward
Cases in between
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
23
Supervised
Unsupervised
Quiz
A classic example of a task that requires machine learning:
Reinforcement
It is very hard to say what makes a 2
Slide credit: Geoffrey Hinton
Time!
6
Supervised
Supervised
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
Unsupervised
Reinforcement
24
Walking Through A Toy Example:
Token Classification
?
Yes
?
Yes
Step1: Feature Extraction
Extract Attributes of Samples
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
No
Step2: Sample Classification
Decide Label for a Sample
25
Walking Through A Toy Example:
Token Classification
B,L,Ring
R,L,Triangle
Y,S,Arrow
B,L,Rectangle
?
G,S,Circle
O,L,Diamond
Yes
?
G,S,Diamond
R,L,Circle
Yes
Y,L,Triangle
No
Step 1: Feature Extraction
Color, Size, Shape
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
26
Walking Through A Toy Example:
Token Classification
Feature Extraction
Color
Size
Shape
Label
Blue
Large
Ring
Yes
Red
Large
Triangle
Yes
Orange
Large
Diamond
Yes
Green
Small
Circle
Yes
Yellow
Small
Arrow
No
Blue
Large
Rectangle
No
Red
Large
Circle
No
Green
Small
Diamond
No
Yellow
Large
Triangle
?
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
27
Walking Through A Toy Example:
Token Classification
Feature Extraction
Color
Size
Shape
Label
Blue
Large
Ring
Yes
Red
Large
Triangle
Yes
Orange
Large
Diamond
Yes
Green
Small
Circle
Yes
Yellow
Small
Arrow
No
Blue
Large
Rectangle
No
Red
Large
Circle
No
Green
Small
Diamond
No
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
28
Walking Through A Toy Example:
Token Classification
Feature Extraction
Similarity
Color
Size
Shape
Label
Color
Size
Shape
Total
Blue
Large
Ring
Yes
0
1
0
1
Red
Large
Triangle
Yes
0
1
1
2
Orange
Large
Diamond
Yes
0
1
0
1
Green
Small
Circle
Yes
0
0
0
0
Yellow
Small
Arrow
No
1
0
0
1
Blue
Large
Rectangle
No
0
1
0
1
Red
Large
Circle
No
0
1
0
1
Green
Small
Diamond
No
0
0
0
0
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
29
Walking Through A Toy Example:
Token Classification
Similarity
Color
Size
Shape
Total
0
1
0
1
0
1
1
2
0
1
0
1
0
0
0
0
1
0
0
1
0
1
0
1
0
1
0
1
0
0
0
0
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
Nearest Neighbor Classifier:
1) Find the “nearest
neighbor” of a sample in
the feature space
2)
Assign the label of the
nearest neighbor to the
sample
30
Inductive vs. Deductive Reasoning
• Main Task of Machine Learning: to make inference
Two Types of Inference
Inductive
Deductive
•
•
•
To reach probable conclusions
Not all needed information is
available, causing uncertainty
Probability and Statistics
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
•
To reach logical conclusions
deterministically
All information that can lead to
the correct conclusion is
available
Rule-based reasoning
31
Inductive Reasoning
Note: humans use inductive reasoning all the time and
not in a formal way like using probability/statistics.
Ref: Gardener, Martin (March 1979). &quot;MATHEMATICAL GAMES: On the fabric of
inductive logic, and some probability paradoxes&quot; (PDF). Scientific American. 234
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
32
Summary by Quick Quiz
Three Components in ML Definition
Task T, Performance P, Experience E
Three Types of in ML
Supervised Learning
Unsupervised Learning
Reinforcement Learning
Inductive and Deductive
Inductive: Probable
Deductive: Rule-based
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
Two Types of Supervised Learning
Classification, Regression
One Type of Unsupervised Learning
Clustering
Example of a Classifier Model
Nearest Neighbor Classifier
33
!&quot;#\$%&amp;'()*+&quot;,,-&quot;./01&quot;233&quot;4()*+5&quot;4656'7681&quot;
34
```