Download presentation
Presentation is loading. Please wait.
1
赵才荣 E-mail:zhaocairong@tongji.edu.cn 同济大学,电子与信息工程学院,智信馆410室
《人工智能原理》课程 第十八章 样例学习 样例学习 赵才荣 同济大学,电子与信息工程学院,智信馆410室 理性的Agent是人工智能方法的核心 通过对Agent从感知外部环境,到实施行动,并最后对外部环境施加影响的全过程,把AI中相互分离的主要领域,如问题求解,知识与推理,合乎逻辑 的行动,不确定知识与推理,学习以及通信、感知与行动等统一在智能Agent这一框架下,形成了一个相互联系的整体。
2
Outline Learning agents Inductive learning Decision tree learning
上海市精品课程 人工智能原理
3
Why is learning important?
So far we have assumed we know how the world works Rules of queens puzzle Rules of chess Knowledge base of logical facts Actions’ preconditions and effects Probabilities in Bayesian networks, MDPs, POMDPs, … Rewards in MDPs At that point “just” need to solve/optimize In the real world this information is often not immediately available AI needs to be able to learn from experience 上海市精品课程 人工智能原理
4
Why is learning important?
Learning is essential for unknown environments, i.e., when designer lacks omniscience Learning is useful as a system construction method, i.e., expose the agent to reality rather than trying to write it down Learning modifies the agent's decision mechanisms to improve performance 上海市精品课程 人工智能原理
5
Different kinds of learning…
Supervised learning: Someone gives us examples and the right answer for those examples We have to predict the right answer for unseen examples Unsupervised learning: We see examples but get no feedback We need to find patterns in the data Reinforcement learning: We take actions and get rewards Have to learn how to get high rewards 上海市精品课程 人工智能原理
6
Learning agents 上海市精品课程 人工智能原理
7
Learning element Design of a learning element is affected by
Which components of the performance element are to be learned What feedback is available to learn these components What representation is used for the components Type of feedback: Supervised learning: correct answers for each example Unsupervised learning: correct answers not given Reinforcement learning: occasional rewards 强化学习:奖惩 上海市精品课程 人工智能原理
8
Inductive learning (归纳学习)
f is the target function An example is a pair (x, f(x)) Problem: find a hypothesis h such that h ≈ f given a training set of examples (This is a highly simplified model of real learning: Ignores prior knowledge Assumes examples are given) 归纳学习 上海市精品课程 人工智能原理
9
Inductive learning method
Construct/adjust h to agree with f on training set (h is consistent if it agrees with f on all examples) E.g., curve fitting: 上海市精品课程 人工智能原理
10
Inductive learning method
Construct/adjust h to agree with f on training set (h is consistent if it agrees with f on all examples) E.g., curve fitting: 上海市精品课程 人工智能原理
11
Inductive learning method
Construct/adjust h to agree with f on training set (h is consistent if it agrees with f on all examples) E.g., curve fitting: 上海市精品课程 人工智能原理
12
Inductive learning method
Construct/adjust h to agree with f on training set (h is consistent if it agrees with f on all examples) E.g., curve fitting: 上海市精品课程 人工智能原理
13
Inductive learning method
Construct/adjust h to agree with f on training set (h is consistent if it agrees with f on all examples) E.g., curve fitting: 上海市精品课程 人工智能原理
14
Inductive learning method
Construct/adjust h to agree with f on training set (h is consistent if it agrees with f on all examples) E.g., curve fitting: Ockham’s razor: prefer the simplest hypothesis consistent with data 上海市精品课程 人工智能原理
15
Learning decision trees
Problem: decide whether to wait for a table at a restaurant, based on the following attributes: Alternate: is there an alternative restaurant nearby? Bar: is there a comfortable bar area to wait in? Fri/Sat: is today Friday or Saturday? Hungry: are we hungry? Patrons: number of people in the restaurant (None, Some, Full) Price: price range ($, $$, $$$) Raining: is it raining outside? Reservation: have we made a reservation? Type: kind of restaurant (French, Italian, Thai (泰国菜), Burger) WaitEstimate: estimated waiting time (0-10, 10-30, 30-60, >60) 学习决策树: 1.是否有替代餐厅 2.等候区是否舒适 3.是周末? 4.饿否? 5.餐厅是否满员 6.价位 7.是否下雨 8.是否预约 9.类型 10.估计等待时间 上海市精品课程 人工智能原理
16
Attribute-based representations
Examples described by attribute values (Boolean, discrete, continuous) E.g., situations where I will/won't wait for a table: Classification of examples is positive (T) or negative (F) 上海市精品课程 人工智能原理
17
Decision trees One possible representation for hypotheses
E.g., here is the “true” tree for deciding whether to wait: 上海市精品课程 人工智能原理
18
Expressiveness Decision trees can express any function of the input attributes. E.g., for Boolean functions, truth table row → path to leaf: Trivially, there is a consistent decision tree for any training set with one path to leaf for each example (unless f nondeterministic in x) but it probably won't generalize to new examples Prefer to find more compact decision trees 上海市精品课程 人工智能原理
19
Hypothesis spaces How many distinct decision trees with n Boolean attributes? = number of Boolean functions = number of distinct truth tables with 2n rows = 22n E.g., with 6 Boolean attributes, there are 18,446,744,073,709,551,616 trees 上海市精品课程 人工智能原理
20
Hypothesis spaces How many distinct decision trees with n Boolean attributes? = number of Boolean functions = number of distinct truth tables with 2n rows = 22n E.g., with 6 Boolean attributes, there are 18,446,744,073,709,551,616 trees How many purely conjunctive hypotheses (e.g., Hungry Rain)? Each attribute can be in (positive), in (negative), or out 3n distinct conjunctive hypotheses More expressive hypothesis space increases chance that target function can be expressed increases number of hypotheses consistent with training set may get worse predictions 上海市精品课程 人工智能原理
21
Decision tree learning
Aim: find a small tree consistent with the training examples Idea: (recursively) choose "most significant" attribute as root of (sub)tree 上海市精品课程 人工智能原理
22
Choosing an attribute Idea: a good attribute splits the examples into subsets that are (ideally) "all positive" or "all negative" Patrons? is a better choice 上海市精品课程 人工智能原理
23
Using information theory
To implement Choose-Attribute in the DTL algorithm Information Content (Entropy): I(P(v1), … , P(vn)) = Σi=1 -P(vi) log2 P(vi) For a training set containing p positive examples and n negative examples: 信息熵 上海市精品课程 人工智能原理
24
Information gain A chosen attribute A divides the training set E into subsets E1, … , Ev according to their values for A, where A has v distinct values. Information Gain (IG) or reduction in entropy from the attribute test: Choose the attribute with the largest IG 信息增益 上海市精品课程 人工智能原理
25
Information gain For the training set, p = n = 6, I(6/12, 6/12) = 1 bit Consider the attributes Patrons and Type (and others too): Patrons has the highest IG of all attributes and so is chosen by the DTL algorithm as the root 上海市精品课程 人工智能原理
26
Example contd. Decision tree learned from the 12 examples:
Substantially simpler than “true” tree---a more complex hypothesis isn’t justified by small amount of data 上海市精品课程 人工智能原理
27
Performance measurement
How do we know that h ≈ f ? Use theorems of computational/statistical learning theory 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 上海市精品课程 人工智能原理
28
Summary Learning needed for unknown environments, lazy designers
Learning agent = performance element + learning element For supervised learning, the aim is to find a simple hypothesis approximately consistent with training examples Decision tree learning using information gain Learning performance = prediction accuracy measured on test set 上海市精品课程 人工智能原理
29
Thank you
Similar presentations