Slide tria tuệ nhân tạo learning decision trees

34 10 0
Slide tria tuệ nhân tạo  learning decision trees

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Introduction to Artificial Intelligence Chapter 4: Learning (1) Learning Decision Trees Nguyễn Hải Minh, Ph.D nhminh@Cit.hcmus.edu.vn CuuDuongThanCong.com https://fb.com/tailieudientucntt Outline q Form of Learning q Learning from Decision Trees q Summary 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com https://fb.com/tailieudientucntt Learning Agents – Why learning? 1.  Unknown environments •  i.e., a robot designed to navigate mazes must learn the layout of each new maze it encounters 2.  Environment changes over time • i.e., An agent designed to predict tomorrow’s stock market prices must learn to adapt when conditions change from boom to bust 3.  No idea how to program a solution • i.e., the task to recognizing the faces of family members 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com https://fb.com/tailieudientucntt Learning element q  Design of a learning element is affected by o  Which components is to be improved o  What prior knowledge the agent already has o  What representation is used for the components o  What feedback is available to learn these components q  Type of feedback: o  Supervised learning: correct answers for each example o  Unsupervised learning: correct answers not given o  Reinforcement learning: occasional rewards 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com https://fb.com/tailieudientucntt Supervised Learning q  Simplest form: learn a function from examples q Problem: given a training set of N example inputoutput pairs (x1, y1), (x2, y2), …, (xN, yN) Where each yj was generated by an unknown function y = f(x) à Find a hypothesis h such that h ≈ f q  To measure the accuracy of a hypothesis we give it a test set of examples that are different with the training set 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com https://fb.com/tailieudientucntt Supervised Learning Consistent linear fit Consistent 7th order polynomial fit Inconsistent linear fit Consistent 6th order polynomial fit Consistent sinusoidal fit • Construct h so that it agrees with f • The hypothesis h is consistent if it agrees with f on all observations • Ockham’s razor: Select the simplest consistent hypothesis 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com https://fb.com/tailieudientucntt Learning problems h(x) = the predicted output value for the input x q Discrete valued function ⇒ classiCication q Continuous valued function ⇒ regression 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com https://fb.com/tailieudientucntt ClassiCication q Is this number 9? o  2 classes: Yes/No q Will you pass or fail the exam? o  2 classes: Fail/Pass q Is this an apple, an orange or a tomato? o  3 classes: Apple/Orange/ Tomato 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com https://fb.com/tailieudientucntt Regression q Estimating the price of a house 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com https://fb.com/tailieudientucntt A classiCication problem example Predicting whether a certain person will wait to have a seat in a restaurant 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 10 https://fb.com/tailieudientucntt Decision tree learning example Hungry? Yes No 5 T, 2 F AE Hungry = 1 T, 4 F 7⎡ ⎤ + ⎡− log − log ⎤ = 0.804 2 − log − log 2 2 7 7 ⎦ 12 ⎣ 5 5⎦ 12 ⎣ ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) IG(Hungry, S) = H(S) – AEHungry= 1 – 0.804 = 0.196 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 20 https://fb.com/tailieudientucntt Decision tree learning example Raining? Yes No 2 T, 2 F AE Raining = 4 T, 4 F − log2 − log2 + − log2 − log2 = 01 30 4 4 12 8 8 12 [ ( ) ( ) ( ) ( )] [ ( ) ( ) ( ) ( )] IG(Raining, S) = H(S) – AERaining= 1 – 1 = 0 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 21 https://fb.com/tailieudientucntt Decision tree learning example ReservaUon? Yes No 3 T, 2 F AE Reservation = 3 T, 4 F 5⎡ 3 − log 2 ⎤ + ⎡− log − log ⎤ = 0.979 − log 5 5 ⎦ 12 ⎣ 7 7⎦ 12 ⎣ ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) IG(Reservation, S) = H(S) – AEReservation= 1 – 0.979 = 0.021 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 22 https://fb.com/tailieudientucntt Decision tree learning example Patrons? None Full Some 2 F 2 T, 4 F 4 T 2⎡ ⎤ + ⎡− log − log ⎤ 2 − log − log 2 2 2 2 ⎦ 12 ⎣ 4 4⎦ 12 ⎣ + ⎡⎣− log 2 − log ⎤⎦ = 0.541 6 6 12 ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) AE Patrons = ( ) ( ) ( ) ( ) IG(Patrons, S) = H(S) – AEPatrons= 1 – 0.541 = 0.459 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 23 https://fb.com/tailieudientucntt Decision tree learning example Price $ $$$ $$ 3 T, 3 F 1 T, 3 F 2 T 6⎡ 2⎡ ⎤ ⎤ 3 0 AE Price = ⎣− log − log + − log − log 2 6 6 ⎦ 12 ⎣ 2 2⎦ 12 + ⎡⎣− log − log ⎤⎦ = 0.770 4 4 12 ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) IG(Price, S) = H(S) – AEPrice= 1 – 0.770 = 0.23 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 24 https://fb.com/tailieudientucntt Decision tree learning example Type French 1 T, 1 F Burger Italian Thai 1 T, 1 F 2 T, 2 F 2 T, 2 F 2⎡ 2⎡ ⎤ ⎤ 1 1 1 AE Type = ⎣− log − log + − log − log 2 2 2 ⎦ 12 ⎣ 2 2⎦ 12 4 + ⎡⎣− log 2 − log 2 ⎤⎦ + ⎡⎣− log 2 − log 2 ⎤⎦ = 4 4 4 4 12 12 ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) IG(Type, S) = H(S) – AEAlternate= 1 – 1 = 0 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 25 https://fb.com/tailieudientucntt Decision tree learning example Est waiUng Ume 0-10 4 T, 2 F > 60 10-30 2 F 30-60 1 T, 1 F 1 T, 1 F 6⎡ ⎤ + ⎡− log − log ⎤ 2 − log − log 2 2 6 6 ⎦ 12 ⎣ 2 2⎦ 12 ⎣ 2 + ⎡⎣− log − log ⎤⎦ + ⎡⎣− log − log 2 ⎤⎦ = 0.792 2 2 2 2 12 12 AE Est.waiting time = ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) IG(Est.Waiting time, S) = H(S) – AE Est.Waiting time = 1 – 0.792 = 0.208 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 26 https://fb.com/tailieudientucntt Decision tree learning example Patrons? None 2 F Full Some 2 T, 4 F X? 4 T q Largest Information Gain (0.459) / Smallest Entropy (0.541) achieved by splitting on Patrons q Continue like this, making new splits, always purifying nodes 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 27 https://fb.com/tailieudientucntt Decision tree learning example True tree 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 28 https://fb.com/tailieudientucntt Decision tree learning example Cannot make it more complex than what the data supports Induced tree (from examples) 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 29 https://fb.com/tailieudientucntt Performance measurement q  How do we know that h ≈ f ? 1.  Use theorems of computational/statistical learning theory 2.  Try h on a new test set of examples (use same distribution over example space as training set) Learning curve = % correct on test set as a function of training set size 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 30 https://fb.com/tailieudientucntt Summary q Learning needed for unknown environments q For supervised learning, the aim is to Cind a simple hypothesis approximately consistent with training examples q Decision tree learning using information gain q Learning performance = prediction accuracy measured on test set 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 31 https://fb.com/tailieudientucntt Next week q Individual Assignment 5 q Chapter 4: Learning (cont) o Learning Probabilistic Model o ArtiCicial Neural Network q Final Review 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 32 https://fb.com/tailieudientucntt Individual Assignment 4 q Given KB as follows Prove that there is no pit in square 1,2 (i.e., ¬P1,2) using Resolution algorithm (clearly show each pair of sentences to be resolved) KB = (B1,1 ⇔ (P1,2∨ P2,1)) ∧¬ B1,1 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 33 https://fb.com/tailieudientucntt Choosing an attribute q Idea: a good attribute splits the examples into subsets that are (ideally) "all positive" or "all negative" q Patrons? is a better choice 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 34 https://fb.com/tailieudientucntt ...Outline q Form of Learning q? ?Learning from Decision Trees q Summary 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com https://fb.com/tailieudientucntt Learning Agents – Why learning? 1. ... https://fb.com/tailieudientucntt Decision tree learning example True tree 7/25/18 Nguyễn Hải Minh @ FIT - HCMUS CuuDuongThanCong.com 28 https://fb.com/tailieudientucntt Decision tree learning example Cannot make it more complex... Summary q? ?Learning needed for unknown environments q For supervised learning, the aim is to Cind a simple hypothesis approximately consistent with training examples q? ?Decision tree learning using information gain

Ngày đăng: 14/12/2021, 22:00