AI Programming CS F-14 Decision Trees

Similar documents
Introduction to Ensemble Learning Featuring Successes in the Netflix Prize Competition

Lecture 1: Basic Concepts of Machine Learning

Module 12. Machine Learning. Version 2 CSE IIT, Kharagpur

CS Machine Learning

Lecture 1: Machine Learning Basics

Machine Learning and Data Mining. Ensembles of Learners. Prof. Alexander Ihler

Chapter 2 Rule Learning in a Nutshell

Rule Learning with Negation: Issues Regarding Effectiveness

(Sub)Gradient Descent

Rule Learning With Negation: Issues Regarding Effectiveness

Exploration. CS : Deep Reinforcement Learning Sergey Levine

Proof Theory for Syntacticians

Artificial Neural Networks written examination

Python Machine Learning

Version Space. Term 2012/2013 LSI - FIB. Javier Béjar cbea (LSI - FIB) Version Space Term 2012/ / 18

Intelligent Agents. Chapter 2. Chapter 2 1

CSL465/603 - Machine Learning

Active Learning. Yingyu Liang Computer Sciences 760 Fall

Probability and Statistics Curriculum Pacing Guide

A Case Study: News Classification Based on Term Frequency

Entrepreneurial Discovery and the Demmert/Klein Experiment: Additional Evidence from Germany

A Version Space Approach to Learning Context-free Grammars

IMGD Technical Game Development I: Iterative Development Techniques. by Robert W. Lindeman

The Good Judgment Project: A large scale test of different methods of combining expert predictions

12- A whirlwind tour of statistics

Objectives. Chapter 2: The Representation of Knowledge. Expert Systems: Principles and Programming, Fourth Edition

Lecture 10: Reinforcement Learning

Machine Learning from Garden Path Sentences: The Application of Computational Linguistics

Algebra 1, Quarter 3, Unit 3.1. Line of Best Fit. Overview

MYCIN. The MYCIN Task

have to be modeled) or isolated words. Output of the system is a grapheme-tophoneme conversion system which takes as its input the spelling of words,

The 9 th International Scientific Conference elearning and software for Education Bucharest, April 25-26, / X

Chapter 2. Intelligent Agents. Outline. Agents and environments. Rationality. PEAS (Performance measure, Environment, Actuators, Sensors)

Data Structures and Algorithms

Reinforcement Learning by Comparing Immediate Reward

Data Stream Processing and Analytics

Build on students informal understanding of sharing and proportionality to develop initial fraction concepts.

Shockwheat. Statistics 1, Activity 1

OCR for Arabic using SIFT Descriptors With Online Failure Prediction

Chapter 4 - Fractions

Maximizing Learning Through Course Alignment and Experience with Different Types of Knowledge

Toward Probabilistic Natural Logic for Syllogistic Reasoning

Eduroam Support Clinics What are they?

STAT 220 Midterm Exam, Friday, Feb. 24

A Pumpkin Grows. Written by Linda D. Bullock and illustrated by Debby Fisher

Automatic Discretization of Actions and States in Monte-Carlo Tree Search

Applications of data mining algorithms to analysis of medical data

A. What is research? B. Types of research

University of Groningen. Systemen, planning, netwerken Bosman, Aart

Managerial Decision Making

Section 7, Unit 4: Sample Student Book Activities for Teaching Listening

OPTIMIZATINON OF TRAINING SETS FOR HEBBIAN-LEARNING- BASED CLASSIFIERS

An Effective Framework for Fast Expert Mining in Collaboration Networks: A Group-Oriented and Cost-Based Method

Using dialogue context to improve parsing performance in dialogue systems

Spring 2016 Stony Brook University Instructor: Dr. Paul Fodor

Introduction to Questionnaire Design

Notes on The Sciences of the Artificial Adapted from a shorter document written for course (Deciding What to Design) 1

The Singapore Copyright Act applies to the use of this document.

Radius STEM Readiness TM

Linguistics 220 Phonology: distributions and the concept of the phoneme. John Alderete, Simon Fraser University

Case study Norway case 1

Simple Random Sample (SRS) & Voluntary Response Sample: Examples: A Voluntary Response Sample: Examples: Systematic Sample Best Used When

Part I. Figuring out how English works

The lab is designed to remind you how to work with scientific data (including dealing with uncertainty) and to review experimental design.

Agents and environments. Intelligent Agents. Reminders. Vacuum-cleaner world. Outline. A vacuum-cleaner agent. Chapter 2 Actuators

RANKING AND UNRANKING LEFT SZILARD LANGUAGES. Erkki Mäkinen DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A ER E P S I M S

Unit 1: Scientific Investigation-Asking Questions

Defragmenting Textual Data by Leveraging the Syntactic Structure of the English Language

Iterative Cross-Training: An Algorithm for Learning from Unlabeled Web Pages

LEGO MINDSTORMS Education EV3 Coding Activities

TD(λ) and Q-Learning Based Ludo Players

Grades. From Your Friends at The MAILBOX

Research Design & Analysis Made Easy! Brainstorming Worksheet

Assignment 1: Predicting Amazon Review Ratings

Probabilistic Latent Semantic Analysis

POLA: a student modeling framework for Probabilistic On-Line Assessment of problem solving performance

Algebra 2- Semester 2 Review

DegreeWorks Advisor Reference Guide

(I couldn t find a Smartie Book) NEW Grade 5/6 Mathematics: (Number, Statistics and Probability) Title Smartie Mathematics

Answer Key For The California Mathematics Standards Grade 1

On-Line Data Analytics

Twitter Sentiment Classification on Sanders Data using Hybrid Approach

Instructor: Mario D. Garrett, Ph.D. Phone: Office: Hepner Hall (HH) 100

Short vs. Extended Answer Questions in Computer Science Exams

Curriculum Design Project with Virtual Manipulatives. Gwenanne Salkind. George Mason University EDCI 856. Dr. Patricia Moyer-Packenham

Learning and Transferring Relational Instance-Based Policies

IT Students Workshop within Strategic Partnership of Leibniz University and Peter the Great St. Petersburg Polytechnic University

Using focal point learning to improve human machine tacit coordination

CS 446: Machine Learning

Learning goal-oriented strategies in problem solving

Testing A Moving Target: How Do We Test Machine Learning Systems? Peter Varhol Technology Strategy Research, USA

Constructive Induction-based Learning Agents: An Architecture and Preliminary Experiments

*Net Perceptions, Inc West 78th Street Suite 300 Minneapolis, MN

Writing Research Articles

Lecture 2: Quantifiers and Approximation

Physics 270: Experimental Physics

A Decision Tree Analysis of the Transfer Student Emma Gunu, MS Research Analyst Robert M Roe, PhD Executive Director of Institutional Research and

Learning From the Past with Experiment Databases

Learning Methods in Multilingual Speech Recognition

Prewriting: Drafting: Revising: Editing: Publishing:

Transcription:

AI Programming CS662-2008F-14 Decision Trees David Galles Department of Computer Science University of San Francisco

14-0: Rule Learning Previously, we ve assumed that background knowledge was given to us by experts. Focused on how to use that knowledge. Today, we ll talk about how to acquire that knowledge from observation. Focus on learning propositional rules sunny warm PlayTennis cool (rain strongwind) PlayTennis

14-1: Learning What does it mean for an agent to learn?

14-2: Learning What does it mean for an agent to learn? Agent acquires new knowledge Agent changes its behavior Agent improves its performance measure on a given task

14-3: Learning Agents A learning agent has a performance element and a learning element. The performance element is what an agent uses to decide what to do. This is what we ve studied up to now. The learning element is what allows the agent to modify the performance element. This might mean adding or changing rules or facts, modifying a heuristic, changing a successor function In order to modify its behavior, an agent needs information telling it how well it is performing. This information is called feedback.

14-4: Deduction vs. Induction Up to now, we ve looked at cases where our agent is given general knowledge and uses this to solve a particular problem. Exactly two people like Homer, Suck always cleans a room, etc. This general-to-specific reasoning is known as deduction. Advantage: deduction is sound, assuming your knowledge is correct.

14-5: Deduction vs. Induction Sometimes, you may not have general information about a problem. Instead, you might have data about particular instances of a problem. The problem then is to figure out a general rule from specific data. This is called induction - most learning is an inductive process. Problem: induction is not sound.

14-6: Example Consider the problem of an agent deciding whether we should play tennis on a given day. There are four observable percepts: Outlook (sunny, rainy, overcast) Temperature (hot, mild, cool) Humidity (high, low) Wind (strong, weak) We don t have a model, but we do have some data about past decsions. Can we induce a general rule for when to play tennis?

14-7: Types of Learning Tasks There are essentially three categories of learning tasks, each of which provides different feedback. They vary in the amount of information that is available to our learning algorithm. Supervised learning. In this case, an external source (often called a teacher) provides the agent with labeled examples Agent sees specific actions/cases, along with their classification. D2 was Sunny, mild, high humidity and weak wind. We played tennis.

14-8: Types of Learning Tasks Unsupervised Learning In this case, there is no teacher to provide examples. The agent typically tries to find a concept or pattern in data. Statistical methods such as clustering fall into this category Our agent might be told that day1, day 4 and day 7 are similar and need to determine what characteristics make these days alike.

14-9: Types of Learning Tasks Reinforcement Learning This is a particular version of learning in which the agent only receives a reward for taking an action. May not know how optimal a reward is. Will not know the best action to take Our agent might be presented with a Sunny, Hot, Low humidity, Strong wind day and asked to choose whether to play tennis. It chooses yes and gets a reward of 0.3 Is 0.3 good or bad?

14-10: Supervised Learning Supervised learning is one of the most common forms of learning. Agent is presented with a set of labeled data and must use this data to determine more general rules. Examples: List of patients and characteristics: what factors are correlated with cancer? What factors make someone a credit risk? What are the best questions for classifying animals? Whose face is in this picture? This is the form of learning we will spend most of our time on.

14-11: Classification the particular learning problem we are focusing on is sometimes known as classification For a given input, determine which class it belongs to. Programs that can perform this task are referred to as classifiers

14-12: The Learning Problem We can phrase the learning problem as that of estimating a function f that tells us how to classify a set of inputs. An example is a set of inputs x and the corresponding f(x) - the class that x belongs to. << Overcast, Cool, Low, Weak >, playtennis > We can define the learning task as follows: Given a collection of examples of f, find a function H that approximates f for our examples. H is called a hypothesis.

14-13: Induction We would like H to generalize This means that H will correctly classify unseen examples. If the hypothesis can correctly classify all of the training examples, we call it a consistent hypothesis. Goal: find a consistent hypothesis that also performs well on unseen examples. We can think of learning as search through a space of hypotheses.

14-14: Inductive Bias Notice that induction is not sound. In picking a hypothesis, we make an educated guess about how to classify unseen data. The way in which we make this guess is called a bias. All learning algorithms have a bias; identifying it can help you understand the sorts of errors it will make. Examples: Occam s razor Most specific hypothesis. Most general hypothesis. Linear function

14-15: Observing Data Agents may have different means of observing examples of a hypothesis. A batch learning algorithm is presented with a large set of data all at once and selects a single hypothesis. An incremental learning algorithm receives examples one at a time and continually modifies its hypothesis. Batch is typically more accurate, but incremental may fit better with the agent s environment. An active learning agent is able to choose examples.

14-16: Online vs Offline An offline learing algorithm is able to separate learning from execution. Learning and performance are separate Batch learning is easier, computational complexity is less of a factor. An online learning algorithm allows an agent to mix learning and execution. Agent takes actions, receives feedback, and updates its performance component. We will worry about both training time (time needed to construct a hypothesis) and classification time (time needed to classify a new instance).

14-17: Learning Decision Trees Decision trees are data structures that provide an agent with a means of classifying examples. At each node in the tree, an attribute is tested. y Has Feathers? n y Can Fly? n y Carivore? n Can Swim? y n Robin Stripes? y n Long Neck? y n Penguin Ostrich Tiger Seal Giraffe Zebra

14-18: Another Example R & N show a decision tree for determining whether to wait at a busy restaurant. The problem has the following inputs/attributes: Alternative nearby Has a bar Patrons? None Some Full No Yes WaitEstimate? >60 30-60 10-30 0-10 No Alternate? Hungry? No Yes No Yes Yes Day of week Hungriness Crowd Reservation? No Yes Bar? Yes No Yes Fri/Sat? No Yes No Yes Yes Alternate? No Yes Yes Raining? No Yes Price No Yes No Yes Raining? Reservation Type of restuarant Note that not all attributes are used. Wait estimate

14-19: Trees as rules A decision tree is just a compiled set of rules. We can rewrite each branch of the tree as a clause in which the path to the leaf is on the left, and the leaf is on the right. Wait30 reservation Stay Wait10 30 Hungry Alternate Stay NoPatrons Stay The tree gives us a more efficient way of determining what to do

14-20: An example training set Ex Attributes Target Alt Bar F ri Hun P at $ Rain Res T ype Est Wait? X 1 T F F T Some $$$ F T French 0-10 T X 2 T F F T Full $ F F Thai 30-60 F X 3 F T F F Some $ F F Burger 0-10 T X 4 T F T T Full $ F F Thai 10-30 T X 5 T F T F Full $$$ F T French >60 F X 6 F T F T Some $$ T T Italian 0-10 T X 7 F T F F None $ T F Burger 0-10 F X 8 F F F T Some $$ T T Thai 0-10 T X 9 F T T F Full $ T F Burger >60 F X 10 T T T T Full $$$ F T Italian 10-30 F X 11 F F F F None $ F F Thai 0-10 F X 12 T T T T Full $ F F Burger 30-60 T

14-21: Inducing a decision tree An example is a specific set of attributes, along with a classification (Wait or not) Examples where Wait is true are called positive examples Examples where Wait is false are called negative examples The set of labeled examples is called the training set. We want to have a tree that: Classifies the training set correctly Accurately predicts unseen examples is as small as possible (Occam s razor)

14-22: Inducing a decision tree We want to have a tree that: Classifies the training set correctly Accurately predicts unseen examples is as small as possible (Occam s razor) What if we construct a tree with one leaf for each example? Would that be good? bad? Why?

14-23: Choosing useful attributes Intuitively, we would like to test attributes that split the training set. Questions that tell us whether or not to go to the restaurant. Splitting on restaurant type is not useful - positive and negative examples are still clustered together. Splitting on crowdedness is more effective. 1 3 4 6 8 12 2 5 7 9 10 11 Type? 1 3 4 6 8 12 2 5 7 9 10 11 Patrons? French Italian Thai Burger 1 5 6 10 4 8 2 11 3 12 7 9 7 11 None Some Full 1 3 6 8 4 12 2 5 9 10 No Yes Hungry? No Yes 4 12 (a) (b) 5 9 2 10

14-24: Constructing a decision tree We can construct a decision tree recursively: 1. Base cases: If all examples are positive or negative, we are done. 2. If there are no examples left, then we haven t seen an instance of this classification, so we use the majority classification of the parent. 3. If there are no attributes left to test, then we have instances with the same description, but different classifications. Insufficient description Noisy data, nondeterministic domain Use majority vote 4. Recursive step Else, pick the best attribute to split on and recursively construct subtrees.

14-25: An example tree Patrons? None Some Full Patrons? No Yes Hungry? None Some Full No Yes No Yes WaitEstimate? No Type? >60 30-60 10-30 0-10 French Italian Thai Burger No Alternate? Hungry? Yes Yes No Fri/Sat? Yes No Yes No Yes No Yes Reservation? Fri/Sat? Yes Alternate? No Yes No Yes No Yes Bar? Yes No Yes Yes Raining? No Yes No Yes No Yes No Yes The hand-constructed tree. No Yes The induced tree. Notice that it s simpler and discovers a relationship between Thai food and waiting.

14-26: Making Decisions We can now use this tree to make decisions, or to classify new instances. Suppose we have a new instance:alt = F, Bar = F,Fri = T,Hungry = T, Patrons = Full, Rain = F,Reservations = F,Type = Burger, EstimatedTime = 10 30. We traverse the tree from the root, following the appropriate Full, Hungry, and Type branches. According to the tree, we should wait.

14-27: Choosing an Attribute The key to constructing a compact and efficient decision tree is to effectively choose attributes to test. Intuition: we want to choose tests that will separate our data set into positive and negative examples. We want to measure the amount of information provided by a test. This is a mathematical concept that characterizes the number of bits needed to answer a question or provide a fact.

14-28: Information Example: In the vacuum world, rooms can be either clean or dirty. This requires one bit to represent. What if a room could take on four states? Eight? What if a room could only be in one state? How many bits would we need to represent this?

14-29: Information Theory More formally, let s say there are n possible answers v 1,v 2,...,v n to a question, and each answer has probability P(v n ) of occuring. The information content of the answer to the question is: I = n i=1 P(v i)log 2 P(v i ) For a coin, this is: 1 2 log 2 1 2 + 1 2 log 2 1 2 = 1. Questions with one highly likely anwer will have low information content. (if the coin comes up heads 99/100 of the time, I = 0.08) Information content is also referred to as entropy. This is often used in compression and data transfer algorithms

14-30: Using Information Theory For decision trees, we want to know how valuable each possible test is, or how much information it yields. We can estimate the probabilities of possible answers from the training set. Usually, a single test will not be enough to completely separate positive and negative examples. Instead, we need to think about how much better we ll be after asking a question. This is called the information gain.

14-31: Information Gain If a training set has p positive examples and n negative examples, its entropy is: I( p, n ) = p log p+n p+n p+n 2 p n log p+n p+n 2 n p+n We want to find the attribute that will come the closest to separating the positive and negative examples. We begin by computing the remainder - this is the information still in the data after we test attribute A. Say attribute A can take on v possible values. This test will create v new subsets of data, labeled E 1,E 2,...,E v. The remainder is the weighed sum of the information in each of these subsets.

14-32: Information Gain Information gain can then be quantified as the difference between the original information (before the test) and the new information (after the test). Gain(A) = I( p p+n, n p+n ) Remainder(A) Heuristic: Always choose the attribute with the largest information gain. Question: What kind of search is this?

14-33: Decision tree pseudocode def maketree(dataset) : if all data are in the same class : return a single Node with that classification if there are no attributes left to test: return a single Node with majority classification else : select the attribute that produces the largest information gain split the dataset according to the values of this attribute to create v smaller datasets. create a new Node - each child will be created by calling maketree with one on the v subsets.

14-34: Example Day Outlook Temperature Humidity Wind PlayTennis D1 Sunny Hot High Weak No D2 Sunny Hot High Strong No D3 Overcast Hot High Weak Yes D4 Rain Mild High Weak Yes D5 Rain Cool Normal Weak Yes D6 Rain Cool Normal Strong No D7 Overcast Cool Normal Strong Yes D8 Sunny Mild High Weak No D9 Sunny Cool Normal Weak Yes D10 Rain Mild Normal Weak Yes D11 Sunny Mild Normal Strong Yes D12 Overcast Mild High Strong Yes D13 Overcast Hot Normal Weak Yes D14 Rain Mild High Strong No

14-35: Example Which attribute is the better classifier? S:[9+,5-] E=0.940 S:[9+,5-] E=0.940 Humidity Wind S:[3+,4-] E=0.985 S:[6+,1-] E=0.592 S:[6+,2-] E=0.811 S:[3+,3-] E=1.0 Gain(S, Humidity) = 0.940 - ((7/14)0.985 + (7/14)0.592) = 0.151 Gain(S, Wind) = 0.940 - ((8/14)0.811 + (6/14)1.0) = 0.048

14-36: Noise If there are two examples that have the same attributes but different values, a decision tree will be unable to classify them separately. We say that this data is noisy. Solution: Use majority rule at the parent node.

14-37: Overfitting A common problem is learning algorithms occurs when there are random or anomalous patterns in the data. For example, in the tennis problem, by chance it might turn out that we always play on Tuesdays. The phenomenon of learning quirks in the data is called overfitting. In decision trees, overfitting is dealt with through pruning. Once the tree is generated, we evaluate the significance of each node.

14-38: Pruning Assume that the test provides no information. (null hypothesis) Does the data in the children look significantly different from this assumption? Use a chi-square test. If not, the node is removed and examples moved up to the parent.

14-39: Continuous-valued inputs Decision trees can also be extended to work with integer and continuous-valued inputs. Discretize the range into, for example, < 70 and > 70. Challenge: What value yields the highest information gain? Use a hill-climbing search to find this value.

14-40: Features of Decision Trees Work well with symbolic data Use information gain to determine what questions are most effective at classifying. Greedy search Produce a human-understandable hypothesis Fixes needed to deal with noise or missing data Can represent all Boolean functions

14-41: Uses of Decision Trees Management Automated help systems Microsoft s online help Data mining