cs 380: artificial intelligence machine learning
TRANSCRIPT
![Page 1: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/1.jpg)
CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING
11/11/2013 Santiago Ontañón [email protected] https://www.cs.drexel.edu/~santi/teaching/2013/CS380/intro.html
![Page 2: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/2.jpg)
Summary so far: • Rational Agents
• Problem Solving • Systematic Search:
• Uninformed • Informed
• Local Search • Adversarial Search
• Logic and Knowledge Representation • Predicate Logic • First-order Logic
• Today: Machine Learning
![Page 3: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/3.jpg)
What is Learning?
![Page 4: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/4.jpg)
Machine Learning • Computational methods for computers to exhibit specific forms of learning. For example:
• Learning from Examples: • Supervised learning • Unsupervised learning
• Reinforcement Learning
• Learning from Observation (demonstration/imitation)
![Page 5: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/5.jpg)
Examples • Supervised Learning: learning to recognize writing
![Page 6: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/6.jpg)
Examples • Unsupervised Learning: clustering observations into
meaningful classes
![Page 7: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/7.jpg)
Examples • Reinforcement Learning: learning to walk
![Page 8: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/8.jpg)
Examples • Learning from demonstration: performing tasks that
other agents (or humans) can do
![Page 9: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/9.jpg)
Learning
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
Chapter 18, Sections 1–3 3
![Page 10: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/10.jpg)
Learning agents
Performance standard
Agent
EnvironmentSensors
Effectors
Performance element
changes
knowledgelearning goals
Problem generator
feedback
Learning element
Critic
experiments
Chapter 18, Sections 1–3 4
![Page 11: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/11.jpg)
Learning element
Design of learning element is dictated by♦ what type of performance element is used♦ which functional component is to be learned♦ how that functional compoent is represented♦ what kind of feedback is available
Example scenarios:
Performance element
Alpha−beta search
Logical agent
Simple reflex agent
Component
Eval. fn.
Transition model
Transition model
Representation
Weighted linear function
Successor−state axioms
Neural net
Dynamic Bayes netUtility−based agent
Percept−action fn
Feedback
Outcome
Outcome
Win/loss
Correct action
Supervised learning: correct answers for each instanceReinforcement learning: occasional rewards
Chapter 18, Sections 1–3 5
![Page 12: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/12.jpg)
Inductive learning (a.k.a. Science)
Simplest form: learn a function from examples (tabula rasa)
f is the target function
An example is a pair x, f(x), e.g.,O O X
XX
, +1
Problem: find a(n) hypothesis hsuch that h ≈ fgiven a training set of examples
(This is a highly simplified model of real learning:– Ignores prior knowledge
– Assumes a deterministic, observable “environment”– Assumes examples are given
– Assumes that the agent wants to learn f—why?)
Chapter 18, Sections 1–3 6
![Page 13: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/13.jpg)
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:
x
f(x)
Chapter 18, Sections 1–3 7
![Page 14: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/14.jpg)
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:
x
f(x)
Chapter 18, Sections 1–3 8
![Page 15: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/15.jpg)
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:
x
f(x)
Chapter 18, Sections 1–3 9
![Page 16: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/16.jpg)
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:
x
f(x)
Chapter 18, Sections 1–3 10
![Page 17: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/17.jpg)
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:
x
f(x)
Chapter 18, Sections 1–3 11
![Page 18: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/18.jpg)
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:
x
f(x)
Ockham’s razor: maximize a combination of consistency and simplicity
Chapter 18, Sections 1–3 12
![Page 19: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/19.jpg)
Attribute-based representations
Examples described by attribute values (Boolean, discrete, continuous, etc.)E.g., situations where I will/won’t wait for a table:
Example Attributes TargetAlt Bar Fri Hun Pat Price Rain Res Type Est WillWait
X1 T F F T Some $$$ F T French 0–10 T
X2 T F F T Full $ F F Thai 30–60 F
X3 F T F F Some $ F F Burger 0–10 TX4 T F T T Full $ F F Thai 10–30 T
X5 T F T F Full $$$ F T French >60 F
X6 F T F T Some $$ T T Italian 0–10 TX7 F T F F None $ T F Burger 0–10 F
X8 F F F T Some $$ T T Thai 0–10 TX9 F T T F Full $ T F Burger >60 F
X10 T T T T Full $$$ F T Italian 10–30 F
X11 F F F F None $ F F Thai 0–10 FX12 T T T T Full $ F F Burger 30–60 T
Classification of examples is positive (T) or negative (F)
Chapter 18, Sections 1–3 13
![Page 20: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/20.jpg)
Decision trees
One possible representation for hypothesesE.g., here is the “true” tree for deciding whether to wait:
No Yes
No Yes
No Yes
No Yes
No Yes
No Yes
None Some Full
>60 30−60 10−30 0−10
No YesAlternate?
Hungry?
Reservation?
Bar? Raining?
Alternate?
Patrons?
Fri/Sat?
WaitEstimate?F T
F T
T
T
F T
TFT
TF
Chapter 18, Sections 1–3 14
![Page 21: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/21.jpg)
Expressiveness
Decision trees can express any function of the input attributes.E.g., for Boolean functions, truth table row → path to leaf:
FT
A
B
F T
B
A B A xor BF F FF T TT F TT T F
F
F F
T
T T
Trivially, there is a consistent decision tree for any training setw/ 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
Chapter 18, Sections 1–3 15
![Page 22: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/22.jpg)
Hypothesis spaces
How many distinct decision trees with n Boolean attributes??
Chapter 18, Sections 1–3 16
![Page 23: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/23.jpg)
Hypothesis spaces
How many distinct decision trees with n Boolean attributes??
= number of Boolean functions
Chapter 18, Sections 1–3 17
![Page 24: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/24.jpg)
Hypothesis spaces
How many distinct decision trees with n Boolean attributes??
= number of Boolean functions= number of distinct truth tables with 2n rows
Chapter 18, Sections 1–3 18
![Page 25: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/25.jpg)
Hypothesis spaces
How many distinct decision trees with n Boolean attributes??
= number of Boolean functions= number of distinct truth tables with 2n rows = 22n
Chapter 18, Sections 1–3 19
![Page 26: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/26.jpg)
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
Chapter 18, Sections 1–3 20
![Page 27: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/27.jpg)
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)??
Chapter 18, Sections 1–3 21
![Page 28: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/28.jpg)
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 w/ training set
⇒ may get worse predictions
Chapter 18, Sections 1–3 22
![Page 29: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/29.jpg)
Decision tree learning
Aim: find a small tree consistent with the training examples
Idea: (recursively) choose “most significant” attribute as root of (sub)tree
function DTL(examples, attributes, default) returns a decision tree
if examples is empty then return default
else if all examples have the same classification then return the classificationelse if attributes is empty then return Mode(examples)else
best←Choose-Attribute(attributes, examples)tree← a new decision tree with root test best
for each value vi of best do
examplesi← {elements of examples with best = vi}subtree←DTL(examplesi,attributes− best,Mode(examples))add a branch to tree with label vi and subtree subtree
return tree
Chapter 18, Sections 1–3 23
![Page 30: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/30.jpg)
Choosing an attribute
Idea: a good attribute splits the examples into subsets that are (ideally) “allpositive” or “all negative”
None Some Full
Patrons?
French Italian Thai Burger
Type?
Patrons? is a better choice—gives information about the classification
Chapter 18, Sections 1–3 24
![Page 31: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/31.jpg)
Information
Information answers questions
The more clueless I am about the answer initially, the more information iscontained in the answer
Scale: 1 bit = answer to Boolean question with prior ⟨0.5, 0.5⟩
Information in an answer when prior is ⟨P1, . . . , Pn⟩ is
H(⟨P1, . . . , Pn⟩) = Σni =1 − Pi log2 Pi
(also called entropy of the prior)
Chapter 18, Sections 1–3 25
![Page 32: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/32.jpg)
Information contd.
Suppose we have p positive and n negative examples at the root⇒ H(⟨p/(p+n), n/(p+n)⟩) bits needed to classify a new example
E.g., for 12 restaurant examples, p = n = 6 so we need 1 bit
An attribute splits the examples E into subsets Ei, each of which (we hope)needs less information to complete the classification
Let Ei have pi positive and ni negative examples⇒ H(⟨pi/(pi+ni), ni/(pi+ni)⟩) bits needed to classify a new example⇒ expected number of bits per example over all branches is
Σipi + ni
p + nH(⟨pi/(pi + ni), ni/(pi + ni)⟩)
For Patrons?, this is 0.459 bits, for Type this is (still) 1 bit
⇒ choose the attribute that minimizes the remaining information needed
Chapter 18, Sections 1–3 26
![Page 33: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/33.jpg)
Example contd.
Decision tree learned from the 12 examples:
No YesFri/Sat?
None Some Full
Patrons?
No YesHungry?
Type?
French Italian Thai Burger
F T
T F
F
T
F T
Substantially simpler than “true” tree—a more complex hypothesis isn’t jus-tified by small amount of data
Chapter 18, Sections 1–3 27
![Page 34: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/34.jpg)
Performance measurement
How do we know that h ≈ f? (Hume’s Problem of Induction)
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
0.40.50.60.70.80.9
1
0 10 20 30 40 50 60 70 80 90 100
% c
orre
ct o
n te
st s
et
Training set size
Chapter 18, Sections 1–3 28
![Page 35: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/35.jpg)
Performance measurement contd.
Learning curve depends on– realizable (can express target function) vs. non-realizable
non-realizability can be due to missing attributesor restricted hypothesis class (e.g., thresholded linear function)
– redundant expressiveness (e.g., loads of irrelevant attributes)
% correct
# of examples
1
nonrealizableredundant
realizable
Chapter 18, Sections 1–3 29
![Page 36: CS 380: ARTIFICIAL INTELLIGENCE MACHINE LEARNING](https://reader030.vdocuments.net/reader030/viewer/2022012410/616a674011a7b741a3521e01/html5/thumbnails/36.jpg)
Summary
Learning needed for unknown environments, lazy designers
Learning agent = performance element + learning element
Learning method depends on type of performance element, availablefeedback, type of component to be improved, and its representation
For supervised learning, the aim is to find a simple hypothesisthat is approximately consistent with training examples
Decision tree learning using information gain
Learning performance = prediction accuracy measured on test set
Chapter 18, Sections 1–3 30