Machine Learning
Machine Learning
ENGINEERING COLLEGE
DEPARTMENT OF COMPUTER SCIENCE AND
ENGINEERING
REGULATION 2017
IV YEAR - VII SEMESTER
OBJECTIVES:
• To understand the need for machine learning for various problem solving
• To study the various supervised, semi-supervised and unsupervised learning
algorithms in machine learning
• To understand the latest trends in machine learning
• To design appropriate machine learning algorithms for problem solving
UNIT I INTRODUCTION 9
Learning Problems – Perspectives and Issues – Concept Learning – Version Spaces and
Candidate Eliminations – Inductive bias – Decision Tree learning – Representation –
Algorithm – Heuristic Space Search.
Learning Sets of Rules – Sequential Covering Algorithm – Learning Rule Set – First Order
Rules – Sets of First Order Rules – Induction on Inverted Deduction – Inverting Resolution –
Analytical Learning – Perfect Domain Theories – Explanation Base Learning – FOCL
Algorithm – Reinforcement Learning – Task – Q-Learning – Temporal Difference Learning
TEXT BOOK:
REFERENCES:
UNIT 1
INTRODUCTION
Ever since computers were invented, we have wondered whether they might be made to learn.
If we could understand how to program them to learn-to improve automatically with
experience-the impact would be dramatic.
• Imagine computers learning from medical records which treatments are most effective
for new diseases
• Houses learning from experience to optimize energy costs based on the particular usage
patterns of their occupants.
• Personal software assistants learning the evolving interests of their users in order to
highlight especially relevant stories from the online morning newspaper
A successful understanding of how to make computers learn would open up many new uses
of computers and new levels of competence and customization
• Some tasks cannot be defined well, except by examples (e.g., recognizing people).
• Relationships and correlations can be hidden within large amounts of data. Machine
Learning/Data Mining may be able to find these relationships.
• Human designers often produce machines that do not work as well as desired in the
environments in which they are used.
• The amount of knowledge available about certain tasks might be too large for explicit
encoding by humans (e.g., medical diagnostic).
• Environments change over time.
• New knowledge about tasks is constantly being discovered by humans. It may be
difficult to continuously re-design systems “by hand”.
2
Definition: A computer program is said to learn from experience E with respect to some class
of tasks T and performance measure P, if its performance at tasks in T, as measured by P,
improves with experience E.
Examples
1. Checkers game: A computer program that learns to play checkers might improve its
performance as measured by its ability to win at the class of tasks involving playing
checkers games, through experience obtained by playing games against itself.
The basic design issues and approaches to machine learning are illustrated by designing a
program to learn to play checkers, with the goal of entering it in the world checkers
tournament
1. Choosing the Training Experience
2. Choosing the Target Function
3. Choosing a Representation for the Target Function
4. Choosing a Function Approximation Algorithm
1. Estimating training values
2. Adjusting the weights
5. The Final Design
• The first design choice is to choose the type of training experience from which the
system will learn.
• The type of training experience available can have a significant impact on success or
failure of the learner.
There are three attributes which impact on success or failure of the learner
1. Whether the training experience provides direct or indirect feedback regarding the
choices made by the performance system.
Indirect training examples consisting of the move sequences and final outcomes of
various games played. The information about the correctness of specific moves early in
the game must be inferred indirectly from the fact that the game was eventually won or
lost.
Here the learner faces an additional problem of credit assignment, or determining the
degree to which each move in the sequence deserves credit or blame for the final
outcome. Credit assignment can be a particularly difficult problem because the game
can be lost even when early moves are optimal, if these are followed later by poor
moves.
Hence, learning from direct training feedback is typically easier than learning from
indirect feedback.
4
2. The degree to which the learner controls the sequence of training examples
Alternatively, the learner might itself propose board states that it finds particularly
confusing and ask the teacher for the correct move.
The learner may have complete control over both the board states and (indirect) training
classifications, as it does when it learns by playing against itself with no teacher present.
3. How well it represents the distribution of examples over which the final system
performance P must be measured
If its training experience E consists only of games played against itself, there is a danger
that this training experience might not be fully representative of the distribution of
situations over which it will later be tested.
It is necessary to learn from a distribution of examples that is different from those on
which the final system will be evaluated.
The next design choice is to determine exactly what type of knowledge will be learned and
how this will be used by the performance program.
Let’s consider a checkers-playing program that can generate the legal moves from any board
state.
The program needs only to learn how to choose the best move from among these legal moves.
We must learn to choose among the legal moves, the most obvious choice for the type of
information to be learned is a program, or function, that chooses the best move for any given
board state.
ChooseMove : B→ M
which indicate that this function accepts as input any board from the set of legal board
states B and produces as output some move from the set of legal moves M.
5
ChooseMove is a choice for the target function in checkers example, but this function
will turn out to be very difficult to learn given the kind of indirect training experience
available to our system
which denote that V maps any legal board state from the set B to some real value.
Intend for this target function V to assign higher scores to better board states. If the
system can successfully learn such a target function V, then it can easily use it to select
the best move from any current board position.
Let us define the target value V(b) for an arbitrary board state b in B, as follows:
• If b is a final board state that is won, then V(b) = 100
• If b is a final board state that is lost, then V(b) = -100
• If b is a final board state that is drawn, then V(b) = 0
• If b is a not a final state in the game, then V(b) = V(b' ),
Where b' is the best final board state that can be achieved starting from b and playing optimally
until the end of the game
Let’s choose a simple representation - for any given board state, the function c will be
calculated as a linear combination of the following board features:
Where,
• w0 through w6 are numerical coefficients, or weights, to be chosen by the learning
algorithm.
• Learned values for the weights w1 through w6 will determine the relative importance
of the various board features in determining the value of the board
• The weight w0 will provide an additive constant to the board value
In order to learn the target function f we require a set of training examples, each describing a
specific board state b and the training value Vtrain(b) for b.
For instance, the following training example describes a board state b in which black has won
the game (note x2 = 0 indicates that red has no remaining pieces) and for which the target
function value Vtrain(b) is therefore +100.
1. Derive training examples from the indirect training experience available to the learner
2. Adjusts the weights wi to best fit these training examples
A simple approach for estimating training values for intermediate board states is to
assign the training value of Vtrain(b) for any intermediate board state b to be
V̂(Successor(b))
Where ,
• V̂is the learner's current approximation to V
• Successor(b) denotes the next board state following b for which it is again the
program's turn to move
Vtrain(b) ← V̂ (Successor(b))
7
Several algorithms are known for finding weights of a linear function that minimize E.
One such algorithm is called the least mean squares, or LMS training rule. For each
observed training example it adjusts the weights a small amount in the direction that
reduces the error on this training example
LMS weight update rule :- For each training example (b, Vtrain(b))
Use the current weights to calculate V̂ (b)
For each weight wi, update it as
Here ƞ is a small constant (e.g., 0.1) that moderates the size of the weight update.
1. The Performance System is the module that must solve the given performance task by
using the learned target function(s). It takes an instance of a new problem (new game)
as input and produces a trace of its solution (game history) as output.
2. The Critic takes as input the history or trace of the game and produces as output a set
of training examples of the target function
3. The Generalizer takes as input the training examples and produces an output
hypothesis that is its estimate of the target function. It generalizes from the specific
training examples, hypothesizing a general function that covers these examples and
other cases beyond the training examples.
4. The Experiment Generator takes as input the current hypothesis and outputs a new
problem (i.e., initial board state) for the Performance System to explore. Its role is to
pick new practice problems that will maximize the learning rate of the overall system.
The sequence of design choices made for the checkers program is summarized in below figure
9
• When and how can prior knowledge held by the learner guide the process of generalizing
from examples? Can prior knowledge be helpful even when it is only approximately
correct?
• What is the best strategy for choosing a useful next training experience, and how does
the choice of this strategy alter the complexity of the learning problem?
• What is the best way to reduce the learning task to one or more function approximation
problems? Put another way, what specific functions should the system attempt to learn?
Can this process itself be automated?
• How can the learner automatically alter its representation to improve its ability to
represent and learn the target function?
11
CONCEPT LEARNING
• 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).
Consider the example task of learning the target concept "Days on which Aldo enjoys
his favorite water sport”
Table: Positive and negative training examples for the target concept EnjoySport.
The task is to learn to predict the value of EnjoySport for an arbitrary day, based on the
values of its other attributes?
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
is represented by the expression
(?, Cold, High, ?, ?, ?)
Notation
• The set of items over which the concept is defined is called the set of instances, which is
denoted by X.
Example: X is the set of all possible days, each represented by the attributes: Sky, AirTemp,
Humidity, Wind, Water, and Forecast
• The concept or function to be learned is called the target concept, which is denoted by c.
c can be any Boolean valued function defined over the instances X
c: X→ {O, 1}
Example: The target concept corresponds to the value of the attribute EnjoySport
(i.e., c(x) = 1 if EnjoySport = Yes, and c(x) = 0 if EnjoySport = No).
• Instances for which c(x) = 1 are called positive examples, or members of the target concept.
• Instances for which c(x) = 0 are called negative examples, or non-members of the target
concept.
• The ordered pair (x, c(x)) to describe the training example consisting of the instance x and
its target concept value c(x).
• D to denote the set of available training examples
13
• The symbol H to denote the set of all possible hypotheses that the learner may consider
regarding the identity of the target concept. Each hypothesis h in H represents a Boolean-
valued function defined over X
h: X→{O, 1}
The goal of the learner is to find a hypothesis h such that h(x) = c(x) for all x in X.
• Given:
• Instances X: Possible days, each described by the attributes
• Sky (with possible values Sunny, Cloudy, and Rainy),
• AirTemp (with values Warm and Cold),
• Humidity (with values Normal and High),
• Wind (with values Strong and Weak),
• Water (with values Warm and Cool),
• Forecast (with values Same and Change).
• Determine:
• A hypothesis h in H such that h(x) = c(x) for all x in X.
Any hypothesis found to approximate the target function well over a sufficiently large set of
training examples will also approximate the target function well over other unobserved
examples.
14
• 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.
Example:
Consider the instances X and hypotheses H in the EnjoySport learning task. The attribute Sky
has three possible values, and AirTemp, Humidity, Wind, Water, Forecast each have two
possible values, the instance space X contains exactly
3.2.2.2.2.2 = 96 distinct instances
5.4.4.4.4.4 = 5120 syntactically distinct hypotheses within H.
Every hypothesis containing one or more "Φ" symbols represents the empty set of instances;
that is, it classifies every instance as negative.
1 + (4.3.3.3.3.3) = 973. Semantically distinct hypotheses
• Consider the sets of instances that are classified positive by hl and by h2.
• h2 imposes fewer constraints on the instance, it classifies more instances as positive. So,
any instance classified positive by hl will also be classified positive by h2. Therefore, h2
is more general than hl.
Given hypotheses hj and hk, hj is more-general-than or- equal do hk if and only if any instance
that satisfies hk also satisfies hi
Definition: Let hj and hk be Boolean-valued functions defined over X. Then hj is more general-
than-or-equal-to hk (written hj ≥ hk) if and only if
• In the figure, the box on the left represents the set X of all instances, the box on the right
the set H of all hypotheses.
• Each hypothesis corresponds to some subset of X-the subset of instances that it classifies
positive.
• The arrows connecting hypotheses represent the more - general -than relation, with the
arrow pointing toward the less general hypothesis.
• Note the subset of instances characterized by h2 subsumes the subset characterized by
hl , hence h2 is more - general– than h1
FIND-S Algorithm
To illustrate this algorithm, assume the learner is given the sequence of training examples
from the EnjoySport task
Observing the first training example, it is clear that hypothesis h is too specific. 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
h1 = <Sunny Warm Normal Strong Warm Same>
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
h2 = <Sunny Warm ? Strong Warm Same>
Upon encountering the third training the algorithm makes no change to h. The FIND-S
algorithm simply ignores every negative example.
h3 = < Sunny Warm ? Strong Warm Same>
Unanswered by FIND-S
Representation
Definition: version space- The version space, denoted V S with respect to hypothesis space
H, D
H and training examples D, is the subset of hypotheses from H consistent with the training
examples in D
V S {h H | Consistent (h, D)}
H, D
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 version space is represented by its most general and least general members. These
members form general and specific boundary sets that delimit the version space within the
partially ordered hypothesis space.
Definition: The general boundary G, with respect to hypothesis space H and training data D,
is the set of maximally general members of H consistent with D
Definition: The specific boundary S, with respect to hypothesis space H and training data D,
is the set of minimally general (i.e., maximally specific) members of H consistent with D.
VS ={ h H | (s S ) (g G ) ( g h s )}
H,D g g
To Prove:
1. Every h satisfying the right hand side of the above expression is in VS
H, D
2. Every member of VS satisfies the right-hand side of the expression
H, D
Sketch of proof:
1. let g, h, s be arbitrary members of G, H, S respectively with g g h g s
• By the definition of S, s must be satisfied by all positive examples in D. Because h g s,
h must also be satisfied by all positive examples in D.
• By the definition of G, g cannot be satisfied by any negative example in D, and because
g g h h cannot be satisfied by any negative example in D. Because h is satisfied by all
positive examples in D and by no negative examples in D, h is consistent with D, and
therefore h is a member of VSH,D.
2. It can be proven by assuming some h in VSH,D,that does not satisfy the right-hand side
of the expression, then showing that this leads to an inconsistency
20
• 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 hypothesis in G
An Illustrative Example
Initializing the S boundary set to contain the most specific (least general) hypothesis
S0 , , , , ,
• When the second training example is observed, it has a similar effect of generalizing S
further to S2, leaving G again unchanged i.e., G2 = G1 = G0
22
• Consider the third training example. This negative example reveals that the G boundary
of the version space is overly general, that is, the hypothesis in G incorrectly predicts
that this new example is a positive example.
• The hypothesis in the G boundary must therefore be specialized until it correctly
classifies this new negative example
Given that there are six attributes that could be specified to specialize G 2, why are there only
three new hypotheses in G3?
For example, the hypothesis h = (?, ?, Normal, ?, ?, ?) is a minimal specialization of G2
that correctly labels the new example as a negative example, but it is not included in G3.
The reason this hypothesis is excluded is that it is inconsistent with the previously
encountered positive examples
• This positive example further generalizes the S boundary of the version space. It also
results in removing one member of the G boundary, because this member fails to
cover the new positive example
After processing these four examples, the boundary sets S4 and G4 delimit the version space
of all hypotheses consistent with the set of incrementally observed training examples.
24
INDUCTIVE BIAS
• Suppose the target concept is not contained in the hypothesis space H, then obvious
solution is to enrich the hypothesis space to include every possible hypothesis.
• Consider the EnjoySport example in which the hypothesis space is restricted to include
only conjunctions of attribute values. Because of this restriction, the hypothesis space is
unable to represent even simple disjunctive target concepts such as
"Sky = Sunny or Sky = Cloudy."
• The following three training examples of disjunctive hypothesis, the algorithm would
find that there are zero hypotheses in the version space
• If Candidate Elimination algorithm is applied, then it end up with empty Version Space.
After first two training example
S= ? Warm Normal Strong Cool Change
• This new hypothesis is overly general and it incorrectly covers the third negative
training example! So H does not include the appropriate c.
• In this case, a more expressive hypothesis space is required.
25
An Unbiased Learner
• The solution to the problem of assuring that the target concept is in the hypothesis space H
is to provide a hypothesis space capable of representing every teachable concept that is
representing every possible subset of the instances X.
• The set of all subsets of a set X is called the power set of X
• In the EnjoySport learning task the size of the instance space X of days described by
the six attributes is 96 instances.
• Thus, there are 296 distinct target concepts that could be defined over this instance space
and learner might be called upon to learn.
• The conjunctive hypothesis space is able to represent only 973 of these - a biased
hypothesis space indeed
• Let us reformulate the EnjoySport learning task in an unbiased way by defining a new
hypothesis space H' that can represent every subset of instances
• The target concept "Sky = Sunny or Sky = Cloudy" could then be described as
(Sunny, ?, ?, ?, ?, ?) v (Cloudy, ?, ?, ?, ?, ?)
Definition:
Consider a concept learning algorithm L for the set of instances X.
• Let c be an arbitrary concept defined over X
• Let D = {(x , c(x))} be an arbitrary set of training examples of c.
c
• Let L (x , D ) denote the classification assigned to the instance x by L after training on
i c i
the data D .
c
• The inductive bias of L is any minimal set of assertions B such that for any target concept
c and corresponding training examples D
c
Decision tree learning is a method for approximating discrete-valued target functions, in which
the learned function is represented by a decision tree.
• Decision trees classify instances by sorting them down the tree from the root to some
leaf node, which provides the classification of the instance.
• Each node in the tree specifies a test of some attribute of the instance, and each branch
descending from that node corresponds to one of the possible values for this attribute.
• An instance is classified by starting at the root node of the tree, testing the attribute
specified by this node, then moving down the tree branch corresponding to the value of
the attribute in the given example. This process is then repeated for the subtree rooted
at the new node.
FIGURE: A decision tree for the concept PlayTennis. An example is classified by sorting it
through the tree to the appropriate leaf node, then returning the classification associated with
this leaf
28
For example, the decision tree shown in above figure corresponds to the expression
(Outlook = Sunny ∧ Humidity = Normal)
∨ (Outlook = Overcast)
∨ (Outlook = Rain ∧ Wind = Weak)
2. The target function has discrete output values – The decision tree assigns a Boolean
classification (e.g., yes or no) to each example. Decision tree methods easily extend to
learning functions with more than two possible output values.
4. The training data may contain errors – Decision tree learning methods are robust to
errors, both errors in classifications of the training examples and errors in the attribute
values that describe these examples.
5. The training data may contain missing attribute values – Decision tree methods can
be used even when some training examples have unknown values
29
Examples are the training examples. Target_attribute is the attribute whose value is to be
predicted by the tree. Attributes is a list of other attributes that may be tested by the
learned decision tree. Returns a decision tree that correctly classifies the given Examples.
• Otherwise Begin
• A ← the attribute from Attributes that best* classifies Examples
• The decision attribute for Root ← A
• For each possible value, vi, of A,
• Add a new tree branch below Root, corresponding to the test A = vi
• Let Examples vi, be the subset of Examples that have value vi for A
• If Examples vi , is empty
• Then below this new branch add a leaf node with label = most common
value of Target_attribute in Examples
• Else below this new branch add the subtree
ID3(Examples vi, Targe_tattribute, Attributes – {A}))
• End
• Return Root
TABLE: Summary of the ID3 algorithm specialized to learning Boolean-valued functions. ID3
is a greedy algorithm that grows the tree top-down, at each node selecting the attribute that best
classifies the local training examples. This process continues until the tree perfectly classifies
the training examples, or until all attributes have been used
30
• The central choice in the ID3 algorithm is selecting which attribute to test at each node
in the tree.
• A statistical property called information gain that measures how well a given attribute
separates the training examples according to their target classification.
• ID3 uses information gain measure to select among the candidate attributes at each
step while growing the tree.
Given a collection S, containing positive and negative examples of some target concept, the
entropy of S relative to this Boolean classification is
Where,
p+ is the proportion of positive examples in S
p- is the proportion of negative examples in S.
Example:
Suppose S is a collection of 14 examples of some boolean concept, including 9 positive and 5
negative examples. Then the entropy of S relative to this boolean classification is
An Illustrative Example
• To illustrate the operation of ID3, consider the learning task represented by the training
examples of below table.
• Here the target attribute PlayTennis, which can have values yes or no for different days.
• Consider the first step through the algorithm, in which the topmost node of the decision
tree is created.
• ID3 determines the information gain for each candidate attribute (i.e., Outlook,
Temperature, Humidity, and Wind), then selects the one with highest information gain.
33
• According to the information gain measure, the Outlook attribute provides the best
prediction of the target attribute, PlayTennis, over the training examples. Therefore,
Outlook is selected as the decision attribute for the root node, and branches are created
below the root for each of its possible values i.e., Sunny, Overcast, and Rain.
34
Figure: Hypothesis space search by ID3. ID3 searches through the space of possible decision
trees from simplest to increasingly complex, guided by the information gain heuristic.
By viewing ID3 in terms of its search space and search strategy, there are some insight into its
capabilities and limitations
1. ID3's hypothesis space of all decision trees is a complete space of finite discrete-valued
functions, relative to the available attributes. Because every finite discrete-valued
function can be represented by some decision tree
ID3 avoids one of the major risks of methods that search incomplete hypothesis spaces:
that the hypothesis space might not contain the target function.
36
2. ID3 maintains only a single current hypothesis as it searches through the space of
decision trees.
For example, with the earlier version space candidate elimination method, which
maintains the set of all hypotheses consistent with the available training examples.
By determining only a single hypothesis, ID3 loses the capabilities that follow from
explicitly representing all consistent hypotheses.
For example, it does not have the ability to determine how many alternative decision
trees are consistent with the available training data, or to pose new instance queries that
optimally resolve among these competing hypotheses
3. ID3 in its pure form performs no backtracking in its search. Once it selects an attribute
to test at a particular level in the tree, it never backtracks to reconsider this choice.
In the case of ID3, a locally optimal solution corresponds to the decision tree it selects
along the single search path it explores. However, this locally optimal solution may be
less desirable than trees that would have been encountered along a different branch of
the search.
4. ID3 uses all training examples at each step in the search to make statistically based
decisions regarding how to refine its current hypothesis.
One advantage of using statistical properties of all the examples is that the resulting
search is much less sensitive to errors in individual training examples.
ID3 can be easily extended to handle noisy training data by modifying its termination
criterion to accept hypotheses that imperfectly fit the training data.
Given a collection of training examples, there are typically many decision trees consistent with
these examples. Which of these decision trees does ID3 choose?
Approximate inductive bias of ID3: Shorter trees are preferred over larger trees
• Consider an algorithm that begins with the empty tree and searches breadth first through
progressively more complex trees.
• First considering all trees of depth 1, then all trees of depth 2, etc.
• Once it finds a decision tree consistent with the training data, it returns the smallest
consistent tree at that search depth (e.g., the tree with the fewest nodes).
• Let us call this breadth-first search algorithm BFS-ID3.
• BFS-ID3 finds a shortest decision tree and thus exhibits the bias "shorter trees are
preferred over longer trees.
A closer approximation to the inductive bias of ID3: Shorter trees are preferred over longer
trees. Trees that place high information gain attributes close to the root are preferred over
those that do not.
CANDIDATE-ELIMINATION Algorithm:
• The version space CANDIDATE-ELIMINATION Algorithm searches an incomplete
hypothesis space
• It searches this space completely, finding every hypothesis consistent with the training
data.
• Its inductive bias is solely a consequence of the expressive power of its hypothesis
representation. Its search strategy introduces no additional bias
38
Preference bias – The inductive bias of ID3 is a preference for certain hypotheses over others
(e.g., preference for shorter hypotheses over larger hypotheses), with no hard restriction on the
hypotheses that can be eventually enumerated. This form of bias is called a preference bias or
a search bias.
Restriction bias – The bias of the CANDIDATE ELIMINATION algorithm is in the form of a
categorical restriction on the set of hypotheses considered. This form of bias is typically called
a restriction bias or a language bias.
Which type of inductive bias is preferred in order to generalize beyond the training data, a
preference bias or restriction bias?
• A preference bias is more desirable than a restriction bias, because it allows the learner
to work within a complete hypothesis space that is assured to contain the unknown target
function.
• In contrast, a restriction bias that strictly limits the set of potential hypotheses is
generally less desirable, because it introduces the possibility of excluding the unknown
target function altogether.
• Occam's razor: is the problem-solving principle that the simplest solution tends to be
the right one. When presented with competing hypotheses to solve a problem, one
should select the solution with the fewest assumptions.
• Occam's razor: “Prefer the simplest hypothesis that fits the data”.
• Many complex hypotheses that fit the current training data but fail to generalize
correctly to subsequent data.
39
Argument opposed:
• There are few small trees, and our priori chance of finding one consistent with an
arbitrary set of data is therefore small. The difficulty here is that there are very many
small sets of hypotheses that one can define but understood by fewer learner.
• The size of a hypothesis is determined by the representation used internally by the
learner. Occam's razor will produce two different hypotheses from the same training
examples when it is applied by two learners, both justifying their contradictory
conclusions by Occam's razor. On this basis we might be tempted to reject Occam's
razor altogether.
• The ID3 algorithm grows each branch of the tree just deeply enough to perfectly classify
the training examples but it can lead to difficulties when there is noise in the data, or
when the number of training examples is too small to produce a representative sample
of the true target function. This algorithm can produce trees that overfit the training
examples.
The below figure illustrates the impact of overfitting in a typical application of decision tree
learning.
• The horizontal axis of this plot indicates the total number of nodes in the decision tree,
as the tree is being constructed. The vertical axis indicates the accuracy of predictions
made by the tree.
• The solid line shows the accuracy of the decision tree over the training examples. The
broken line shows accuracy measured over an independent set of test example
• The accuracy of the tree over the training examples increases monotonically as the tree
is grown. The accuracy measured over the independent test examples first increases,
then decreases.
How can it be possible for tree h to fit the training examples better than h', but for it to perform
more poorly over subsequent examples?
1. Overfitting can occur when the training examples contain random errors or noise
2. When small numbers of examples are associated with leaf nodes.
Reduced-Error Pruning
The impact of reduced-error pruning on the accuracy of the decision tree is illustrated in below
figure
• The additional line in figure shows accuracy over the test examples as the tree is pruned.
When pruning begins, the tree is at its maximum size and lowest accuracy over the test
set. As pruning proceeds, the number of nodes is reduced and accuracy over the test set
increases.
• The available data has been split into three subsets: the training examples, the validation
examples used for pruning the tree, and a set of test examples used to provide an
unbiased estimate of accuracy over future unseen examples. The plot shows accuracy
over the training and test sets.
43
Rule Post-Pruning
Rule post-pruning is successful method for finding high accuracy hypotheses
For example, consider the decision tree. The leftmost path of the tree in below figure is
translated into the rule.
IF (Outlook = Sunny) ^ (Humidity = High)
THEN PlayTennis = No
Given the above rule, rule post-pruning would consider removing the preconditions
(Outlook = Sunny) and (Humidity = High)
• It would select whichever of these pruning steps produced the greatest improvement in
estimated rule accuracy, then consider pruning the second precondition as a further
pruning step.
• No pruning step is performed if it reduces the estimated rule accuracy.
There are three main advantages by converting the decision tree to rules before pruning
The gain ratio measure penalizes attributes by incorporating a split information, that is sensitive
to how broadly and uniformly the attribute splits the data
The data which is available may contain missing values for some
attributes Example: Medical diagnosis
• <Fever = true, Blood-Pressure = normal, …, Blood-Test = ?, …>
• Sometimes values truly unknown, sometimes low priority (or cost too high)
• In some learning tasks the instance attributes may have associated costs.
• For example: In learning to classify medical diseases, the patients described in terms
of attributes such as Temperature, BiopsyResult, Pulse, BloodTestResults, etc.
• These attributes vary significantly in their costs, both in terms of monetary cost and
cost to patient comfort
• Decision trees use low-cost attributes where possible, depends only on high-cost
attributes only when needed to produce reliable classifications
INDUCTIVE BIAS
In the Candidate-Elimination Algorithm, we get two hypotheses, one specific and one general at
the end as a final solution. Now, we also need to check if the hypothesis we got from the
algorithm is actually correct or not, also make decisions like what training examples should the
machine learn next.
• This basically means learning from examples, learning on the go. [From examples we
derive rules.]
• We are given input samples (x) and output samples (f(x)) in the context of inductive
learning, and the objective is to estimate the function (f).
• The goal is to generalize [general procedure] from the samples and map such that the
output may be estimated for fresh samples in the future.
• It does not include all types of training instances. [ does not consider all types of training
examples.]
• The issue is that we have skewed the learner’s thinking to only evaluate conjunctive
possibilities.
• In this instance, a more expressive hypothesis space is required. [solution is, include all
hypothesis]
• Example: sunny warm normal strong cool change= yes
• The inductive bias (also known as learning bias) of a learning algorithm is the set of
assumptions that the learner uses to predict outputs of given inputs that it has not
encountered.
• Inductive bias is anything which makes the algorithm learn one pattern instead of
another pattern.
• In machine learning, one aims to construct algorithms that are able to learn to predict a
certain target output.
• The idea of inductive bias is to let the learner generalize beyond the observed training
examples to infer new examples.
• ‘ > ’ -> Inductively inferred from.
• For example,
• x > y means y is inductively deduced from x.
Example
Learning algorithm – L (based on the learning algorithm you got a training data)
Training data D = {x, c(x)}
New instance = xi
Represented as L(xi, D)
(D^Xi)>L(Xi,D)
• Heuristics are used in situations in which there is the requirement of a short-term solution.
• On facing complex situations with limited resources and time, Heuristics can help to
make quick decisions by shortcuts and approximated calculations.
• Most of the heuristic methods involve mental shortcuts to make decisions on past
experiences.
50
• Hill Climbing
• Constraint Satisfaction Problems
• Simulated Annealing
• Best First search (BFS)
We can perform the Heuristic techniques into two categories:
INTRODUCTION
Artificial neural networks (ANNs) provide a general, practical method for learning real-valued,
discrete-valued, and vector-valued target functions.
Biological Motivation
• The study of artificial neural networks (ANNs) has been inspired by the observation that
biological learning systems are built of very complex webs of interconnected Neurons
• Human information processing system consists of brain neuron: basic building block
cell that communicates information to and from various parts of body
1
NEURAL NETWORK REPRESENTATIONS
2
• Figure illustrates the neural network representation.
• The network is shown on the left side of the figure, with the input camera image depicted
below it.
• Each node (i.e., circle) in the network diagram corresponds to the output of a single
network unit, and the lines entering the node from below are its inputs.
• There are four units that receive inputs directly from all of the 30 x 32 pixels in the
image. These are called "hidden" units because their output is available only within the
network and is not available as part of the global network output. Each of these four
hidden units computes a single real-valued output based on a weighted combination of
its 960 inputs
• These hidden unit outputs are then used as inputs to a second layer of 30 "output" units.
• Each output unit corresponds to a particular steering direction, and the output values of
these units determine which steering direction is recommended most strongly.
• The diagrams on the right side of the figure depict the learned weight values associated
with one of the four hidden units in this ANN.
• The large matrix of black and white boxes on the lower right depicts the weights from
the 30 x 32 pixel inputs into the hidden unit. Here, a white box indicates a positive
weight, a black box a negative weight, and the size of the box indicates the weight
magnitude.
• The smaller rectangular diagram directly above the large matrix shows the weights from
this hidden unit to each of the 30 output units.
ANN learning is well-suited to problems in which the training data corresponds to noisy,
complex sensor data, such as inputs from cameras and microphones.
3
PERCEPTRON
• One type of ANN system is based on a unit called a perceptron. Perceptron is a single
layer neural network.
Figure: A perceptron
Learning a perceptron involves choosing values for the weights w0 , . . . , wn . Therefore, the
space H of candidate hypotheses considered in perceptron learning is the set of all possible
real-valued weight vectors
4
Representational Power of Perceptrons
Perceptrons can represent all of the primitive Boolean functions AND, OR, NAND (~ AND),
and NOR (~OR)
Some Boolean functions cannot be represented by a single perceptron, such as the XOR
function whose value is 1 if and only if x1 ≠ x2
5
Drawback of perceptron
• The perceptron rule finds a successful weight vector when the training examples are
linearly separable, it can fail to converge if the examples are not linearly separable
The learning problem is to determine a weight vector that causes the perceptron to produce the
correct + 1 or - 1 output for each of the given training examples.
• The role of the learning rate is to moderate the degree to which weights are changed at
each step. It is usually set to some small value (e.g., 0.1) and is sometimes made to decay
as the number of weight-tuning iterations increases
Drawback:
The perceptron rule finds a successful weight vector when the training examples are linearly
separable, it can fail to converge if the examples are not linearly separable.
6
Gradient Descent and the Delta Rule
• If the training examples are not linearly separable, the delta rule converges toward a
best-fit approximation to the target concept.
• The key idea behind the delta rule is to use gradient descent to search the hypothesis
space of possible weight vectors to find the weights that best fit the training examples.
To understand the delta training rule, consider the task of training an unthresholded perceptron.
That is, a linear unit for which the output O is given by
To derive a weight learning rule for linear units, specify a measure for the training error of a
hypothesis (weight vector), relative to the training examples.
Where,
• D is the set of training examples,
• td is the target output for training example d,
• od is the output of the linear unit for training example d
• E ( w⃗⃗⃗⃗⃗⃗⃗⃗⃗) is simply half the squared difference between the target output td and the linear
unit output od, summed over all training examples.
7
• Given the way in which we chose to define E, for linear units this error surface must
always be parabolic with a single global minimum.
Gradient descent search determines a weight vector that minimizes E by starting with an
arbitrary initial weight vector, then repeatedly modifying it in small steps.
At each step, the weight vector is altered in the direction that produces the steepest descent
along the error surface depicted in above figure. This process continues until the global
minimum error is reached.
How to calculate the direction of steepest descent along the error surface?
The direction of steepest can be found by computing the derivative of E with respect to each
component of the vector w⃗⃗⃗⃗⃗⃗⃗⃗⃗. This vector derivative is called the gradient of E with respect to
w⃗⃗⃗⃗⃗⃗⃗⃗⃗, written as
8
The gradient specifies the direction of steepest increase of E, the training rule for
gradient descent is
• Here η is a positive constant called the learning rate, which determines the step
size in the gradient descent search.
• The negative sign is present because we want to move the weight vector in the
direction that decreases E.
𝜕𝐸
Calculate the gradient at each step. The vector of derivatives that form the
𝜕𝑤𝑖
gradient can be obtained by differentiating E from Equation (2), as
9
GRADIENT DESCENT algorithm for training a linear unit
To summarize, the gradient descent algorithm for training linear units is as follows:
• Pick an initial random weight vector.
• Apply the linear unit to all training examples, then compute Δw i for each weight
according to Equation (7).
• Update each weight wi by adding Δwi, then repeat this process
Gradient descent is an important general paradigm for learning. It is a strategy for searching
through a large or infinite hypothesis space that can be applied whenever
1. The hypothesis space contains continuously parameterized hypotheses
2. The error can be differentiated with respect to these hypothesis parameters
10
Stochastic Approximation to Gradient Descent
• The gradient descent training rule presented in Equation (7) computes weight updates
after summing over all the training examples in D
• The idea behind stochastic gradient descent is to approximate this gradient descent
search by updating weights incrementally, following the calculation of the error for
each individual example
∆wi = η (t – o) xi
• where t, o, and xi are the target value, unit output, and ith input for the training example
in question
One way to view this stochastic gradient descent is to consider a distinct error function
Ed( ⃗⃗⃗w⃗⃗⃗⃗⃗⃗ ) for each individual training example d as follows
• Where, td and od are the target value and the unit output value for training example d.
• Stochastic gradient descent iterates over the training examples d in D, at each iteration
altering the weights according to the gradient with respect to Ed( w⃗⃗⃗⃗⃗⃗⃗⃗⃗)
• The sequence of these weight updates, when iterated over all training examples,
provides a reasonable approximation to descending the gradient with respect to our
original error function Ed( w⃗⃗⃗⃗⃗⃗⃗⃗⃗)
• By making the value of η sufficiently small, stochastic gradient descent can be made to
approximate true gradient descent arbitrarily closely
11
The key differences between standard gradient descent and stochastic gradient descent are
• In standard gradient descent, the error is summed over all examples before updating
weights, whereas in stochastic gradient descent weights are updated upon examining
each training example.
• Summing over multiple examples in standard gradient descent requires more
computation per weight update step. On the other hand, because it uses the true gradient,
standard gradient descent is often used with a larger step size per weight update than
stochastic gradient descent.
• In cases where there are multiple local minima with respect to stochastic gradient
descent can sometimes avoid falling into these local minima because it uses the various
∇E ( ⃗⃗⃗w⃗⃗⃗⃗⃗⃗) rather than ∇ E( w⃗⃗⃗⃗⃗⃗⃗⃗⃗) to guide its search
d
12
A Differentiable Threshold Unit (Sigmoid unit)
• Sigmoid unit-a unit very much like a perceptron, but based on a smoothed, differentiable
threshold function.
• The sigmoid unit first computes a linear combination of its inputs, then applies a
threshold to the result and the threshold output is a continuous function of its input.
• More precisely, the sigmoid unit computes its output O as
13
where,
• outputs - is the set of output units in the network
• tkd and Okd - the target and output values associated with the kth output unit
• d - training example
Algorithm:
• Create a feed-forward network with ni inputs, nhidden hidden units, and nout output
units.
• Initialize all network weights to small random numbers
• Until the termination condition is met, Do
• For each (𝑥 ⃗⃗⃗ 𝑡 ), in training examples, Do
,
Propagate the input forward through the network:
1. Input the instance 𝑥⃗⃗⃗, to the network and compute the output ou of
every unit u in the network.
Propagate the errors backward through the network:
14
Adding Momentum
Because BACKPROPAGATION is such a widely used algorithm, many variations have been
developed. The most common is to alter the weight-update rule the equation below
by making the weight update on the nth iteration depend partially on the update that occurred
during the (n - 1)th iteration, as follows:
Where, Downstream(r) is the set of units immediately downstream from unit r in the network:
that is, all units whose inputs include the output of unit r
• Deriving the stochastic gradient descent rule: Stochastic gradient descent involves
iterating through the training examples one at a time, for each training example d
descending the gradient of the error Ed with respect to this single example
• For each training example d every weight wji is updated by adding to it Δwji
15
Here outputs is the set of output units in the network, tk is the target value of unit k for training
example d, and ok is the output of unit k given training example d.
The derivation of the stochastic gradient descent rule is conceptually straightforward, but
requires keeping track of a number of subscripts and variables
16
Consider two cases: The case where unit j is an output unit for the network, and the case where
j is an internal unit (hidden unit).
17
Case 2: Training Rule for Hidden Unit Weights.
• In the case where j is an internal, or hidden unit in the network, the derivation of the
training rule for wji must take into account the indirect ways in which wji can influence
the network outputs and hence Ed.
• For this reason, we will find it useful to refer to the set of all units immediately
downstream of unit j in the network and denoted this set of units by Downstream( j).
• netj can influence the network outputs only through the units in Downstream(j).
Therefore, we can write
18
REMARKS ON THE BACKPROPAGATION ALGORITHM
• Hypothesis space is the n-dimensional Euclidean space of the n network weights and
hypothesis space is continuous.
19
• As it is continuous, E is differentiable with respect to the continuous parameters of the
hypothesis, results in a well-defined error gradient that provides a very useful structure
for organizing the search for the best hypothesis.
• It is difficult to characterize precisely the inductive bias of BACKPROPAGATION
algorithm, because it depends on the interplay between the gradient descent search and
the way in which the weight space spans the space of representable functions. However,
one can roughly characterize it as smooth interpolation between data points.
BACKPROPAGATION can define new hidden layer features that are not explicit in the input
representation, but which capture properties of the input instances that are most relevant to
learning the target function.
20
• Consider training the network shown in Figure to learn the simple target function f (x)
= x, where x is a vector containing seven 0's and a single 1.
• The network must learn to reproduce the eight inputs at the corresponding eight output
units. Although this is a simple function, the network in this case is constrained to use
only three hidden units. Therefore, the essential information from all eight input units
must be captured by the three learned hidden units.
• When BACKPROPAGATION applied to this task, using each of the eight possible
vectors as training examples, it successfully learns the target function. By examining
the hidden unit values generated by the learned network for each of the eight possible
input vectors, it is easy to see that the learned encoding is similar to the familiar standard
binary encoding of eight values using three bits (e.g., 000,001,010,. . . , 111). The exact
values of the hidden units for one typical run of shown in Figure.
• This ability of multilayer networks to automatically discover useful representations at
the hidden layers is a key feature of ANN learning
What is an appropriate condition for terminating the weight update loop? One choice is to
continue training until the error E on the training examples falls below some predetermined
threshold.
To see the dangers of minimizing the error over the training data, consider how the error E
varies with the number of weight iterations
21
• Consider first the top plot in this figure. The lower of the two lines shows the
monotonically decreasing error E over the training set, as the number of gradient descent
iterations grows. The upper line shows the error E measured over a different validation
set of examples, distinct from the training examples. This line measures the
generalization accuracy of the network-the accuracy with which it fits examples beyond
the training data.
• The generalization accuracy measured over the validation examples first decreases, then
increases, even as the error over the training examples continues to decrease. How can
this occur? This occurs because the weights are being tuned to fit idiosyncrasies of the
training examples that are not representative of the general distribution of examples.
The large number of weight parameters in ANNs provides many degrees of freedom for
fitting such idiosyncrasies
• Why does overfitting tend to occur during later iterations, but not during earlier
iterations?
By giving enough weight-tuning iterations, BACKPROPAGATION will often be able
to create overly complex decision surfaces that fit noise in the training data or
unrepresentative characteristics of the particular training sample.
22
UNIT 3
BAYESIAN AND COMPUTATIONAL LEARNING
INTRODUCTION
Bayesian learning methods are relevant to study of machine learning for two different reasons.
1. First, Bayesian learning algorithms that calculate explicit probabilities for hypotheses,
such as the naive Bayes classifier, are among the most practical approaches to certain
types of learning problems
2. The second reason is that they provide a useful perspective for understanding many
learning algorithms that do not explicitly manipulate probabilities.
• Each observed training example can incrementally decrease or increase the estimated
probability that a hypothesis is correct. This provides a more flexible approach to
learning than algorithms that completely eliminate a hypothesis if it is found to be
inconsistent with any single example
• Prior knowledge can be combined with observed data to determine the final probability
of a hypothesis. In Bayesian learning, prior knowledge is provided by asserting (1) a
prior probability for each candidate hypothesis, and (2) a probability distribution over
observed data for each possible hypothesis.
• Bayesian methods can accommodate hypotheses that make probabilistic predictions
• New instances can be classified by combining the predictions of multiple hypotheses,
weighted by their probabilities.
• Even in cases where Bayesian methods prove computationally intractable, they can
provide a standard of optimal decision making against which other practical methods
can be measured.
86
Practical difficulty in applying Bayesian methods
1. One practical difficulty in applying Bayesian methods is that they typically require
initial knowledge of many probabilities. When these probabilities are not known in
advance they are often estimated based on background knowledge, previously available
data, and assumptions about the form of the underlying distributions.
2. A second practical difficulty is the significant computational cost required to determine
the Bayes optimal hypothesis in the general case. In certain specialized situations, this
computational cost can be significantly reduced.
BAYES THEOREM
Bayes theorem provides a way to calculate the probability of a hypothesis based on its prior
probability, the probabilities of observing various data given the hypothesis, and the observed
data itself.
Notations
• P(h) prior probability of h, reflects any background knowledge about the chance that h
is correct
• P(D) prior probability of D, probability that D will be observed
• P(D|h) probability of observing D given a world in which h holds
• P(h|D) posterior probability of h, reflects confidence that h holds after D has been
observed
Bayes theorem is the cornerstone of Bayesian learning methods because it provides a way to
calculate the posterior probability P(h|D), from the prior probability P(h), together with P(D)
and P(D|h).
• P(h|D) increases with P(h) and with P(D|h) according to Bayes theorem.
• P(h|D) decreases as P(D) increases, because the more probable it is that D will be
observed independent of h, the less evidence D provides in support of h.
87
Maximum a Posteriori (MAP) Hypothesis
• In many learning scenarios, the learner considers some set of candidate hypotheses H
and is interested in finding the most probable hypothesis h ∈ H given the observed data
D. Any such maximally probable hypothesis is called a maximum a posteriori (MAP)
hypothesis.
• Bayes theorem to calculate the posterior probability of each candidate hypothesis is hMAP
is a MAP hypothesis provided
P(D|h) is often called the likelihood of the data D given h, and any hypothesis that maximizes
P(D|h) is called a maximum likelihood (ML) hypothesis
Example
• Consider a medical diagnosis problem in which there are two alternative hypotheses:
(1) that the patient has particular form of cancer, and (2) that the patient does not. The
available data is from a particular laboratory test with two possible outcomes: +
(positive) and - (negative).
88
• We have prior knowledge that over the entire population of people only .008 have this
disease. Furthermore, the lab test is only an imperfect indicator of the disease.
• The test returns a correct positive result in only 98% of the cases in which the disease is
actually present and a correct negative result in only 97% of the cases in which the
disease is not present. In other cases, the test returns the opposite result.
• The above situation can be summarized by the following probabilities:
Suppose a new patient is observed for whom the lab test returns a positive (+) result.
Should we diagnose the patient as having cancer or not?
The exact posterior probabilities can also be determined by normalizing the above quantities
so that they sum to 1
89
BAYES THEOREM AND CONCEPT LEARNING
What is the relationship between Bayes theorem and the problem of concept learning?
Since Bayes theorem provides a principled way to calculate the posterior probability of each
hypothesis given the training data, and can use it as the basis for a straightforward learning
algorithm that calculates the probability for each possible hypothesis, then outputs the most
probable.
We can design a straightforward concept learning algorithm to output the maximum a posteriori
hypothesis, based on Bayes theorem, as follows:
In order specify a learning problem for the BRUTE-FORCE MAP LEARNING algorithm we
must specify what values are to be used for P(h) and for P(D|h) ?
Let’s choose P(h) and for P(D|h) to be consistent with the following assumptions:
• The training data D is noise free (i.e., di = c(xi))
• The target concept c is contained in the hypothesis space H
• Do not have a priori reason to believe that any hypothesis is more probable than any
other.
90
What values should we specify for P(h)?
• Given no prior knowledge that one hypothesis is more likely than another, it is
reasonable to assign the same prior probability to every hypothesis h in H.
• Assume the target concept is contained in H and require that these prior probabilities
sum to 1.
Given these choices for P(h) and for P(D|h) we now have a fully-defined problem for the above
BRUTE-FORCE MAP LEARNING algorithm.
Where, VSH,D is the subset of hypotheses from H that are consistent with D
To summarize, Bayes theorem implies that the posterior probability P(h|D) under our assumed
P(h) and P(D|h) is
91
The Evolution of Probabilities Associated with Hypotheses
Example:
• FIND-S outputs a consistent hypothesis, it will output a MAP hypothesis under the
probability distributions P(h) and P(D|h) defined above.
• Are there other probability distributions for P(h) and P(D|h) under which FIND-S
outputs MAP hypotheses? Yes.
• Because FIND-S outputs a maximally specific hypothesis from the version space, its
output hypothesis will be a MAP hypothesis relative to any prior probability distribution
that favours more specific hypotheses.
Note
• Bayesian framework is a way to characterize the behaviour of learning algorithms
• By identifying probability distributions P(h) and P(D|h) under which the output is a
optimal hypothesis, implicit assumptions of the algorithm can be characterized
(Inductive Bias)
• Inductive inference is modelled by an equivalent probabilistic reasoning system based
on Bayes theorem
92
MAXIMUM LIKELIHOOD AND LEAST-SQUARED ERROR HYPOTHESES
Consider the problem of learning a continuous-valued target function such as neural network
learning, linear regression, and polynomial curve fitting
A straightforward Bayesian analysis will show that under certain assumptions any learning
algorithm that minimizes the squared error between the output hypothesis predictions and the
training data will output a maximum likelihood (ML) hypothesis
Assuming training examples are mutually independent given h, we can write P(D|h) as the
product of the various (di|h)
Given the noise ei obeys a Normal distribution with zero mean and unknown variance σ2 , each
di must also obey a Normal distribution around the true targetvalue f(xi). Because we are
writing the expression for P(D|h), we assume h is the correct description of f.
Hence, µ = f(xi) = h(xi)
93
Maximize the less complicated logarithm, which is justified because of the monotonicity of
function p
The first term in this expression is a constant independent of h, and can therefore be
discarded, yielding
Thus, above equation shows that the maximum likelihood hypothesis hML is the one that
minimizes the sum of the squared errors between the observed training values d i and the
hypothesis predictions h(xi)
Note:
Why is it reasonable to choose the Normal distribution to characterize noise?
• Good approximation of many types of noise in physical systems
• Central Limit Theorem shows that the sum of a sufficiently large number of
independent, identically distributed random variables itself obeys a Normal distribution
Only noise in the target value is considered, not in the attributes describing the instances
themselves
94
MAXIMUM LIKELIHOOD HYPOTHESES FOR PREDICTING PROBABILITIES
What criterion should we optimize in order to find a maximum likelihood hypothesis for f' in
this setting?
• First obtain an expression for P(D|h)
• Assume the training data D is of the form D = {(x1, d1) . . . (xm, dm)}, where di is the
observed 0 or 1 value for f (xi).
• Both xi and di as random variables, and assuming that each training example is drawn
independently, we can write P(D|h) as
Equation (4) to substitute for P(di |h, xi) in Equation (5) to obtain
95
The last term is a constant independent of h, so it can be dropped
Equation (7) describes the quantity that must be maximized in order to obtain the maximum
likelihood hypothesis in our current problem setting
• Derive a weight-training rule for neural network learning that seeks to maximize G(h,D)
using gradient ascent
• The gradient of G(h,D) is given by the vector of partial derivatives of G(h,D) with
respect to the various network weights that define the hypothesis h represented by the
learned network
• In this case, the partial derivative of G(h, D) with respect to weight wjk from input k to
unit j is
• Suppose our neural network is constructed from a single layer of sigmoid units. Then,
where xijk is the kth input to unit j for the ith training example, and d(x) is the derivative
of the sigmoid squashing function.
• Finally, substituting this expression into Equation (1), we obtain a simple expression for
the derivatives that constitute the gradient
96
Because we seek to maximize rather than minimize P(D|h), we perform gradient ascent rather
than gradient descent search. On each iteration of the search the weight vector is adjusted in
the direction of the gradient, using the weight update rule
Where, η is a small positive constant that determines the step size of the i gradient ascent search
This equation (1) can be interpreted as a statement that short hypotheses are preferred,
assuming a particular representation scheme for encoding hypotheses and data
• -log2P(h): the description length of h under the optimal encoding for the hypothesis
space H, LCH (h) = −log2P(h), where CH is the optimal code for hypothesis space H.
• -log2P(D | h): the description length of the training data D given hypothesis h, under the
optimal encoding from the hypothesis space H: LCH (D|h) = −log2P(D| h) , where C D|h
is the optimal code for describing data D assuming that both the sender and receiver
know the hypothesis h.
• Rewrite Equation (1) to show that hMAP is the hypothesis h that minimizes the sum given
by the description length of the hypothesis plus the description length of the data given
the hypothesis.
Where, CH and CD|h are the optimal encodings for H and for D given h
97
The Minimum Description Length (MDL) principle recommends choosing the hypothesis that
minimizes the sum of these two description lengths of equ.
Where, codes C1 and C2 to represent the hypothesis and the data given the hypothesis
The above analysis shows that if we choose C1 to be the optimal encoding of hypotheses CH,
and if we choose C2 to be the optimal encoding CD|h, then hMDL = hMAP
Apply the MDL principle to the problem of learning decision trees from some training data.
What should we choose for the representations C1 and C2 of hypotheses and data?
• For C1: C1 might be some obvious encoding, in which the description length grows with
the number of nodes and with the number of edges
• For C2: Suppose that the sequence of instances (x1 . . .xm) is already known to both the
transmitter and receiver, so that we need only transmit the classifications (f (x1) . . . f
(xm)).
• Now if the training classifications (f (x1) . . .f(xm)) are identical to the predictions of the
hypothesis, then there is no need to transmit any information about these examples. The
description length of the classifications given the hypothesis ZERO
• If examples are misclassified by h, then for each misclassification we need to transmit
a message that identifies which example is misclassified as well as its correct
classification
• The hypothesis hMDL under the encoding C1 and C2 is just the one that minimizes the
sum of these description lengths.
98
NAIVE BAYES CLASSIFIER
• The naive Bayes classifier applies to learning tasks where each instance x is described
by a conjunction of attribute values and where the target function f (x) can take on any
value from some finite set V.
• A set of training examples of the target function is provided, and a new instance is
presented, described by the tuple of attribute values (al, a2.. .am).
• The learner is asked to predict the target value, or classification, for this new instance.
The Bayesian approach to classifying the new instance is to assign the most probable target
value, VMAP, given the attribute values (al, a2.. .am) that describe the instance
• The naive Bayes classifier is based on the assumption that the attribute values are
conditionally independent given the target value. Means, the assumption is that given
the target value of the instance, the probability of observing the conjunction (al, a2.. .am),
is just the product of the probabilities for the individual attributes:
Where, VNB denotes the target value output by the naive Bayes classifier
99
An Illustrative Example
• Let us apply the naive Bayes classifier to a concept learning problem i.e., classifying
days according to whether someone will play tennis.
• The below table provides a set of 14 training examples of the target concept PlayTennis,
where each day is described by the attributes Outlook, Temperature, Humidity, and
Wind
• Use the naive Bayes classifier and the training data from this table to classify the
following novel instance:
< Outlook = sunny, Temperature = cool, Humidity = high, Wind = strong >
• Our task is to predict the target value (yes or no) of the target concept PlayTennis for
this new instance
100
The probabilities of the different target values can easily be estimated based on their
frequencies over the 14 training examples
• P(P1ayTennis = yes) = 9/14 = 0.64
• P(P1ayTennis = no) = 5/14 = 0.36
Similarly, estimate the conditional probabilities. For example, those for Wind = strong
• P(Wind = strong | PlayTennis = yes) = 3/9 = 0.33
• P(Wind = strong | PlayTennis = no) = 3/5 = 0.60
Thus, the naive Bayes classifier assigns the target value PlayTennis = no to this new
instance, based on the probability estimates learned from the training data.
By normalizing the above quantities to sum to one, calculate the conditional probability that
the target value is no, given the observed attribute values
Estimating Probabilities
• We have estimated probabilities by the fraction of times the event is observed to occur
over the total number of opportunities.
• For example, in the above case we estimated P(Wind = strong | Play Tennis = no) by
the fraction nc /n where, n = 5 is the total number of training examples for which
PlayTennis = no, and nc = 3 is the number of these for which Wind = strong.
• When nc = 0, then nc /n will be zero and this probability term will dominate the quantity
calculated in Equation (2) requires multiplying all the other probability terms by this
zero value
• To avoid this difficulty we can adopt a Bayesian approach to estimating the probability,
using the m-estimate defined as follows
m -estimate of probability:
101
• p is our prior estimate of the probability we wish to determine, and m is a constant
called the equivalent sample size, which determines how heavily to weight p relative
to the observed data
• Method for choosing p in the absence of other information is to assume uniform
priors; that is, if an attribute has k possible values we set p = 1 /k.
• The naive Bayes classifier makes significant use of the assumption that the values of the
attributes a1 . . .an are conditionally independent given the target value v.
• This assumption dramatically reduces the complexity of learning the target function
A Bayesian belief network describes the probability distribution governing a set of variables
by specifying a set of conditional independence assumptions along with a set of conditional
probabilities
Bayesian belief networks allow stating conditional independence assumptions that apply to
subsets of the variables
Notation
• Consider an arbitrary set of random variables Y1 . . . Yn , where each variable Yi can
take on the set of possible values V(Yi).
• The joint space of the set of variables Y to be the cross product V(Y1) x V(Y2) x. . .
V(Yn).
• In other words, each item in the joint space corresponds to one of the possible
assignments of values to the tuple of variables (Y1 . . . Yn). The probability distribution
over this joint' space is called the joint probability distribution.
• The joint probability distribution specifies the probability for each of the possible
variable bindings for the tuple (Y1 . . . Yn).
• A Bayesian belief network describes the joint probability distribution for a set of
variables.
Conditional Independence
Where,
102
The above expression is written in abbreviated form as
P(X | Y, Z) = P(X | Z)
The naive Bayes classifier assumes that the instance attribute A1 is conditionally independent
of instance attribute A2 given the target value V. This allows the naive Bayes classifier to
calculate P(Al, A2 | V) as follows,
Representation
A Bayesian belief network represents the joint probability distribution for a set of variables.
Bayesian networks (BN) are represented by directed acyclic graphs.
The Bayesian network in above figure represents the joint probability distribution over the
boolean variables Storm, Lightning, Thunder, ForestFire, Campfire, and BusTourGroup
A Bayesian network (BN) represents the joint probability distribution by specifying a set of
conditional independence assumptions
• BN represented by a directed acyclic graph, together with sets of local conditional
probabilities
• Each variable in the joint space is represented by a node in the Bayesian network
• The network arcs represent the assertion that the variable is conditionally independent
of its non-descendants in the network given its immediate predecessors in the network.
• A conditional probability table (CPT) is given for each variable, describing the
probability distribution for that variable given the values of its immediate predecessors
103
The joint probability for any desired assignment of values (y1, . . . , yn) to the tuple of network
variables (Y1 . . . Ym) can be computed by the formula
Example:
Consider the node Campfire. The network nodes and arcs represent the assertion that Campfire
is conditionally independent of its non-descendants Lightning and Thunder, given its
immediate parents Storm and BusTourGroup.
This means that once we know the value of the variables Storm and BusTourGroup, the
variables Lightning and Thunder provide no additional information about Campfire
The conditional probability table associated with the variable Campfire. The assertion is
Inference
• Use a Bayesian network to infer the value of some target variable (e.g., ForestFire) given
the observed values of the other variables.
• Inference can be straightforward if values for all of the other variables in the network
are known exactly.
• A Bayesian network can be used to compute the probability distribution for any subset
of network variables given the values or distributions for any subset of the remaining
variables.
• An arbitrary Bayesian network is known to be NP-hard
104
Learning Bayesian Belief Networks
Affective algorithms can be considered for learning Bayesian belief networks from training
data by considering several different settings for learning problem
➢ First, the network structure might be given in advance, or it might have to be inferred from
the training data.
➢ Second, all the network variables might be directly observable in each training example,
or some might be unobservable.
• In the case where the network structure is given in advance and the variables are fully
observable in the training examples, learning the conditional probability tables is
straightforward and estimate the conditional probability table entries
• In the case where the network structure is given but only some of the variable values
are observable in the training data, the learning problem is more difficult. The learning
problem can be compared to learning weights for an ANN.
The gradient ascent rule which maximizes P(D|h) by following the gradient of ln P(D|h) with
respect to the parameters that define the conditional probability tables of the Bayesian network.
Let wijk denote a single entry in one of the conditional probability tables. In particular wijk
denote the conditional probability that the network variable Yi will take on the value yi, given
that its immediate parents Ui take on the values given by uik.
The gradient of ln P(D|h) is given by the derivatives for each of the wijk.
As shown below, each of these derivatives can be calculated as
Derive the gradient defined by the set of derivatives for all i, j, and k. Assuming the
training examples d in the data set D are drawn independently, we write this derivative as
105
We write the abbreviation Ph(D) to represent P(D|h).
106
THE EM ALGORITHM
The EM algorithm can be used even for variables whose value is never directly observed,
provided the general form of the probability distribution governing these variables is known.
• This problem setting is illustrated in Figure for the case where k = 2 and where the
instances are the points shown along the x axis.
• Each instance is generated using a two-step process.
• First, one of the k Normal distributions is selected at random.
• Second, a single random instance xi is generated according to this selected
distribution.
• This process is repeated to generate a set of data points as shown in the figure.
107
• To simplify, consider the special case
• The selection of the single Normal distribution at each step is based on choosing
each with uniform probability
• Each of the k Normal distributions has the same variance σ2, known value.
• The learning task is to output a hypothesis h = (μ1 , . . . ,μk) that describes the means of
each of the k distributions.
• We would like to find a maximum likelihood hypothesis for these means; that is, a
hypothesis h that maximizes p(D |h).
In this case, the sum of squared errors is minimized by the sample mean
• Our problem here, however, involves a mixture of k different Normal distributions, and
we cannot observe which instances were generated by which distribution.
• Consider full description of each instance as the triple (xi, zi1, zi2),
• where xi is the observed value of the ith instance and
• where zi1 and zi2 indicate which of the two Normal distributions was used to
generate the value xi
• In particular, zij has the value 1 if xi was created by the jth Normal distribution and 0
otherwise.
• Here xi is the observed variable in the description of the instance, and zil and zi2 are
hidden variables.
• If the values of zil and zi2 were observed, we could use following Equation to solve for
the means p1 and p2
• Because they are not, we will instead use the EM algorithm
EM algorithm
108
109