EE2211 Introduction to Machine Learning Lecture 1 Wang Xinchao xinchao@nus.edu.sg !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 2 World’s Largest Selfie !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 3 World’s Largest Selfie !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 7 AI, Machine Learning, and Deep Learning !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 -> Supervision! Slide credit: Geoffrey Hinton !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 10 Application of Machine Learning Task T, Performance P, Experience E T: Email Categorization P: Classification Accuracy E: Email Data, Some Labelled !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 11 Application of Machine Learning Task T, Performance P, Experience E T: Playing Go Game P: Chances of Winning E: Records of Past Games !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 13 Web Search Engine Product Recommendation Photo Tagging Virtual Personal Assistant Traffic Prediction !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !!, #! , ! ", #" , …, ! # , ## 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 % !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 2010 2020 2030 ! " : 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 !!, #! , ! ", #" , …, ! # , ## Learn a function $ ! to predict categorical # given ! # = Sea Bass !" !! # = Sea Bass !" # = Salmon ? # = Salmon lightness !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !!, ! ", …, ! # , without labels • Output Hidden Structure Behind !! !! !" !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" !" 20 Types of Machine Learning Supervised Learning Input: 1) Training Samples, 2) Desired Output (Teacher/Supervision) Output: A rule that maps input to output !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" Training 15 minutes Training 30 minutes 22 Reinforcement Learning • Given sequence of states ! and actions " with (delayed) rewards # • Output a policy $(&, (), to guide us what action & to take in state ( %: Ball Location, Paddle Location, Bricks #: left, right &: positive reward Knocking a brick, clearing all bricks negative reward Missing the ball zero reward Cases in between !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" Unsupervised Reinforcement 24 Walking Through A Toy Example: Token Classification ? Yes ? Yes Step1: Feature Extraction Extract Attributes of Samples !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 ? !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" • 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). "MATHEMATICAL GAMES: On the fabric of inductive logic, and some probability paradoxes" (PDF). Scientific American. 234 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 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 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" Two Types of Supervised Learning Classification, Regression One Type of Unsupervised Learning Clustering Example of a Classifier Model Nearest Neighbor Classifier 33 !"#$%&'()*+",,-"./01"233"4()*+5"4656'7681" 34