11/1/2001CS 638, Fall 2001 Today AI –Decision trees –Rule-based systems.

Slides:



Advertisements
Similar presentations
Artificial Intelligence 12. Two Layer ANNs
Advertisements

COMP3740 CR32: Knowledge Management and Adaptive Systems
Heuristic Search techniques
Software Development Languages and Environments. Programming languages High level languages are problem orientated contain many English words are easier.
Michael Alves, Patrick Dugan, Robert Daniels, Carlos Vicuna
CPSC 502, Lecture 15Slide 1 Introduction to Artificial Intelligence (AI) Computer Science cpsc502, Lecture 15 Nov, 1, 2011 Slide credit: C. Conati, S.
Huffman code and ID3 Prof. Sin-Min Lee Department of Computer Science.
Introduction Training Complexity, Pruning CART vs. ID3 vs. C4.5
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
CS 484 – Artificial Intelligence1 Announcements Choose Research Topic by today Project 1 is due Thursday, October 11 Midterm is Thursday, October 18 Book.
Programming Types of Testing.
Michael Zyda Finite State Machines Michael Zyda
Classification Techniques: Decision Tree Learning
Artificial Intelligence in Game Design Introduction to Learning.
Decision Tree under MapReduce Week 14 Part II. Decision Tree.
Expert System Human expert level performance Limited application area Large component of task specific knowledge Knowledge based system Task specific knowledge.
Machine Learning CPSC 315 – Programming Studio Spring 2009 Project 2, Lecture 5.
10/28/03CS679 - Fall Copyright Univ. of Wisconsin Last Time AI Overview State-machines for AI.
1 Chapter 10 Introduction to Machine Learning. 2 Chapter 10 Contents (1) l Training l Rote Learning l Concept Learning l Hypotheses l General to Specific.
10/30/2001CS 638, Fall 2001 Today AI –Overview –State Machines.
Induction of Decision Trees
1 Chapter 9 Rules and Expert Systems. 2 Chapter 9 Contents (1) l Rules for Knowledge Representation l Rule Based Production Systems l Forward Chaining.
Rules and Expert Systems
Data Mining with Decision Trees Lutz Hamel Dept. of Computer Science and Statistics University of Rhode Island.
Three kinds of learning
Learning decision trees derived from Hwee Tou Ng, slides for Russell & Norvig, AI a Modern Approachslides Tom Carter, “An introduction to information theory.
Learning….in a rather broad sense: improvement of performance on the basis of experience Machine learning…… improve for task T with respect to performance.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Review Rong Jin. Comparison of Different Classification Models  The goal of all classifiers Predicating class label y for an input x Estimate p(y|x)
Part I: Classification and Bayesian Learning
CS Bayesian Learning1 Bayesian Learning. CS Bayesian Learning2 States, causes, hypotheses. Observations, effect, data. We need to reconcile.
Issues with Data Mining
Fall 2004 TDIDT Learning CS478 - Machine Learning.
Machine Learning Chapter 3. Decision Tree Learning
Learning what questions to ask. 8/29/03Decision Trees2  Job is to build a tree that represents a series of questions that the classifier will ask of.
INTRODUCTION TO MACHINE LEARNING. $1,000,000 Machine Learning  Learn models from data  Three main types of learning :  Supervised learning  Unsupervised.
CS-424 Gregory Dudek Today’s outline Administrative issues –Assignment deadlines: 1 day = 24 hrs (holidays are special) –The project –Assignment 3 –Midterm.
Slides for “Data Mining” by I. H. Witten and E. Frank.
Recursion Chapter 7. Chapter Objectives  To understand how to think recursively  To learn how to trace a recursive method  To learn how to write recursive.
Production Systems A production system is –a set of rules (if-then or condition-action statements) –working memory the current state of the problem solving,
Chapter 9 – Classification and Regression Trees
LEARNING DECISION TREES Yılmaz KILIÇASLAN. Definition - I Decision tree induction is one of the simplest, and yet most successful forms of learning algorithm.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology AI – Decision Trees and Rule Systems Spring 2012.
Learning from Observations Chapter 18 Through
Scaling up Decision Trees. Decision tree learning.
Artificial Intelligence in Game Design N-Grams and Decision Tree Learning.
For Wednesday No reading Homework: –Chapter 18, exercise 6.
For Monday No new reading Homework: –Chapter 18, exercises 3 and 4.
CS 8751 ML & KDDDecision Trees1 Decision tree representation ID3 learning algorithm Entropy, Information gain Overfitting.
MACHINE LEARNING 10 Decision Trees. Motivation  Parametric Estimation  Assume model for class probability or regression  Estimate parameters from all.
CS 5751 Machine Learning Chapter 3 Decision Tree Learning1 Decision Trees Decision tree representation ID3 learning algorithm Entropy, Information gain.
Decision Trees Binary output – easily extendible to multiple output classes. Takes a set of attributes for a given situation or object and outputs a yes/no.
Decision Tree Learning
Finite State Machines (FSM) OR Finite State Automation (FSA) - are models of the behaviors of a system or a complex object, with a limited number of defined.
COMP 2208 Dr. Long Tran-Thanh University of Southampton Decision Trees.
CSC 8520 Spring Paula Matuszek DecisionTreeFirstDraft Paula Matuszek Spring,
CSC321: Introduction to Neural Networks and Machine Learning Lecture 15: Mixtures of Experts Geoffrey Hinton.
Artificial Intelligence in Game Design Lecture 20: Hill Climbing and N-Grams.
Machine Learning in Practice Lecture 2 Carolyn Penstein Rosé Language Technologies Institute/ Human-Computer Interaction Institute.
Learning From Observations Inductive Learning Decision Trees Ensembles.
Finite State Machines Logical and Artificial Intelligence in Games Lecture 3a.
10/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Terrain Generation We’re pretty much done with the graphics part of the course.
The Game Development Process: Artificial Intelligence.
DECISION TREES An internal node represents a test on an attribute.
Artificial Intelligence
Ch9: Decision Trees 9.1 Introduction A decision tree:
Supervised Learning Seminar Social Media Mining University UC3M
The Metacircular Evaluator
Machine Learning: Lecture 3
Presentation transcript:

11/1/2001CS 638, Fall 2001 Today AI –Decision trees –Rule-based systems

11/1/2001CS 638, Fall 2001 Classification Our aim is to decide which action to take given the world state Convert this to a classification problem: –The state of the world is a set of attributes (or features) Who I can see, how far away they are, how much energy, … –Given any state, there is one appropriate action Extends to multiple actions at the same time –The action is the class that a world state belongs to Low energy, see the enemy means I should be in the retreat state Classification problems are very well studied

11/1/2001CS 638, Fall 2001 Decision Trees Nodes represent attribute tests –One child for each possible outcome of the test Leaves represent classifications –Can have the same classification for several leaves Classify by descending from root to a leaf –At each node perform the test and descend the appropriate branch –When a leaf is reached return the classification (action) of that leaf Decision tree is a “disjunction of conjunctions of constraints on the attribute values of an instance” –Action if (A and B and C) or (A and ~B and D) or ( … ) … –Retreat if (low health and see enemy) or (low health and hear enemy) or ( … ) …

11/1/2001CS 638, Fall 2001 Handling Simultaneous Actions Treat each output command as a separate classification problem –Given inputs should walk => –Given inputs should turn => –Given inputs should run => –Given inputs should weapon => –Given inputs should fire => Have a separate tree for each command If commands are not independent, need a conflict resolution strategy –Can’t run and stop, for instance

11/1/2001CS 638, Fall 2001 Deciding on Actions Each time the AI is called: –Poll each decision tree for current output –Event driven - only call when state changes Need current value of each input attribute –All sensor inputs describe the state of the world Store the state of the environment –Most recent values for all sensor inputs –Change state upon receipt of a message –Or, check validity when AI is updated –Or, a mix of both (polling and event driven)

11/1/2001CS 638, Fall 2001 Sense, Think, Act Cycle Sense –Gather input sensor changes –Update state with new values Think –Poll each decision tree Act –Execute any changes to actions Sense Think Act

11/1/2001CS 638, Fall 2001 Decision Tree for Quake Just one tree Attributes: E= L= S= D= Actions: Attack, Retreat, Chase, Spawn, Wander Could add additional trees: –If I’m attacking, which weapon should I use? –If I’m wandering, which way should I go? –Much like hierarchical FSMs D? SpawnE? L?S? WanderRetreatAttackL? t tt f ff RetreatChase tf ft

11/1/2001CS 638, Fall 2001 Compare and Contrast Spawn D (-E,-S,-L) Wander -E,-D,-S,-L E -S Attack-E E,-D,-S,-L E Chase -E,-D,S,-L S D S D D Retreat-E E,-D,-S,L L -E Retreat-S -E,-D,S,L Wander-L -E,-D,-S,L Retreat-ES E,-D,S,L Attack-ES E,-D,S,-L E E -E -L S -S L -E E L -L L D

11/1/2001CS 638, Fall 2001 Building Decision Trees Decision trees can be constructed by hand –Think of the questions you would ask to decide what to do –For example: Tonight I can study, play games or sleep. How do I make my decision? But, decision trees are typically learned: –Provide examples: many sets of attribute values and resulting actions –Algorithm then constructs a tree from the examples –Reasoning: We don’t know how to decide on an action, so let the computer do the work –Whose behavior would we wish to learn?

11/1/2001CS 638, Fall 2001 Learning Decision Trees Decision trees are usually learned by induction –Generalize from examples –Induction doesn’t guarantee correct decision trees Bias towards smaller decision trees –Occam’s Razor: Prefer simplest theory that fits the data –Too expensive to find the very smallest decision tree Learning is non-incremental –Need to store all the examples ID3 is the basic learning algorithm –C4.5 is an updated and extended version

11/1/2001CS 638, Fall 2001 Induction If X is true in every example that results in action A, then X must always be true for action A –More examples are better –Errors in examples cause difficulty If X is true in most examples X must always be true ID3 does a good job of handling errors (noise) in examples –Note that induction can result in errors It may just be coincidence that X is true in all the examples Typical decision tree learning determines what tests are always true for each action –Assumes that if those things are true again, then the same action should result

11/1/2001CS 638, Fall 2001 Learning Algorithms Recursive algorithms –Find an attribute test that separates the actions –Divide the examples based on the test –Recurse on the subsets What does it mean to separate? –Ideally, there are no actions that have examples in both sets –Failing that, most actions have most examples in one set –The things to measure is entropy - the degree of homogeneity (or lack of it) in a set Entropy is also important for compression What have we seen before that tries to separate sets? –Why is this different?

11/1/2001CS 638, Fall 2001 Induction requires Examples Where do examples come from? –Programmer/designer provides examples –Capture an expert player’s actions, and the game state, while they play # of examples need depends on difficulty of concept –Difficulty: Number of tests needed to determine the action –More is always better Training set vs. Testing set –Train on most (75%) of the examples –Use the rest to validate the learned decision trees by estimating how well the tree does on examples it hasn’t seen

11/1/2001CS 638, Fall 2001 Decision Tree Advantages Simpler, more compact representation State is recorded in a memory –Create “internal sensors” – Enemy-Recently-Sensed Easy to create and understand –Can also be represented as rules Decision trees can be learned

11/1/2001CS 638, Fall 2001 Decision Tree Disadvantages Decision tree engine requires more coding than FSM –Each tree is “unique” sequence of tests, so little common structure Need as many examples as possible Higher CPU cost - but not much higher Learned decision trees may contain errors

11/1/2001CS 638, Fall 2001 References Mitchell: Machine Learning, McGraw Hill, 1997 Russell and Norvig: Artificial Intelligence: A Modern Approach, Prentice Hall, 1995 Quinlan: Induction of decision trees, Machine Learning 1:81-106, 1986 Quinlan: Combining instance-based and model-based learning,10th International Conference on Machine Learning, 1993 –This is coincidental - I took an AI course from Quinlan in 1993

11/1/2001CS 638, Fall 2001 Rule-Based Systems Decision trees can be converted into rules –Just test the disjunction of conjunctions for each leaf More general rule-based systems let you write the rules explicitly System consists of: –A rule set - the rules to evaluate –A working memory - stores state –A matching scheme - decides which rules are applicable –A conflict resolution scheme - if more than one rule is applicable, decides how to proceed What types of games make the most extensive use of rules?

11/1/2001CS 638, Fall 2001 Rule-Based Systems Structure Rule Memory Working Memory Program Procedural Knowledge Long-term Knowledge Data Declarative Knowledge Short-term Knowledge Match Conflict Resolution Act

11/1/2001CS 638, Fall 2001 AI Cycle Match Conflict Resolution Act Rule instantiations that match working memory Selected Rule Changes to Working Memory Memory Actions Sensing Game

11/1/2001CS 638, Fall 2001 Age of Kings ; The AI will attack once at 1100 seconds and then again ; every 1400 sec, provided it has enough defense soldiers. (defrule (game-time > 1100) =>(attack-now) (enable-timer )) (defrule (timer-triggered 7) (defend-soldier-count >= 12) =>(attack-now) (disable-timer 7) (enable-timer )) Rule Action

11/1/2001CS 638, Fall 2001 Age of Kings What is it doing?(defrule(true)=> (enable-timer ) (disable-self)) (defrule (timer-triggered 4) => (cc-add-resource food 700) (cc-add-resource wood 700) (cc-add-resource gold 700) (disable-timer 4) (enable-timer ) (disable-self) )

11/1/2001CS 638, Fall 2001 Implementing Rule-Based Systems Where does the time go? –90-95% goes to Match Matching all rules against all of working memory each cycle is way too slow Key observation –# of changes to working memory each cycle is small –If conditions, and hence rules, can be associated with changes, then we can make things fast (event driven) Match Conflict Resolution Act Memory

11/1/2001CS 638, Fall 2001 Efficient Special Case If only simple tests in conditions, compile rules into a match net Process changes to working memory Associate changes with tests Expected cost: Linear in the number of changes to working memory R1: If A, B, C, then … Test ATest BTest C R1 Conflict Set R2: If A, B, D, then … Test D R2 Rules: Bit vectors store which tests are true Rules with all tests true go in conflict set

11/1/2001CS 638, Fall 2001 General Case Rules can be arbitrarily complex –In particular: function calls in conditions and actions If we have arbitrary function calls in conditions: –Can’t hash based on changes –Run through rules one at a time and test conditions –Pick the first one that matches (or do something else) –Time to match depends on: Number of rules Complexity of conditions Number of rules that don’t match

11/1/2001CS 638, Fall 2001 Baulders Gate IF Heard([PC],UNDER_ATTACK) Heard([PC],UNDER_ATTACK) !InParty(LastAttackerOf(LastHeardBy(Myself))) !InParty(LastAttackerOf(LastHeardBy(Myself))) Range(LastAttackerOf(LastHeardBy(Myself)),5) Range(LastAttackerOf(LastHeardBy(Myself)),5) !StateCheck(LastAttackerOf(LastHeardBy(Myself)), !StateCheck(LastAttackerOf(LastHeardBy(Myself)), STATE_PANIC) STATE_PANIC) !Class(Myself,FIGHTER_MAGE_THIEF) !Class(Myself,FIGHTER_MAGE_THIEF)THEN RESPONSE #100 RESPONSE #100 EquipMostDamagingMelee() EquipMostDamagingMelee() AttackReevaluate(LastAttackerOf(LastHeardBy(Myself)),30) AttackReevaluate(LastAttackerOf(LastHeardBy(Myself)),30)END

11/1/2001CS 638, Fall 2001 Research Rule-based Systems Allow complex conditions with multiple variables –Function calls in conditions and actions –Can compute many relations using rules Examples: –OPS5, OPS83, CLIPS, ART, ECLIPS, … Laird: “Might be overkill for most of today’s computer game AIs”

11/1/2001CS 638, Fall 2001 Conflict Resolution Strategies What do we do if multiple rules match?

11/1/2001CS 638, Fall 2001 Conflict Resolution Strategies What do we do if multiple rules match? Rule order – pick the first rule that matches –Makes order of loading important – not good for big systems Rule specificity - pick the most specific rule Rule importance – pick rule with highest priority –When a rule is defined, give it a priority number –Forces a total order on the rules – is right 80% of the time –Decide Rule 4 [80] is better than Rule 7 [70] –Decide Rule 6 [85] is better than Rule 5 [75] –Now have ordering between all of them – even if wrong

11/1/2001CS 638, Fall 2001 Basic Idea of Efficient Matching How do we reduce the cost of matching? Save intermediate match information (RETE) –Share intermediate match information between rules –Recompute intermediate information for changes –Requires extra memory for intermediate match information –Scales well to large rule sets Recompute match for rules affected by change (TREAT) –Check changes against rules in conflict set –Less memory than Rete –Doesn’t scale as well to large rule sets Make extensive use of hashing (mapping between memory and tests/rules)

11/1/2001CS 638, Fall 2001 Rule-based System: Good and Bad Advantages –Corresponds to way people often think of knowledge –Very expressive –Modular knowledge Easy to write and debug compared to decision trees More concise than FSM Disadvantages –Can be memory intensive –Can be computationally intensive –Sometimes difficult to debug

11/1/2001CS 638, Fall 2001 References RETE: –Forgy, C. L. Rete: A fast algorithm for the many pattern/many object pattern match problem. Artificial Intelligence, 19(1) 1982, pp TREAT: –Miranker, D. TREAT: A new and efficient match algorithm for AI production systems. Pittman/Morgan Kaufman, 1989