for wednesday read chapter 18, section 7 homework: –chapter 18, exercise 11

46
For Wednesday Read chapter 18, section 7 Homework: Chapter 18, exercise 11

Upload: ethelbert-daniels

Post on 30-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

For Wednesday

• Read chapter 18, section 7• Homework:

– Chapter 18, exercise 11

Page 2: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Program 3

• Any questions?

Page 3: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Inductive Bias

• A hypothesis space that does not not include every possible binary function on the instance space incorporates a bias in the type of concepts it can learn.

• Any means that a concept learning system uses to choose between two functions that are both consistent with the training data is called inductive bias.

Page 4: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Forms of Inductive Bias

• Language bias: – The language for representing concepts defines

a hypothesis space that does not include all possible functions (e.g. conjunctive descriptions).

• Search bias: – The language is expressive enough to represent

all possible functions (e.g. disjunctive normal form) but the search algorithm embodies a preference for certain consistent functions over others (e.g. syntactic simplicity).

Page 5: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Unbiased Learning• For instances described by n attributes each

with m values, there are mn instances and therefore 2m^n possible binary functions.

• For m=2, n=10, there are 3.4 x 1038 functions, of which only 59,049 can be represented by conjunctions (a small percentage indeed!).

• However unbiased learning is futile since if we consider all possible functions then simply memorizing the data without any effective generalization is an option.

Page 6: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Lessons

• Function approximation can be viewed as a search through a pre defined space of hypotheses (a representation language) for a hypothesis which best fits the training data.

• Different learning methods assume different hypothesis spaces or employ different search techniques.

Page 7: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Varying Learning Methods

• Can vary the representation: – Numerical function – Rules or logicial functions – Nearest neighbor (case based)

• Can vary the search algorithm: – Gradient descent – Divide and conquer – Genetic algorithm

Page 8: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Evaluation of Learning Methods• Experimental: Conduct well controlled

experiments that compare various methods on benchmark problems, gather data on their performance (e.g. accuracy, run time), and analyze the results for significant differences.

• Theoretical: Analyze algorithms mathematically and prove theorems about their computational complexity, ability to produce hypotheses that fit the training data, or number of examples needed to produce a hypothesis that accurately generalizes to unseen data (sample complexity).

Page 9: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Empirical Evaluation

• Training and Testing• Leave-One-Out• Cross-validation• Learning Curves

Page 10: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Decision Trees

• Classifiers for instances represented as feature vectors

• Nodes test features, there is one branch for each value of the feature, and leaves specify categories.

• Can represent arbitrary disjunction and conjunction and therefore can represent any discrete function on discrete features.

Page 11: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Handle Disjunction

• Can categorize instances into multiple disjoint categories.

• Can be rewritten as rules in disjunctive normal form (DNF) red Ù circle ® pos

red Ù circle ® A

blue ® B; red Ù square ® B

green ® C; red Ù triangle ® C

Page 12: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Decision Tree Learning

• Instances are represented as attribute value pairs.

• Discrete values are simplest, thresholds on numerical features are also possible for splitting nodes.

• Output is a discrete category. Real valued outputs are possible with additions (regression trees).

Page 13: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Decision Tree Learning cont.

• Algorithms are efficient for processing large amounts of data.

• Methods are available for handling noisy data (category and attribute noise).

• Methods are available for handling missing attribute values.

Page 14: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Basic Decision Tree Algorithm DTree(examples, attributes)

If all examples are in one category, return a leaf node with this category as a label.

Else if attributes are empty then return a leaf node labelled with the category which is most common in examples.

Else Pick an attribute, A, for the root.

For each possible value v i for A

Let examples i be the subset of examples that have value v i for A.

Add a branch out of the root for the test A=v i .

If examples i is empty then

Create a leaf node labelled with the category which is most common in examples

Else recursively create a subtree by calling

DTree(examples i , attributes {A})

Page 15: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Picking an Attribute to Split On

• Goal is to have the resulting decision tree be as small as possible, following Occam's Razor.

• Finding a minimal decision tree consistent with a set of data is NP hard.

• Simple recursive algorithm does a greedy heuristic search for a fairly simple tree but cannot guarantee optimality.

Page 16: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

What Is a Good Test?

• Want a test which creates subsets which are relatively “pure” in one class so that they are closer to being leaf nodes.

• There are various heuristics for picking a good test, the most popular one based on information gain (mutual information) originated with ID3 system of Quinlan (1979)

Page 17: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Entropy

• Entropy (impurity, disorder) of a set of examples,S, relative to a binary classification is:

Entropy(S) = -p+log2(p+) - p-log2(p-)

where p+ is the proportion of positive examples in S and p is the proportion of negatives.

• If all examples belong to the same category, entropy is 0 (by definition 0log(0) is defined to be 0).

• If examples are equally mixed (p + =p = 0.5) then entropy is a maximum at 1.0.

Page 18: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

• Entropy can be viewed as the number of bits required on average to encode the class of an example in S, where data compression (e.g Huffman coding) is used to give shorter codes to more likely cases.

• For multiple category problems with c categories, entropy generalizes to:

Entropy(S) = -pilog2(pi)

where pi is proportion of category i examples in S.

Page 19: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Information Gain

• The information gain of an attribute is the expected reduction in entropy caused by partitioning on this attribute:

Gain(S,A) = Entropy(S) - (|Sv|/|S|) Entropy(Sv)

where Sv is the subset of S for which attribute A has value v and the entropy of the partitioned data is calculated by weighting the entropy of each partition by its size relative to the original set.

Page 20: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Information Gain Example

• Example: big, red, circle: + small, red, circle: + small, red, square: big, blue, circle:

• Split on size:– big: 1+, 1-, E = 1– small: 1+, 1-, E = 1– gain = 1 - ((.5)1 + (.5)1) = 0

• Split on color:– red: 2+, 1-, E = 0.918– blue: 0+, 1-, E = 0– gain = 1 - ((.75)0.918 +

(.25)0) = 0.311

• Split on shape:– circle: 2+, 1-, E = 0.918– square: 0+, 1-, E = 0– gain = 1 - ((.75)0.918 +

(.25)0) = 0.311

Page 21: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Hypothesis Space in Decision Tree Induction

• Conducts a search of the space of decision trees which can represent all possible discrete functions.

• Creates a single discrete hypothesis consistent with the data, so there is no way to provide confidences or create useful queries.

Page 22: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Algorithm Characteristics

• Performs hill climbing search so may find a locally optimal solution. Guaranteed to find a tree that fits any noise free training set, but it may not be the smallest.

• Performs batch learning. Bases each decision on a batch of examples and can terminate early to avoid fitting noisy data.

Page 23: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Bias

• Bias is for trees of minimal depth; however, greedy search introduces a complication that it may not find the minimal tree and positions features with high information gain high in the tree.

• Implements a preference bias (search bias) as opposed to a restriction bias (language bias) like candidate elimination.

Page 24: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Simplicity• Occam's razor can be defended on the basis that

there are relatively few simple hypotheses compared to complex ones, therefore, a simple hypothesis that is consistent with the data is less likely to be a statistical coincidence than finding a complex, consistent hypothesis.

• However, – Simplicity is relative to the hypothesis language used. – This is an argument for any small hypothesis space and

holds equally well for a small space of arcane complex hypotheses, e.g. decision trees with exactly 133 nodes where attributes along every branch are ordered alphabetically from root to leaf.

Page 25: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Overfitting• Learning a tree that classifies the training data

perfectly may not lead to the tree with the best generalization performance since – There may be noise in the training data that the tree is

fitting. – The algorithm might be making some decisions toward

the leaves of the tree that are based on very little data and may not reflect reliable trends in the data.

• A hypothesis, h, is said to overfit the training data if there exists another hypothesis, h’, such that h has smaller error than h’ on the training data but h’ has smaller error on the test data than h.

Page 26: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Overfitting and Noise• Category or attribute noise can cause overfitting. • Add noisy instance:

– <<medium, green, circle>, +> (really )

• Noise can also cause directly conflicting examples with same description and different class. Impossible to fit this data and must label leaf with majority category. – <<big, red, circle>, > (really +)

• Conflicting examples can also arise if attributes are incomplete and inadequate to discriminate the categories.

Page 27: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Avoiding Overfitting

• Two basic approaches – Prepruning: Stop growing the tree at some

point during construction when it is determined that there is not enough data to make reliable choices.

– Postpruning: Grow the full tree and then remove nodes that seem to not have sufficient evidence.

Page 28: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Evaluating Subtrees to Prune

• Cross validation: – Reserve some of the training data as a hold out set

(validation set, tuning set) to evaluate utility of subtrees.

• Statistical testing: – Perform some statistical test on the training data to

determine if any observed regularity can be dismissed as likely to to random chance.

• Minimum Description Length (MDL): – Determine if the additional complexity of the

hypothesis is less complex than just explicitly remembering any exceptions.

Page 29: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Learning Theory• Theorems that characterize classes of learning problems or

specific algorithms in terms of computational complexity or sample complexity, i.e. the number of training examples necessary or sufficient to learn hypotheses of a given accuracy.

• Complexity of a learning problem depends on:– Size or expressiveness of the hypothesis space.– Accuracy to which target concept must be approximated.– Probability with which the learner must produce a successful

hypothesis.– Manner in which training examples are presented, e.g. randomly

or by query to an oracle.

Page 30: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Types of Results• Learning in the limit: Is the learner guaranteed to

converge to the correct hypothesis in the limit as the number of training examples increases indefinitely?

• Sample Complexity: How many training examples are needed for a learner to construct (with high probability) a highly accurate concept?

• Computational Complexity: How much computational resources (time and space) are needed for a learner to construct (with high probability) a highly accurate concept?– High sample complexity implies high computational complexity,

since learner at least needs to read the input data.• Mistake Bound: Learning incrementally, how many

training examples will the learner misclassify before constructing a highly accurate concept.

Page 31: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Learning in the Limit• Given a continuous stream of examples where the learner

predicts whether each one is a member of the concept or not and is then is told the correct answer, does the learner eventually converge to a correct concept and never make a mistake again?

• No limit on the number of examples required or computational demands, but must eventually learn the concept exactly.

• By simple enumeration, concepts from any known finite hypothesis space are learnable in the limit, although typically requires an exponential (or doubly exponential) number of examples and time.

• Class of total recursive (Turing computable) functions is not learnable in the limit.

Page 32: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Learning in the Limit vs.PAC Model

• Learning in the limit model is too strong.– Requires learning correct exact concept

• Learning in the limit model is too weak– Allows unlimited data and computational resources.

• PAC Model– Only requires learning a Probably Approximately

Correct Concept: Learn a decent approximation most of the time.

– Requires polynomial sample complexity and computational complexity.

Page 33: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Cannot Learn Exact Conceptsfrom Limited Data, Only Approximations

Negative

Learner Classifier

Positive

Negative

Positive

Page 34: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Cannot Learn Even Approximate Conceptsfrom Pathological Training Sets

Learner ClassifierNegative

Positive

NegativePositive

Page 35: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

PAC Learning

• The only reasonable expectation of a learner is that with high probability it learns a close approximation to the target concept.

• In the PAC model, we specify two small parameters, ε and δ, and require that with probability at least (1 δ) a system learn a concept with error at most ε.

Page 36: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Formal Definition of PAC-Learnable• Consider a concept class C defined over an instance space X

containing instances of length n, and a learner, L, using a hypothesis space, H.

• C is said to be PAC-learnable by L using H iff for all cC, distributions D over X, 0<ε<0.5, 0<δ<0.5; learner L by sampling random examples from distribution D, will with probability at least 1 δ output a hypothesis hH such that errorD(h) ε, in time polynomial in 1/ε, 1/δ, n and size(c).

• Example:– X: instances described by n binary features– C: conjunctive descriptions over these features– H: conjunctive descriptions over these features– L: most-specific conjunctive generalization algorithm (Find-S)– size(c): the number of literals in c (i.e. length of the conjunction).

Page 37: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Issues of PAC Learnability• The computational limitation also imposes a

polynomial constraint on the training set size, since a learner can process at most polynomial data in polynomial time.

• How to prove PAC learnability:– First, prove sample complexity of learning C using H is

polynomial.– Second, prove that the learner can train on a

polynomial-sized data set in polynomial time.• To be PAC-learnable, there must be a hypothesis

in H with arbitrarily small error for every concept in C, generally CH.

Page 38: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Version Space

• Bounds on generalizations of a set of examples

Page 39: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Consistent Learners• A learner L using a hypothesis H and training data

D is said to be a consistent learner if it always outputs a hypothesis with zero error on D whenever H contains such a hypothesis.

• By definition, a consistent learner must produce a hypothesis in the version space for H given D.

• Therefore, to bound the number of examples needed by a consistent learner, we just need to bound the number of examples needed to ensure that the version-space contains no hypotheses with unacceptably high error.

Page 40: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

ε-Exhausted Version Space• The version space, VSH,D, is said to be ε-exhausted iff every

hypothesis in it has true error less than or equal to ε.• In other words, there are enough training examples to

guarantee than any consistent hypothesis has error at most ε.• One can never be sure that the version-space is ε-exhausted,

but one can bound the probability that it is not.• Theorem 7.1 (Haussler, 1988): If the hypothesis space H is

finite, and D is a sequence of m1 independent random examples for some target concept c, then for any 0 ε 1, the probability that the version space VSH,D is not ε-exhausted is less than or equal to:

|H|e–εm

Page 41: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Sample Complexity Analysis• Let δ be an upper bound on the probability of not

exhausting the version space. So:

/ln1

ln

/ln

)inequality (flip /ln

)ln(

)),(consist(

Hm

Hm

Hm

Hm

He

eHDHP

m

mbad

Page 42: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Sample Complexity Result• Therefore, any consistent learner, given at least:

examples will produce a result that is PAC.• Just need to determine the size of a hypothesis space to

instantiate this result for learning specific classes of concepts.

• This gives a sufficient number of examples for PAC learning, but not a necessary number. Several approximations like that used to bound the probability of a disjunction make this a gross over-estimate in practice.

/ln1

ln

H

Page 43: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Sample Complexity of Conjunction Learning• Consider conjunctions over n boolean features. There are 3n of these

since each feature can appear positively, appear negatively, or not appear in a given conjunction. Therefore |H|= 3n, so a sufficient number of examples to learn a PAC concept is:

• Concrete examples:– δ=ε=0.05, n=10 gives 280 examples– δ=0.01, ε=0.05, n=10 gives 312 examples– δ=ε=0.01, n=10 gives 1,560 examples– δ=ε=0.01, n=50 gives 5,954 examples

• Result holds for any consistent learner.

/3ln1

ln/3ln1

ln

nn

Page 44: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

Sample Complexity of LearningArbitrary Boolean Functions

• Consider any boolean function over n boolean features such as the hypothesis space of DNF or decision trees. There are 22^n of these, so a sufficient number of examples to learn a PAC concept is:

• Concrete examples:– δ=ε=0.05, n=10 gives 14,256 examples– δ=ε=0.05, n=20 gives 14,536,410 examples– δ=ε=0.05, n=50 gives 1.561x1016 examples

/2ln21

ln/2ln1

ln 2

nn

Page 45: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

COLT Conclusions

• The PAC framework provides a theoretical framework for analyzing the effectiveness of learning algorithms.

• The sample complexity for any consistent learner using some hypothesis space, H, can be determined from a measure of its expressiveness |H| or VC(H), quantifying bias and relating it to generalization.

• If sample complexity is tractable, then the computational complexity of finding a consistent hypothesis in H governs its PAC learnability.

• Constant factors are more important in sample complexity than in computational complexity, since our ability to gather data is generally not growing exponentially.

• Experimental results suggest that theoretical sample complexity bounds over-estimate the number of training instances needed in practice since they are worst-case upper bounds.

Page 46: For Wednesday Read chapter 18, section 7 Homework: –Chapter 18, exercise 11

COLT Conclusions (cont)• Additional results produced for analyzing:

– Learning with queries– Learning with noisy data– Average case sample complexity given assumptions about the data

distribution.– Learning finite automata– Learning neural networks

• Analyzing practical algorithms that use a preference bias is difficult.

• Some effective practical algorithms motivated by theoretical results:– Winnow– Boosting– Support Vector Machines (SVM)