Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... ·...

63
Introduction to Machine Learning Introduction to Machine Learning Amo G. Tong 1

Transcript of Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... ·...

Page 1: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

Introduction to Machine Learning

Introduction to Machine Learning Amo G. Tong 1

Page 2: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

Lecture 1Introduction

• Course Information

• Introduction

• Remarks

• Optimization

• Some materials are courtesy of Vibhave Gogate and Tom Mitchell.

• All pictures belong to their creators.

Introduction to Machine Learning Amo G. Tong 2

Page 3: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• CISC 684

• Class Time: M/W 8:40-9:55 am

• Instructor: Dr. Tong

• Email: [email protected]

• TA Information: See Canvas

Introduction to Machine Learning Amo G. Tong 3

Course Information

Page 4: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

Introduction to Machine Learning Amo G. Tong 4

Evaluations

• Four assignments. (30%)• Individual Problems: analysis• Group Problems: programming

• Midterm. (25%)

• Final exam. (25%)

• Group Project. (10%)• Project Proposal• Project Report.

• Group Participation (5%)

• Quiz. (5%)• A student will automatically get full credit for pop quiz if they get no less

than 90% of the total in the final exam.

• Extra credits. (5% more or less)

Page 5: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

Introduction to Machine Learning Amo G. Tong 5

• Find your teammates.

• A group should have two to four members, unless otherwise permitted by the instructor.

• Each student should be in a group. If you have difficulties in finding a group, please email the instructor.

• A group should have a leader who is responsible for communications and making submissions.

• The leader should send the names of the group members to the TA by Sep 6.

• See Syllabus on Canvas for more details.

First thing to do

Page 6: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

Introduction to Machine Learning Amo G. Tong 6

Course

• Attendance is mandatory.

• Please carefully read the first four pages of the syllabus and pay attention to the announcement on Canvas.

• Feel free to send me emails or discuss things on Piazza.

Page 7: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Text book:

• Machine Learning, Tom Mitchell, McGraw Hill, 1997. 1st Edition. Link

• Machine Learning: a Probabilistic Perspective, Kevin Patrick Murphy, 1st Edition. Link

• Pattern Recognition and Machine Learning, C. Bishop, Springer Link

• Other materials: As announced.

• Prerequisite:

• Probability Theory, Discrete Math

• Simple Calculus

• Linear Algebra preferred.

Introduction to Machine Learning Amo G. Tong 7

Materials

Page 8: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• What is machine learning?

• Informally, given some training data, we want to solve a problem related to the given data, at our best.

Introduction to Machine Learning Amo G. Tong 8

Machine Learning

Page 9: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• What is machine learning?

• Informally, given some training data, we want to solve a problem related to the given data, at our best.

• A checker learning problem.

• Experience: records of previous games. (data)

• Task: how to play checker. (problem)

• Performance Measure: percent of games won. (at our best)

Introduction to Machine Learning Amo G. Tong 9

Machine Learning

Page 10: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• What is machine learning?

• Informally, given some training data, we want to solve a problem related to the given data, at our best.

• A robot driving learning problem.

Introduction to Machine Learning Amo G. Tong 10

https://www.irishtimes.com/polopoly_fs/1.3400131.1519215500!/image/image.jpg_gen/derivatives/box_620_330/image.jpghttps://www.ucsusa.org/sites/default/files/styles/adaptive/public/images/2017/01/vehicles-cars-how-autonomous-vehicles-work.jpg?itok=a4C4VKIJ

robot driving human driving

Machine Learning

Page 11: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• What is machine learning?

• Informally, given some training data, we want to solve a problem related to the given data, at our best.

• A robot driving learning problem.

• Experience: images and commands recorded while observing a human driver. (data)

• Task: driving on public highways using vision sensors. (problem)

• Performance measure: average distance traveled before an error. (at our best)

Introduction to Machine Learning Amo G. Tong 11

Design algorithm automatically

Machine Learning

Page 12: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• What is machine learning?

• Machine Learning is the science of getting computers to learn as well as humans do or better. - Dr. Roman Yampolskiy

• Machine Learning at its most basic is the practice of using algorithms to parse data, learn from it, and then make a determination or prediction about something in the world. -Michael Copeland, Nvidia.

• Formally, A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, its performance at tasks in T as measured by P, improves with experience. - T. Mitchell

• Why not define machine learning yourself after learning this course?

Introduction to Machine Learning Amo G. Tong 12

Machine Learning

Page 13: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Advertisement Filtering

Introduction to Machine Learning Amo G. Tong 13

Advertisement or regular email?

Examples of Machine Learning Tasks

Page 14: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Regression

• 𝑓(𝑥)

Introduction to Machine Learning Amo G. Tong 14

Examples of Machine Learning Tasks

Page 15: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Regression

• 𝑓(𝑥)

Introduction to Machine Learning Amo G. Tong 15

Predict 𝑓(𝑥) for other 𝑥.Looks like we have 𝑓(𝑥) = 𝑐 for some constant 𝑐.

𝑦

𝑥

𝑓(𝑥)? 𝑓(𝑥)?

Examples of Machine Learning Tasks

Training data

Prediction

Page 16: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Regression

• 𝑓(𝑥)

Introduction to Machine Learning Amo G. Tong 16

Predict 𝑓(𝑥) for other 𝑥.Looks like we have a linear function.

𝑦

𝑥

𝑓(𝑥)?

Examples of Machine Learning Tasks

Page 17: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Regression

• 𝑓(𝑥)

Introduction to Machine Learning Amo G. Tong 17

Predict 𝑓(𝑥) for other 𝑥.Looks like we have a linear function.

𝑦

𝑥

𝑓(𝑥)?

Examples of Machine Learning Tasks

How to compute this line?

Prediction

Page 18: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Regression

• 𝑓(𝑥)

Introduction to Machine Learning Amo G. Tong 18

Predict 𝑓(𝑥) for other 𝑥.Looks like we have a complicated function.

𝑓(𝑥)? The gold price tomorrow.

Examples of Machine Learning Tasks

Page 19: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Collaborative Filtering : predict how well a user will like an item that he has not rated given a set of historical preference judgments for a community of users.

Introduction to Machine Learning Amo G. Tong 19

Examples of Machine Learning Tasks

Page 20: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

Introduction to Machine Learning Amo G. Tong 20

Why machine learning?

Characteristics of Machine Learning

Page 21: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Human expertise is not needed.

• Example: AlphaGo.

• AlphaGo was built by machine learning experts and some people who are familiar with Go. We do not need a champion.

• However, AlphaGo won the games against the champions.

Introduction to Machine Learning Amo G. Tong 21

https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/300px-FloorGoban.JPG

Characteristics of Machine Learning

Why machine learning?

Page 22: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Handle the case when human expertise cannot be explained easily.

• Example: AlphaGo.

• Even a champion cannot easily explain the best way to play Go. A Go player needs to practice many years before becoming a champion.

• However, AlphaGo learns really fast due to the high performance computing devices.

Introduction to Machine Learning Amo G. Tong 22

Characteristics of Machine Learning

Why machine learning?

Page 23: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Handle the case when requirements and data change over time.

• Example: fingerprint recognition.

• A fingerprint application may receive new prints everyday.

Introduction to Machine Learning Amo G. Tong 23

Characteristics of Machine Learning

Why machine learning?

Page 24: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Handle the case when the problem or the data size is just too large

• Example: checker learning.

• Given a lot of records of the games, a human cannot check the records one by one to learning how to play checker.

Introduction to Machine Learning Amo G. Tong 24

Characteristics of Machine Learning

Why machine learning?

Page 25: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Supervised (Inductive) Learning.

Introduction to Machine Learning Amo G. Tong 25

Types of Machine Learning Tasks

Page 26: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Supervised (Inductive) Learning.

• 𝑋: all possible data (instance space)

• We assume there is an unknown function 𝑓 defined over 𝑋.

Introduction to Machine Learning Amo G. Tong 26

Types of Machine Learning Tasks

Page 27: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Supervised (Inductive) Learning.

• 𝑋: all possible data (instance space)

• We assume there is an unknown function 𝑓 defined over 𝑋.

• Training data: a subset 𝑿𝒄 ⊆ 𝑿 and 𝒇(𝒙) for each 𝒙 ∈ 𝑿𝒄.

• Given the training data, we want to know 𝒇(𝒙) for future 𝒙. That is, we want learn the function 𝒇 from the training data.

Introduction to Machine Learning Amo G. Tong 27

Types of Machine Learning Tasks

Page 28: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Supervised (Inductive) Learning.

• 𝑋: all possible data (instance space)

• We assume there is an unknown function 𝑓 defined over 𝑋.

• Training data: a subset 𝑋𝑐 ⊆ 𝑋 and 𝑓(𝑥) for each 𝑥 ∈ 𝑋𝑐.

• Given the training data, we want to know 𝑓(𝑥) for future 𝑥. That is, we want to learn the function 𝑓 from the training data.

• Example: Handwriting number recognition.

• {all possible handwriting numbers} to {0,1,2,3,4,5,6,7,8,9}

• The instance space is infinite.

• We have some recognized samples.

• Recognize new images.

Introduction to Machine Learning Amo G. Tong 28

𝑓 = 2

Types of Machine Learning Tasks

Page 29: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Supervised (Inductive) Learning.

• 𝑋: all possible data (instance space)

• A target set Y.

• Assume there is a joint distribution 𝐷 define over (𝑋, 𝑌)

• Training data: a subset of samples generated from D.

• Given the training data, we want to learn the underlying distribution D.

•Pr 1 ] = 0.1

•Pr[2| ] = 0.9

Introduction to Machine Learning Amo G. Tong 29

More general, a probabilistic perspective.

Types of Machine Learning Tasks

Page 30: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Supervised (Inductive) Learning.

• 𝑋: all possible data (instance space)

• A target set Y.

• Assume there is a joint distribution 𝐷 define over (𝑋, 𝑌)

• (a) a distribution over the functions from 𝑋 to 𝑌.

• (b) for each 𝑥 ∈ X, a distribution over 𝑌.

• 𝑋={0, 1, 2}, 𝑌={Yes, No}. A distribution over the 3 ∗ 2 pairs (𝑥, 𝑦).

• A distribution over the 23 functions from 𝑋 to 𝑌.

• A distribution over {Yes, No} for each 𝑥 ∈ 𝑋.

Introduction to Machine Learning Amo G. Tong 30

Types of Machine Learning Tasks

Page 31: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Unsupervised Learning.

• No labels on the training data.

• Draw references, e.g. hidden structures, from data.

• Example: Discovery clusters of data.

Introduction to Machine Learning Amo G. Tong 31

Types of Machine Learning Tasks

Page 32: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Supervised (Inductive) Learning.

• Training data with labels

• Unsupervised Learning

• Training data without labels

• Semi-supervised learning

• Training data with few labels.

• Reinforcement learning

• The learner interacts with the world via “actions” and tries to find an optimal policy of behavior with respect to “rewards” it receives from the environment

Introduction to Machine Learning Amo G. Tong 32

Types of Machine Learning Tasks

Page 33: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

Introduction to Machine Learning Amo G. Tong 33

Remarks

Page 34: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• To learn is to search the hypothesis space to find one that best fits the data.

Introduction to Machine Learning Amo G. Tong 34

𝑦

𝑥

Regression: the hypothesis space is a set of functions.

Remarks

Page 35: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• To learn is to search the hypothesis space to find one that best fits the data.

Introduction to Machine Learning Amo G. Tong 35

(a) We can hardly draw any conclusion if no prior assumption.

If we assume each function is equally possible, then any function fitting the data is equally good. No conclusion can be drawn.

Should we consider all the functions?

Remarks

𝑦

𝑥

Page 36: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• To learn is to search the hypothesis space to find one that best fits the data.

Introduction to Machine Learning Amo G. Tong 36

Remarks

𝑦

𝑥

Predict 𝑓(𝑥) here

Page 37: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• To learn is to search the hypothesis space to find one that best fits the data.

Introduction to Machine Learning Amo G. Tong 37

(a) We can hardly draw any conclusion if no prior assumption.

If we assume the underlying function is linear, only one solution exists.

Should we consider all the functions?

Remarks

𝑦

𝑥

Page 38: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• To learn is to search the hypothesis space to find one that best fits the data.

Introduction to Machine Learning Amo G. Tong 38

𝑦

𝑥

(b) How to make assumptions?• Prior Knowledge• …

Remarks

𝑦

𝑥

Linear

𝑦

𝑥

Quadratic

Page 39: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• To learn is to search the hypothesis space to find one that best fits the data.

Introduction to Machine Learning Amo G. Tong 39

𝑦

𝑥

(b) How to make assumptions?• Prior Knowledge• …

Remarks

𝑦

𝑥

Linear

Assuming it is linear, how to find the best one? [we need a machine learning algorithm]

Page 40: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• To learn is to search the hypothesis space to find one that best fits the data.

• A machine learning algorithm is a search procedure.

• Different models consider different hypothesis

• Different algorithms search the space according to different measures.

Introduction to Machine Learning Amo G. Tong 40

Remarks

Page 41: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• We cannot learn everything.

Introduction to Machine Learning Amo G. Tong 41

Remarks

Page 42: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• We cannot learn everything.

• Can we predict the Powerball winning number according to

Introduction to Machine Learning Amo G. Tong 42

Remarks

Page 43: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• We cannot learn everything.

• Can we predict the Powerball winning number according to

• the weather of last week?

• the gold price yesterday?

• the previous winning numbers?

Introduction to Machine Learning Amo G. Tong 43

Remarks

Page 44: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• We cannot learn everything.

• Can we predict the Powerball winning number according to

• the weather of last week?

• the gold price yesterday?

• the previous winning numbers?

• No, we cannot because they cannot affect the future winning number.

• That is, there must be some underlying relationship between the data and the learning goal.

Introduction to Machine Learning Amo G. Tong 44

Remarks

Page 45: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• We cannot learn it if we do not have good data.

• Regression.

• Can you learning 𝑓(𝑥)?

Introduction to Machine Learning Amo G. Tong 45

Remarks

Page 46: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• We cannot learn it if we do not have good data.

• Regression.

• Can you learning 𝑓(𝑥)?

• Formally, what general bounds can be found to relate the confidence in learned hypotheses space to amount of training data and the character of the learner’s hypothesis space?

• Informally, how much data is needed for a good solution?

Introduction to Machine Learning Amo G. Tong 46

Remarks

Page 47: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• We cannot learn it if we do not have good data.

• Regression.

• Can you learning 𝑓(𝑥)?

• Formally, what general bounds can be found to relate the confidence in learned hypotheses space to amount of training data and the character of the learner’s hypothesis space?

• It relates to the hypothesis space.

• E.g. learning a linear function requires two points. 𝒚 = 𝒂𝒙 + 𝒃

• E.g. learning a quadratic function requires three points. 𝒂𝒙𝟐 + 𝒃𝒙 + 𝒄 = 𝒚.

Introduction to Machine Learning Amo G. Tong 47

Remarks

Page 48: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Algorithm/Model Selection.

• Once you have a reasonable task and a good training data, which model/algorithm should be used?

• Decision Tree.

• Support vector machine.

• Neural Networks.

• Naïve Bayes.

• …

Introduction to Machine Learning Amo G. Tong 48

Remarks

Page 49: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Overfitting vs Underfitting

• Underfitting refers to the case when the results cannot capture the structure of the data.

• Cannot do good prediction.

• Overfitting refers to the case when the results fits the training data too well.

• Cannot do good prediction.

Introduction to Machine Learning Amo G. Tong 49

Remarks

Page 50: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Overfitting vs Underfitting

Introduction to Machine Learning Amo G. Tong 50

Remarks

Page 51: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Overfitting vs Underfitting

Introduction to Machine Learning Amo G. Tong 51

Underfitting

Remarks

Page 52: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Overfitting vs Underfitting

Introduction to Machine Learning Amo G. Tong 52

Remarks

Underfitting Overfitting

Page 53: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Overfitting vs Underfitting

Introduction to Machine Learning Amo G. Tong 53

Better

Tips: a simple representation of the target function is preferred.

Remarks

Underfitting Overfitting

Page 54: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Note: machine learning involves a lot of optimizations!

• Lagrange multiplier: a useful method to find the maxima or minima of a function 𝑓(𝑥1, … , 𝑥𝑛) subject to 𝑔(𝑥1, … , 𝑥𝑛) = 0.

• Step 1. Consider 𝐿 = 𝑓 − 𝜆 𝑔.

• Step 2. Calculate the partial derivatives 𝜕 𝐿

𝜕 𝑥𝑖and

𝜕 𝐿

𝜕 𝜆

• Step 3. Solve the equations 𝜕 𝐿

𝜕 𝑥𝑖= 0 and

𝜕 𝐿

𝜕 𝜆= 0

Introduction to Machine Learning Amo G. Tong 54

Optimization

Page 55: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Note: machine learning involves a lot of optimizations!

• Lagrange multiplier: a useful method to find the maxima or minima of a function 𝑓(𝑥1, … , 𝑥𝑛) subject to 𝑔(𝑥1, … , 𝑥𝑛) = 0.

• Step 1. Consider 𝐿 = 𝑓 − 𝜆 𝑔.

• Step 2. Calculate the partial derivatives 𝜕 𝐿

𝜕 𝑥𝑖and

𝜕 𝐿

𝜕 𝜆

• Step 3. Solve the equations 𝜕 𝐿

𝜕 𝑥𝑖= 0 and

𝜕 𝐿

𝜕 𝜆= 0

• Note: the solution can be maxima or minima.

• Special case: find the maxima or minima of 𝒇 𝒙𝟏, … , 𝒙𝒏 . Set 𝝀 = 𝟎

Introduction to Machine Learning Amo G. Tong 55

we have 𝑛 + 1equations and 𝑛 + 1 variables

Optimization

Page 56: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Maximize 𝑥1 + 𝑥2

• Subject to 𝑥12 + 𝑥2

2 − 1 = 0

• 𝐿 = 𝑥1 + 𝑥2 − 𝜆( 𝑥12 + 𝑥2

2 − 1)

•𝜕 𝐿

𝜕 𝑥1= 1 − 2𝜆𝑥1 = 0,

𝜕 𝐿

𝜕 𝑥2= 1 − 2𝜆𝑥2 = 0,

𝜕 𝐿

𝜕 𝜆= 𝑥1

2 + 𝑥22 − 1 = 0

• Solve the above equations:

• (𝑥1 =1

2, 𝑥2 =

1

2, 𝜆 =

1

2) and (𝑥1 = −

1

2, 𝑥2 = −

1

2, 𝜆 = −

1

2)

Introduction to Machine Learning Amo G. Tong 56

maxima minima

Optimization

Page 57: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Note: machine learning involves a lot of optimizations!

• Gradient Descent: a useful method to find the solution to minimize function 𝑓(𝑥1, … , 𝑥𝑛).

• Iteratively update the current solution x by

• Simultaneously update each 𝑥𝑖 by 𝑥𝑖 = 𝑥𝑖 − 𝛼𝜕 𝑓

𝜕 𝑥𝑖

• Until converge or other criteria met.

• (−𝜕 𝑓

𝜕 𝑥1, … , −

𝜕 𝑓

𝜕 𝑥𝑛) : the direction that 𝑓 decreases most fast. (where to move)

• 𝛼: learning rate. (how far to move)

Introduction to Machine Learning Amo G. Tong 57

Optimization

Page 58: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Note: machine learning involves a lot of optimizations!

• Gradient Descent: a useful method to find the solution to minimize function 𝑓(𝑥1, … , 𝑥𝑛).

• Gradient Descent and Convex.

Introduction to Machine Learning Amo G. Tong 58

𝑥𝑖 = 𝑥𝑖 − 𝛼𝜕 𝑓

𝜕 𝑥𝑖

optimal

If you are hereIf you are here

Optimization

Page 59: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Note: machine learning involves a lot of optimizations!

• Gradient Descent: a useful method to find the solution to minimize function 𝑓(𝑥1, … , 𝑥𝑛).

• Gradient Descent and Convex.

Introduction to Machine Learning Amo G. Tong 59

𝑥𝑖 = 𝑥𝑖 − 𝛼𝜕 𝑓

𝜕 𝑥𝑖

optimal

Optimization

If 𝛼 is too small, slow convergence.

Page 60: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Note: machine learning involves a lot of optimizations!

• Gradient Descent: a useful method to find the solution to minimize function 𝑓(𝑥1, … , 𝑥𝑛).

• Gradient Descent and Convex.

Introduction to Machine Learning Amo G. Tong 60

𝑥𝑖 = 𝑥𝑖 − 𝛼𝜕 𝑓

𝜕 𝑥𝑖

optimal

If 𝛼 is too large, may diverge.

Optimization

Page 61: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Note: machine learning involves a lot of optimizations!

• Gradient Ascent: a useful method to find the solution to maximize function 𝑓(𝑥1, … , 𝑥𝑛).

• Iteratively update the current solution x by

• Simultaneously update each 𝑥𝑖 by 𝑥𝑖 = 𝑥𝑖 + 𝛼𝜕 𝑓

𝜕 𝑥𝑖

• Until converge or other criteria met.

• (𝜕 𝑓

𝜕 𝑥1, … ,

𝜕 𝑓

𝜕 𝑥𝑛) : the direction that 𝑓 increases most fast.

Introduction to Machine Learning Amo G. Tong 61

Optimization

Page 62: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

• Note: machine learning involves a lot of optimizations!

• Common derivatives:

•𝜕 𝑥𝑎

𝜕 𝑥= 𝑎𝑥𝑎−1,

𝜕 ln𝑥

𝜕 𝑥=

1

𝑥,

𝜕 𝑎𝑥

𝜕 𝑥= 𝑎𝑥 ln 𝑎

• Rules:

•𝜕 𝑓 𝑥 +𝑔(𝑥)

𝜕 𝑥=

𝜕 𝑓 𝑥

𝜕 𝑥+

𝜕 𝑔 𝑥

𝜕 𝑥

•𝜕 𝑓 𝑥 𝑔(𝑥)

𝜕 𝑥= 𝑔(𝑥)

𝜕 𝑓 𝑥

𝜕 𝑥+ 𝑓(𝑥)

𝜕 𝑔 𝑥

𝜕 𝑥

•𝜕 𝑓 𝑔(𝑥)

𝜕 𝑥=

𝜕 𝑓 𝑥

𝜕𝑔(𝑥)⋅𝜕 𝑔 𝑥

𝜕 𝑥

Introduction to Machine Learning Amo G. Tong 62

summation

multiplication

chain

Optimization

Page 63: Introduction to Machine Learning - udel.eduudel.edu/~amotong/teaching/machine learning... · Introduction to Machine Learning Amo G. Tong 5 •Find your teammates. •A group should

Introduction to Machine Learning Amo G. Tong 63

• Supervised learning: Decision tree induction, Rule induction, Instance-based learning, Bayesian learning, Neural networks, Support vector machines, Linear Regression, Model ensembles, Graphical models, etc.

• Unsupervised learning: Clustering, Dimensionality reduction

• General machine learning concepts and techniques: Feature selection, cross-validation, maximum likelihood estimation, gradient descent, expectation-maximization, learning theory.

• Advanced topics: deep learning, etc.

• Prerequisite: probability, statistics, simple calculus, linear algebra.

• Theoretical analysis and practical programming.

Things Will Be Covered