Docsity

Learning, learning Agents, Supervised Learning - Slides | CS 662, Study notes of Computer Science

Toggle sidebar
bg1
Artificial Intelligence Programming
Decision Trees
Chris Brooks
Department of Computer Science
University of San Francisco
Departmentof Computer Science —University of San Francisco – p.1/??
13-0: Learning
What does it mean for an agent to learn?
Departmentof Computer Science —University of San Francisco – p.2/??
13-1: 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
Departmentof Computer Science —University of San Francisco – p.3/??
13-2: Learning Agents
Recall that at the beginning of the semester we talked
about learning agents
Performance standard
Agent
Environment
Sensors
Performance
element
changes
knowledge
learning
goals
Problem
generator
feedback
Learning
element
Critic
Actuators
Departmentof Computer Science —University of San Francisco – p.4/??
13-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.
Departmentof Computer Science —University of San Francisco – p.5/??
13-4: Types of Learning Tasks
There are essentially three categories of learning tasks,
each of which provides different feedback.
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.
Departmentof Computer Science —University of San Francisco – p.6/??
pf3
pf4
pf5

Partial preview of the text

Download Learning, learning Agents, Supervised Learning - Slides | CS 662 and more Study notes Computer Science in PDF only on Docsity!

Artificial Intelligence Programming

Decision Trees

Chris Brooks Department of Computer Science University of San Francisco ?? Department of Computer Science — University of San Francisco – p.1/

Learning 13-0:

What does it mean for an agent to learn? ?? Department of Computer Science — University of San Francisco – p.2/

Learning 13-1:

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 ?? Department of Computer Science — University of San Francisco – p.3/

Learning Agents 13-2:

Recall that at the beginning of the semester we talked learning agents about Performance standard Agent Environment Sensors element Performance changes knowledge goalslearning Problemgenerator feedback element Learning Critic Actuators ?? Department of Computer Science — University of San Francisco – p.4/

Learning Agents 13-3:

and a performance element A learning agent has 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. . feedback This information is called

Types of Learning Tasks 13-4:

There are essentially three categories of learning tasks, each of which provides different feedback. Supervised learning. In this case, an external source (often called a teacher) labeled examples provides the agent with Agent sees specific actions/cases, along with their classification.

Types of Learning Tasks 13-5:

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 Reinforcement Learning This is a particular version of learning in which the for taking an action. reward agent only receives a May not know how optimal a reward is. Will not know the “best” action to take ?? Department of Computer Science — University of San Francisco – p.7/

Supervised Learning 13-6:

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 process of learning general rules from specific facts

. induction is called ?? Department of Computer Science — University of San Francisco – p.8/

Defining the Learning Problem 13-7:

We can phrase the learning problem as that of estimating that tells us how to classify a set of inputs. f a function and the corresponding x An example is a set of inputs )x( f << M ammal, EatsM eat, BlackStripes, T awny >, T iger > We can define the learning task as follows: H , find a function f Given a collection of examples of for our examples. f that approximates

. hypothesis is called a H ?? Department of Computer Science — University of San Francisco – p.9/

Induction 13-8:

generalize to H We would like will correctly classify unseen H This means that examples. If the hypothesis can correctly classify all of the training hypothesis. consistent examples, we call it a Goal: find a consistent hypothesis that also performs well on unseen examples. We can think of learning as search through a space of hypotheses. ?? Department of Computer Science — University of San Francisco – p.10/

Inductive Bias 13-9:

Notice that induction is not sound. In picking a hypothesis, we make an educated guess.

. bias the way in which we make this guess is called a All learning lagorithms 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 ?? Department of Computer Science — University of San Francisco – p.11/

Observing Data 13-10:

Agents may have different means of observing examples of a hypothesis. learning algorithm is presented with a large set of batch A data all at once and selects a single hypothesis. learning algorithm receives examples one incremental An at a time and continually modifies its hypothesis. Batch is typically more accurate, but incremental may fit better with the agent’s environment. learning agent is able to choose examples. active An learning agent has examples presented to it by passive A an outside source. Active learning is more powerful, but may not fit with ?? Department of Computer Science — University of San Francisco – p.12/ the constraints of the domain.

Constructing a decision tree 13-17:

We can construct a decision tree recursively:

  1. If all examples are positve 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. Else, pick the best attribute to split on and recursively construct subtrees. ?? Department of Computer Science — University of San Francisco – p.19/

An example tree 13-18:

Yes No Yes No Yes No Yes No Full Some None 0-10 10-30 30-60 > Alternate? Yes^ No Hungry? Reservation? Raining? Bar? Alternate? Patrons? Fri/Sat? Yes No Yes No Yes Yes No Yes Yes No Yes No YesYes^ No Yes No WaitEstimate? hand-constructed The tree. Full Some None Patrons? Yes (^) Hungry? No Yes No No Yes Fri/Sat? No Yes No Yes Type? Burger Thai Italian French No Yes Notice The induced tree. that it’s simpler and dis- covers a relationship be- tween Thai food and wait- ing. ?? Department of Computer Science — University of San Francisco – p.20/

Choosing an Attribute 13-19:

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. provided information We want to measure the amount of by a test. This is a mathematical concept that characterizes the number of bits needed to answer a question or provide a fact. ?? Department of Computer Science — University of San Francisco – p.21/

Choosing an Attribute 13-20:

Example: let’s say I’m trying to predict the flip of a coin. Before the flip, one bit (heads/tails) is enough to completely answer the question. After I’ve seen the coin, additional bits contain no information, since they don’t provide new knowledge. ?? Department of Computer Science — University of San Francisco – p.22/

Information Theory 13-21:

possible answers n More formally, let’s say there are to a question, and each answer has probability^ n , ..., v^2 , v^1 v of occuring. )nv( P of the answer to the question is: information content The

= I

n∑ )iv( P^2 log)iv( P−^ =1i

. = 1^122 log^12 − +^122 log^12 − For a coin, this is: 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 sometimes called entropy. This is often used in compression and data transfer algorithms

Using Information Theory 13-22:

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.

. information gain This is called the

Information Gain 13-23:

negative n positive examples and p If a training set has examples, the information in a correct answer is: nn+ p (^2) log nn+ p − np+ p (^2) log np+ p − ) = nn+ p , np+ p ( I 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 .A information still in the data after we test attribute possible values. This test v can take on A Say attribute

.^ v , ..., E^2 , E^1 E new subsets of data, labeled v will create The remainder is the sum of the information in each of these subsets. ) =A( Remainder v ∑ =1i in+i p (I ∗^ n+^ p ip ,^ in+i^ p in )^ in+i^ p ?? Department of Computer Science — University of San Francisco – p.25/

Information Gain 13-24:

Information gain can then be quantified as the difference between the original information (before the test) and the new information (after the test). )A( Remainder − )^ nn+^ p ,^ np+^ p (I ) =A( Gain Heuristic: Always choose the attribute with the largest information gain. Question: What kind of search is this? ?? Department of Computer Science — University of San Francisco – p.26/

Example 13-25:

PlayTennis Wind Humidity Temperature Outlook Day No Weak High Hot Sunny D No Strong High Hot Sunny D Yes Weak High Hot Overcast D Yes Weak High Mild Rain D Yes Weak Normal Cool Rain D No Strong Normal Cool Rain D Yes Strong Normal Cool Overcast D No Weak High Mild Sunny D Yes Weak Normal Cool Sunny D Yes Weak Normal Mild Rain D Yes Strong Normal Mild Sunny D Yes Strong High Mild Overcast D Yes Weak Normal Hot Overcast D No Strong High Mild Rain D ?? Department of Computer Science — University of San Francisco – p.27/

Example 13-26:

Which attribute is the best classifier? Normal High Humidity [6+,1-] [3+,4-] Wind Strong Weak [3+,3-] [6+,2-] = .940 - (8/14).811 - (6/14)1.0= .048^ = .940 - (7/14).985 - (7/14).592=. ) Wind Gain (S, ) Gain (S, Humidity =0.940 E =0.940 E =1.00 E =0.811 E =0.592 E =0.985 E [9+,5-] S: [9+,5-] S: ?? Department of Computer Science — University of San Francisco – p.28/

Noise 13-27:

If there are two examples that have the same attributes but different values, a decision tree will be unable to classify them separately.

. noisy We say that this data is Solution: Use majority rule at the parent node.

Overfitting 13-28:

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.