Concept Learning - QB - Solutions
Concept Learning - QB - Solutions
CONCEPT LEARNING
1. Define concept learning and discuss with example.
Solution:
▪ Learning involves acquiring general concepts from specific training examples. Example: People
continually learn general concepts or categories such as "bird," "car," "situations in which I should
study more in order to pass the exam," etc.
▪ Each such concept can be viewed as describing some subset of objects or events defined over a
larger set
▪ Alternatively, each concept can be thought of as a Boolean-valued function defined over this larger
set. (Example: A function defined over all animals, whose value is true for birds and false for other
animals).
Concept learning - Inferring a Boolean-valued function from training examples of its input and
output
The attribute EnjoySport indicates whether or not a Person enjoys his favorite water sport on this day.
The task is to learn to predict the value of EnjoySport for an arbitrary day, based on the values of its otherattributes ?
If some instance x satisfies all the constraints of hypothesis h, then h classifies x as a positive example (h(x)
= 1).
The hypothesis that PERSON enjoys his favorite sport only on cold days with high humidity (independent
of the values of the other attributes) is represented by the expression
(?, Cold, High, ?, ?, ?)
The most general hypothesis-that every day is a positive example-is represented by
(?, ?, ?, ?, ?, ?)
Example: X is the set of all possible days, each represented by the attributes: Sky, AirTemp, Humidity,
Wind, Water, and Forecast
• Concept learning can be viewed as the task of searching through a large space of hypotheses
implicitly defined by the hypothesis representation.
• The goal of this search is to find the hypothesis that best fits the training examples.
FIND-S Algorithm
1. Initialize h to the most specific hypothesis in H
2. For each positive training instance x
For each attribute constraint ai in h
If the constraint ai is satisfied by x
Then do nothing
Else replace ai in h by the next more general constraint that is satisfied by x
3. Output hypothesis h
Find S – Drawback
If multiple hypotheses consistent with the training examples, FIND-S will find the most specific. It is
unclear whether we should prefer this hypothesis
Training examples may contain at least some errors or noise. Such inconsistent sets of training examples
can severely mislead FIND-S, since it ignores negative examples.
There can be several maximally specific hypotheses consistent with the data. Find S finds only one.
Solution:
Version Space:
The version space, denoted VSH,D with respect to hypothesis space H and training examples D, is the subset
of hypotheses from H consistent with the training examples in D
LIST-THEN-ELIMINATE Algorithm:
The LIST-THEN-ELIMINATE algorithm first initializes the version space to contain all hypotheses in H
and then eliminates any hypothesis found inconsistent with any training example.
The CANDIDATE-ELIMINTION algorithm computes the version space containing all hypotheses from H
that are consistent with an observed sequence of training examples.
Algorithm:
1. Initialize G to the set of maximally general hypotheses in H
2. Initialize S to the set of maximally specific hypotheses in H
3. For each training example d, do
a. If d is a positive example
▪ Remove from G any hypothesis inconsistent with d,
▪ For each hypothesis s in S that is not consistent with d,
• Remove s from S
• Add to S all minimal generalizations h of s such that h is consistent with d,
and some member of G is more general than h
• Remove from S, hypothesis that is more general than another hypothesis in S
b. If d is a negative example
▪ Remove from S any hypothesis inconsistent with d
▪ For each hypothesis g in G that is not consistent with d
• Remove g from G
• Add to G all minimal specializations h of g such that h is consistent with d,
and some member of S is more specific than h
• Remove from G any hypothesis that is less general than another in G
Solution:
▪ Suppose we wish to assure that the hypothesis space contains the unknown target concept.
▪ The obvious solution is to enrich the hypothesis space to include every possible hypothesis.
▪ Consider EnjoySport example in which we restricted the hypothesis space to include only
conjunctions of attribute values.
2. An unbiased learner
▪ The obvious solution to be a unbiased learner– design hypothesis space H to represent every
teachable concept;
▪ It should capable of representing every possible subset of the instances X. In general, the set of all
subsets of a set X is called the power-set of X.
▪ In general, number of distinct subsets is 2|X|.
▪ Thus, there are 296, or approximately distinct target concepts that could be defined over this instance
space and that our learner might be called upon to learn.
Our conjunctive hypothesis space is able to represent only 973 of these-a very biased hypothesisspace indeed!
▪ Let us reformulate the Enjoysport learning task
▪ Let H’ represent every subset of instances; that is, let H’ correspond to the power set of X.
▪ One way to define such an H' is to allow arbitrary disjunctions, conjunctions, and negations of our
earlier hypotheses.
▪ For instance, the target concept "Sky = Sunny or Sky = Cloudy" could then be described as
▪ CEA generalizes observed training examples because it was biased by the implicit assumption that
the target concept could be represented by a conjunction of attribute values.
• If this assumption is correct (and the training examples are error-free), its classification of new
sample will also be correct.
• If this assumption is incorrect, however, it is certain that the CEA will mis-classify at least
some instances from X.
FIND-S
Observing the first training example, it is clear that our hypothesis is too specific. In particular, none of the
"Ø" constraints in h are satisfied by this example, so each is replaced by the next more general constraint
that fits the example
This h is still very specific; it asserts that all instances are negative except for the single positive training
example
The second training example forces the algorithm to further generalize h, this time substituting a "?' in place
of any attribute value in h that is not satisfied by the new example
Upon encountering the third training the algorithm makes no change to h. The FIND-S algorithm simply
ignores every negative example.
Example-1:
Sky Airtemp Humidity Wind Water Forecast EnjoySport
Sunny Warm Normal Strong Warm Same Yes
Sunny Warm High Strong Warm Same Yes
Rainy Cold High Strong Warm Change No
SUnny Warm High Strong Cool Change Yes
Consider the second training instance : <Sunny, Warm, High, Strong, Warm, Same> +
Compare each instance value with specific hypothesis value and generalize it. There is no change in
general hypothesis
Consider the third training instance : <Rainy, Cold, High, Strong, Warm, Change> -
-ve instance
S after removing consistent hypothesis with d
{('sunny', 'warm', '?', 'strong', 'warm',
'same')} G specialization
Consider g: ('?', '?', '?', '?', '?', '?')
g after min specialization: Compare g('?', '?', '?', '?', '?', '?') with all the instances of example and try
to make each ? with some value pair.
{('?', '?', '?', '?', 'cool', '?'), ('?', '?', '?', '?', '?', 'same'), ('?', 'warm', '?', '?', '?', '?'),
('sunny', '?', '?', '?', '?', '?'), ('?', '?', 'normal', '?', '?', '?')}
G after retaining g where g is consistent with d & some member of S is more specific than g
{('?', '?', '?', '?', '?', 'same'), ('?', 'warm', '?', '?', '?', '?'), ('sunny', '?', '?', '?', '?', '?')}
Consider the Fourth Training Instance d: ('sunny', 'warm', 'high', 'strong', 'cool', 'change', 'Y')
+ve instance
G after removing inconsistent hypothesis with d:
{('?', 'warm', '?', '?', '?', '?'), ('sunny', '?', '?', '?', '?', '?')}
S generalization
Consider s: ('sunny', 'warm', '?', 'strong', 'warm', 'same')
s after min generalization
{('sunny', 'warm', '?', 'strong', '?', '?')}
First two pairs are matching with my –ve instance (i.e. triangle and small) which should be opposite
so try to make each ? in the first two pairs with specific ones. {?,blue,?} is opposite to –ve instance d so
keep it as it is.
Replace each pair ? with the opposite pair in the negative instance. (In the first pair ? should be replaced by
{big,?,triangle} bcz small is there in my –ve instance and second ? can be replaced by {?,blue,triangle}
Second pair second ? can be replaced by {small,blue,?} and third ? can be replaced by {small,?,circle}
Compare G[2] with d and if it is not consistent then remove that pair.
{big,?,triangle} {small, ?, circle} ,– consistant bcz it is –ve and my instance also negative so consider this one.
{?,blue,triangle} and {small,blue,?} - These two are specific to {?,blue,?} so ignore it.
{?,blue,?} – This is –ve as opposite to red is blue but my instance also –ve so consistant.
Example-3 :
1. S0 ={0,0,0}
G0 ={?,?,?}
2. Consider the first instance d:{small,blue,circle} +ve
S1={small,blue,circle}
G1={?,?,?}
Consider the second instance d:{big,red,circle} –ve
S2={small,blue,circle}
G : Each ? can be replaced by specific pairs
G2: {small,?,?}{?,blue,?}{?,?,triangle}
Try to make G with consistant pairs there by removing less consistant ones.Here first two
pairs are consistant with specific hypothesis but third pair is not consistant so ignore it.
G2={small,?,?}{?,blue,?}
Consider the third instance d:{small,red,triangle} –ve
S3={small,blue,circle}
G after specialization : Make second and third ? in the first pair specific and second pair is
consistant with d so keep as it is.
{small,blue,?}{small,?,circle}{?,blue,?}
Try to make G with consistant pairs there by removing less consistant ones.
Among first two pairs {small,blue,?} is less consistant and matches with {small,?,circle} so
ignore it.
G3={small,?,circle}{?,blue,?}
Consider the fourth instance d:{small,red,circle} +ve
S4 = {small,?,circle}
G after specialization : G4 ={small,?,circle} because second pair is less consistant so
ignore.
Consider the fifth instance d:{big,blue,circle} –ve
S5 = {small,?,circle}
G5={small,?,circle}
Example-4 :
1. S0={0,0,0,0,0}
G0={?,?,?,?,?}