lecture 2: basics - github pages · last lecture •what is machine learning and what is artificial...
TRANSCRIPT
![Page 1: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/1.jpg)
Lecture 2: BasicsShuai Li
John Hopcroft Center, Shanghai Jiao Tong University
https://shuaili8.github.io
https://shuaili8.github.io/Teaching/VE445/index.html
1
![Page 2: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/2.jpg)
Last lecture
• What is Machine Learning and what is Artificial Intelligence
• An example of AI but not ML• A* algorithm
• History of ML• Deduction
• Learning from samples (deep learning)
• Recent progress• Computer vision/speech recognition/natural language processing/game AI
• Many applications• Many industries/many aspects of life
2
![Page 3: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/3.jpg)
Today’s lecture
• The classification of machine learning• Supervised/unsupervised/reinforcement
• Supervised learning• Evaluation metrics for classification
• Accuracy/Precision/Recall/F1 score
• Evaluation metrics for regression• Pearson coefficient/coefficient of determination
• Model selection: bias/variance/generalization
• Machine learning process
• Generalization error bound (next time)
3
![Page 4: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/4.jpg)
4
![Page 5: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/5.jpg)
Machine Learning Categories
• Unsupervised learning• No labeled data
• Supervised learning• Use labeled data to predict on unseen points
• Semi-supervised learning• Use labeled data and unlabeled data to predict on unlabeled/unseen points
• Reinforcement learning• Sequential prediction and receiving feedbacks
5
![Page 6: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/6.jpg)
Supervised learning example
6
![Page 7: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/7.jpg)
Unsupervised learning example
7
![Page 8: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/8.jpg)
Semi-supervised learning example
8
![Page 9: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/9.jpg)
Reinforcement learning example
9
![Page 10: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/10.jpg)
10
![Page 11: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/11.jpg)
11
![Page 12: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/12.jpg)
Supervised Learning
12
![Page 13: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/13.jpg)
13
![Page 14: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/14.jpg)
14
![Page 15: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/15.jpg)
Classification -- Handwritten digits
15
![Page 16: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/16.jpg)
Regression example
16
![Page 17: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/17.jpg)
Model Evaluations
17
![Page 18: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/18.jpg)
Classification -- Model evaluations
• Confusion Matrix• TP – True Positive ; FP – False Positive
• FN – False Negative; TN – True Negative
Predicted Class
Actual
Class
Class = Yes Class = No
Class = Yes a (TP) b (FN)
Class = No c (FP) d (TN)
FNFPTNTP
TNTP
dcba
da
+++
+=
+++
+= Accuracy
18
![Page 19: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/19.jpg)
Classification -- Model evaluations
• Given a set of records containing positive and negative results, the computer is going to classify the records to be positive or negative.
• Positive: The computer classifies the result to be positive
• Negative: The computer classifies the result to be negative
• True: What the computer classifies is true
• False: What the computer classifies is false
19
![Page 20: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/20.jpg)
Classification -- Model evaluations
• Limitation of Accuracy• Consider a 2-class problem
• Number of Class 0 examples = 9990
• Number of Class 1 examples = 10
• If a “stupid” model predicts everything to be class 0, accuracy is 9990/10000 = 99.9 %
• The accuracy is misleading because the model does not detect any example in class 1
20
![Page 21: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/21.jpg)
Classification -- Model evaluations
• Cost-sensitive measures
cba
a
pr
rp
ba
a
FNTP
TP
ca
a
FPTP
TP
++=
+=
+=
+=
+=
+=
2
22(F) measure-F
(r) Recall
(p) Precision
Harmonic mean of Precision and Recall (Why not just average?)
Predicted Class
Actual
Class
Class = Yes Class = No
Class = Yes a (TP) b (FN)
Class = No c (FP) d (TN)
21
![Page 22: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/22.jpg)
22
![Page 23: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/23.jpg)
How to understand
• A school is running a machine learning primary diabetes scan on all of its students• Diabetic (+) / Healthy (-)
• False positive is just a false alarm
• False negative• Prediction is healthy but is diabetic
• Worst case among all 4 cases
• Accuracy• Accuracy = (TP+TN)/(TP+FP+FN+TN)
• How many students did we correctly label out of all the students?23
![Page 24: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/24.jpg)
How to understand (cont.)
• A school is running a machine learning primary diabetes scan on all of its students• Diabetic (+) / Healthy (-)
• False positive is just a false alarm
• False negative• Prediction is healthy but is diabetic
• Worst case among all 4 cases
• Precision• Precision = TP/(TP+FP)
• How many of those who we labeled as diabetic are actually diabetic?24
![Page 25: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/25.jpg)
How to understand (cont.)
• A school is running a machine learning primary diabetes scan on all of its students• Diabetic (+) / Healthy (-)
• False positive is just a false alarm
• False negative• Prediction is healthy but is diabetic
• Worst case among all 4 cases
• Recall (sensitivity)• Recall = TP/(TP+FN)
• Of all the people who are diabetic, how many of those we correctly predict?25
![Page 26: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/26.jpg)
F1 score (F-Score / F-Measure)
• F1 Score = 2*(Recall * Precision) / (Recall + Precision)
• Harmonic mean (average) of the precision and recall
• F1 Score is best if there is some sort of balance between precision (p) & recall (r) in the system. Oppositely F1 Score isn’t so high if one measure is improved at the expense of the other.
• For example, if P is 1 & R is 0, F1 score is 0.
26
![Page 27: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/27.jpg)
Which to choose• Accuracy
• A great measure • But only when you have symmetric datasets (FN & FP counts are close)• Also, FN & FP have similar costs
• F1 score• If the cost of FP and FN are different• F1 is best if you have an uneven class distribution
• Recall • If FP is far better than FN or if the occurrence of FN is unaccepted/intolerable• Would like more extra FP (false alarms) over saving some FN• E.g. diabetes. We’d rather get some healthy people labeled diabetic over leaving a
diabetic person labeled healthy
• Precision• Want to be more confident of your TP• E.g. spam emails. We’d rather have some spam emails in inbox rather than some
regular emails in your spam box. 27
![Page 28: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/28.jpg)
Example
• Given 30 human photographs, a computer predicts 19 to be male, 11 to be female. Among the 19 male predictions, 3 predictions are not correct. Among the 11 female predictions, 1 prediction is not correct.
Predicted Class
Actual
Class
Male Female
Male a = TP = 16 b = FN = 1
Female c = FP = 3 d = TN = 10
28
![Page 29: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/29.jpg)
Example
• Accuracy = (16 + 10) / (16 + 3 + 1 + 10) = 0.867
• Precision = 16 / (16 + 3) = 0.842
• Recall = 16 / (16 + 1) = 0.941
• F-measure = 2 (0.842)(0.941) / (0.842 + 0.941)
= 0.889
Predicted Class
Actual
Class
Male Female
Male a = TP = 16 b = FN = 1
Female c = FP = 3 d = TN = 10
29
![Page 30: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/30.jpg)
Discussion
• “In a specific case, precision cannot be computed.” Is the statement true? Why?
• If the statement is true, can F-measure be computed in that case?
• How about if b is positive, a and c are negative, or if c is positive, a and b are negative ?
a b c
a TP FN FN
b FP TN TN
c FP TN TN
Classified as
a: positiveb: negativec: negative
30
![Page 31: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/31.jpg)
Regression-Model Evaluation
• Pearson correlation measures the linear association between continuous variables• Quantifies the degree to which a relationship between two variables can be
described by a line.
• Remember the definition of cosine between vectors:
31
![Page 32: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/32.jpg)
Examples of Pearson correlation
32
![Page 33: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/33.jpg)
Limitation
• Only linear correlation can be detected.
• Clearly, there are some relationship between X and Y, but the correlation is only 0.02.
33
![Page 34: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/34.jpg)
Coefficient of determination
• Coefficient of determination (R2) is the proportion of the variance in the dependent variable that is predictable from the independent variable.
• It measures how much of the residue can be explained by the regression line
34
![Page 35: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/35.jpg)
Regression -- Model evaluation
• 𝑅2 =𝑒𝑥𝑝𝑙𝑎𝑖𝑛𝑒𝑑 𝑣𝑎𝑟𝑖𝑎𝑛𝑐𝑒
𝑡𝑜𝑡𝑎𝑙 𝑣𝑎𝑟𝑖𝑎𝑛𝑐𝑒
• Total variance:
• Explained variance:
• Or, it can be computed as:
where
35
![Page 36: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/36.jpg)
Model Selections
36
![Page 37: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/37.jpg)
Minimize the error rate?
• Given a data set 𝑆
• Error rate = # of Errors
# of Total Samples
• Accuracy = 1 - Error rate
Error rate = 3
19Error rate =
2
19
https://malware.news/uploads/default/original/3X/6/d/6df12e50b7f97cdba92697ce164cbe4a5502a349.pnghttps://upload.wikimedia.org/wikipedia/commons/thumb/1/19/Overfitting.svg/1200px-Overfitting.svg.png 37
![Page 38: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/38.jpg)
Fitting
https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190523171258/overfitting_2.png 38
![Page 39: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/39.jpg)
Split training and test
• Split dataset to training and test
• Train models on training dataset
• The evaluation of the model is the error on test dataset
• Might overfit the training dataset
39
![Page 40: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/40.jpg)
Cross validation
40
![Page 41: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/41.jpg)
Bias
41
![Page 42: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/42.jpg)
Underfitting
42
![Page 43: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/43.jpg)
Variance
43
![Page 44: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/44.jpg)
Overfitting
44
![Page 45: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/45.jpg)
Bias-variance decompositionTrue value Estimated value
45
Can be understood by replacing 𝑦 and ො𝑦 with model parameters 𝜃 and መ𝜃
![Page 46: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/46.jpg)
46
![Page 47: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/47.jpg)
Generalization
• Observations:• The best hypothesis on the sample may not be the best overall
• Complex rules (very complex separation surfaces) can be poor predictors
• trade-off: complexity of hypothesis set vs sample size (underfitting/overfitting)
47
![Page 48: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/48.jpg)
Balance bias-variance trade-off
48
![Page 49: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/49.jpg)
Learning ≠ Fitting
• Notion of simplicity/complexity
• How to define complexity
• Model selection49
![Page 50: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/50.jpg)
Machine Learning Process
https://techblog.cdiscount.com/assets/images/DataScience/automl/ML_process.png50
![Page 51: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/51.jpg)
Problem Formulation
51
![Page 52: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/52.jpg)
Problem Definition
• Spaces:• Input space (feature space) 𝑋, output space (labeled space) 𝑌
• Loss function: 𝐿: 𝑌 × 𝑌 → ℝ• 𝐿( ො𝑦, 𝑦): loss of predicting ො𝑦 when the true output is 𝑦
• Binary classification: 𝐿 ො𝑦, 𝑦 = 1 ො𝑦≠𝑦
• Regression: 𝐿 ො𝑦, 𝑦 =1
2ො𝑦 − 𝑦 2
• Hypothesis set: 𝐻 ⊆ 𝑌𝑋(mappings from 𝑋 to 𝑌)• Space of possible models, e.g. all linear functions
• Depends on feature structure and prior knowledge about the problem
52
![Page 53: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/53.jpg)
Set-up
• Training data:• Sample 𝑆 of size 𝑁 drawn i.i.d. from X × 𝑌 according to distribution 𝐷:
𝑆 = 𝑥1, 𝑦1 , 𝑥2, 𝑦2 , … , 𝑥𝑁, 𝑦𝑁
• Objective:• Find hypothesis ℎ ∈ 𝐻 with small generalization error
• Generalization error𝑅 ℎ = 𝔼(𝑥,𝑦)~𝐷 𝐿(ℎ 𝑥 , 𝑦)
• Empirical error
𝑅 ℎ =1
𝑁
𝑖=1
𝑁
𝐿(ℎ 𝑥𝑖 , 𝑦𝑖)
53
![Page 54: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/54.jpg)
Model Selection
• For any ℎ ∈ 𝐻
𝑅 ℎ −minℎ′
𝑅 ℎ′ = 𝑅 ℎ − minℎ′∈𝐻
𝑅 ℎ′ + minℎ′∈𝐻
𝑅 ℎ′ −minℎ′
𝑅 ℎ′
• Approximation: only depends on 𝐻
• Estimation• Recall 𝑅 ℎ = 𝔼(𝑥,𝑦)~𝐷 𝐿(ℎ 𝑥 , 𝑦)
• Empirical error: 𝑅 ℎ =1
𝑁σ𝑖=1𝑁 𝐿(ℎ 𝑥𝑖 , 𝑦𝑖)
• Empirical risk minimization:ℎ = argminℎ∈𝐻 𝑅 ℎ
estimation approximation
54
![Page 55: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/55.jpg)
Model Selection
• 𝑅 ℎ −minℎ′
𝑅 ℎ′ = 𝑅 ℎ − minℎ′∈𝐻
𝑅 ℎ′ + minℎ′∈𝐻
𝑅 ℎ′ −minℎ′
𝑅 ℎ′
• ERM ℎ = argminℎ∈𝐻 𝑅 ℎ
estimation approximation
55
![Page 56: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/56.jpg)
Principle of Occam’s Razor
Suppose there exist two explanations for an occurrence.
The one that requires the least assumptions is usually correct.
Figure credit: Zhihua Zhou56
![Page 57: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/57.jpg)
Regularization
• Recall empirical risk minimization(ERM):ℎ = argminℎ∈𝐻 𝑅 ℎ
The above equation can be over-optimized.
• Regularization-based algorithmsℎ = argminℎ∈𝐻 𝑅 ℎ + 𝜆Ω(ℎ)
regularization parameter
Complexity of h
Figure credit: Weinan Zhang57
![Page 58: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/58.jpg)
Regularization (cont.)
• E.g. 𝐿2-norm (Ridge): Ω ℎ = 𝑎𝑥 + 𝑏 = 𝑎2 + 𝑏2
• E.g. 𝐿1-norm (Lasso): Ω ℎ = 𝑎𝑥 + 𝑏 = 𝑎 + 𝑏
https://miro.medium.com/max/1200/1*o6H_R3Do1zpch-3MZk_fjQ.png58
![Page 59: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/59.jpg)
Machine Learning Process
https://techblog.cdiscount.com/assets/images/DataScience/automl/ML_process.png59
![Page 60: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/60.jpg)
Generalization Error Bound
60
![Page 61: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/61.jpg)
61
![Page 62: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/62.jpg)
62
![Page 63: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/63.jpg)
63
![Page 64: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/64.jpg)
64
![Page 65: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/65.jpg)
Generalization error bound revisit
65
![Page 66: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/66.jpg)
Summary
• The classification of machine learning• Supervised/unsupervised/reinforcement
• Supervised learning• Evaluation metrics for classification
• Accuracy/Precision/Recall/F1 score
• Evaluation metrics for regression• Pearson coefficient/coefficient of determination
• Model selection: bias/variance/generalization
• Machine learning process
• Generalization error bound
66
![Page 67: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/67.jpg)
Next Lecture
Linear Regression
67
![Page 68: Lecture 2: Basics - GitHub Pages · Last lecture •What is Machine Learning and what is Artificial Intelligence •An example of AI but not ML •A* algorithm •History of ML •Deduction](https://reader030.vdocument.in/reader030/viewer/2022041107/5f09ebcd7e708231d42924a9/html5/thumbnails/68.jpg)
Questions?
https://shuaili8.github.io
Shuai Li
https://shuaili8.github.io/Teaching/VE445/index.html
68