Professional Documents
Culture Documents
module_1_notes (1) (1)
module_1_notes (1) (1)
INTRODUCTION
Chapter 1 : Machine learning Landscape: what is ML?, Why, Types of ML, main
challenges of ML
Machine Learning vs. Just Downloading Data - Downloading data (e.g., Wikipedia)
doesn't make a computer learn or improve at tasks. Machine Learning requires using
data to improve performance on a specific task
1
Machine Learning approach
The program is much shorter, easier to maintain, and most likely more accurate
A spam filter based on Machine Learning techniques automatically learns which words
and phrases are good predictors of spam by detecting unusually frequent patterns of
words in the spam examples
if spammers notice that all their emails containing “4U” are blocked, they might start
writing “For U” instead. A spam filter using traditional programming techniques
would need to be updated to flag “For U” emails. If spammers keep working around
your spam filter, you will need to keep writing new rules forever
2
Automatically adapting to change
spam filter based on Machine Learning techniques automatically notices that “For U”
has become unusually frequent in spam flagged by users, and it starts flagging them
without your intervention
3
Machine Learning can help humans learn
ML algorithms can be inspected to see what they have learned (although for some
algorithms this can be tricky).
For instance, once the spam filter has been trained on enough spam, it can easily be
inspected to reveal the list of words and combinations of words that it believes are the
best predictors of spam. Sometimes this will reveal unsuspected correlations or new
trends, and thereby lead to a better understanding of the problem.
Applying ML techniques to dig into large amounts of data can help discover patterns
that were not immediately apparent. This is called data mining.
4
To summarize, Traditional programming is ideal for well-defined tasks with clear rules
and where precise control is needed. Machine Learning is a powerful tool for complex
problems with large datasets, where the ability to learn and adapt is crucial.
● Whether or not they can learn incrementally on the fly (online versus
batchlearning)
● Whether they work by simply comparing new data points to known data
points,or instead detect patterns in the training data and build a predictive
model, much like scientists do (instance-based versus model-based learning)
5
Supervised/Unsupervised Learning
There are four major categories according to the amount and type of supervision they get
during training
● supervised learning,
● unsupervised learning,
● Reinforcement Learning
Supervised learning
In supervised learning, the training data you feed to the algorithm includes the desired
According to the amount and type of supervision they get during training
6
A typical supervised learning task is classification. The spam filter is a good example of
this: it is trained with many example emails along with their class (spam or ham),and it
must learn how to classify new emails. Another typical task is to predict a target numeric
value, such as the price of a car, given a set of features (mileage, age, brand, etc.) called
predictors. This sort of task is called regression. To train the system, you need to give it
many examples of cars, including both their predictors and their labels (i.e., their prices).
Unsupervised learning
In unsupervised learning, the training data is unlabeled. The system tries to learn
7
without a teacher.
■ K-Means
■ DBSCAN
■ One-class SVM
■ Isolation Forest
■ Kernel PCA
■ Apriori
■ Eclat
Clustering
8
For example, say you have a lot of data about your blog’s visitors. You may want to run
a clustering algorithm to try to detect groups of similar visitors (Figure 1-8). At no point
do you tell the algorithm which group a visitor belongs to: it finds those connections
without your help. For example, it might notice that 40% of your visitors are males who
love comic books and generally read your blog in the evening, while 20% are young sci-
fi lovers who visit during the weekends, and so on. If you use a hierarchical clustering
algorithm, it may also subdivide each group into smaller groups. This may help you
target your posts for each group.
Visualization
representation of your data that can easily be plotted (Figure 1-9). These algorithms try
to preserve as much structure as they can (e.g., trying to keep separate clusters in the
input space from overlapping in the visualization), so you can understand how the data
is organized and perhaps identify unsuspected patterns.
9
Anomaly detection
It's often recommended to reduce the dimensionality of your training data using a
dimensionality reduction algorithm before feeding it to another machine learning
algorithm (like a supervised learning algorithm). This can lead to significant advantages:
the algorithm will run much faster, the data will require less disk and memory space, and
in some cases, it might even improve performance.
10
Unsupervised Anomaly Detection
Novelty detection is a very similar task. The distinction lies in the training data. Novelty
detection algorithms expect to see only normal data during training, while anomaly
detection algorithms are generally more tolerant and can often perform well even with a
small percentage of outliers present in the training set.
Finally, association rule learning is another common unsupervised task. The goal here is
to delve into vast amounts of data and discover interesting relationships between
attributes. Imagine you own a supermarket. Running an association rule learning
algorithm on your sales logs might reveal that customers who purchase barbecue sauce
and potato chips also tend to buy buns and hamburger patties, indicating a potential
association for a summer barbecue grill-out.
11
Semi - Supervised Learning
Some algorithms can handle training data that is partially labeled. This typically
involves a large amount of unlabeled data and a smaller amount of labeled data. This
approach is called semi-supervised learning (Figure 1-11).
Certain photo-hosting services, like Google Photos, exemplify this concept. When you
upload your family photos, the service automatically recognizes that the same person,
let's call them person A, appears in photos 1, 5, and 11, while another person, person B,
shows up in photos 2, 5, and 7. This represents the unsupervised aspect of the algorithm
(clustering). Now, the system only needs you to identify these people. With just one
label per person, it can name everyone in every photo, making photo searching
significantly easier.
Reinforcement Learning
For instance, many robots utilize reinforcement learning algorithms to learn how to
12
walk. DeepMind's AlphaGo program also serves as a prime example of reinforcement
learning. It grabbed headlines in May 2017 when it defeated the world champion Ke Jie
at the game of Go. AlphaGo learned its winning policy by analyzing millions of games
and then playing numerous games against itself. It's important to note that learning was
disabled during the matches against the champion; AlphaGo was simply applying the
policy it had already acquired.
Batch learning trains on all data at once, making it slow and resource-intensive. This is
suitable for offline learning scenarios where the system is trained, deployed, and doesn't
update itself (e.g., initial spam filter training).
13
● Rapidly Changing Data: Situations like stock price prediction require more
reactive solutions.
● Limited Resources: Batch learning is impractical for resource-constrained
environments (e.g., smartphones, robots) that can't store large amounts of data or
perform lengthy computations.
In these cases, incremental learning algorithms, which learn from data gradually, are a
better choice.
Online learning
Online learning tackles data continuously, one instance or mini-batch at a time (Figure 1-
13). This makes it:
● Fast and Adaptable: Ideal for constantly changing data streams (e.g., stock prices)
and autonomous systems that need to learn on the go.
● Resource-Friendly: Online learners discard processed data, saving storage space.
This is useful for systems with limited resources (e.g., smartphones).
● Scalable to Big Data: Out-of-core learning allows processing massive datasets in
parts (Figure 1-14). However, it's typically done offline.
● A key parameter is the learning rate, which controls how quickly the system adapts:
● High learning rate: Adapts rapidly to new data but forgets old data quickly (e.g., a
spam filter might miss new spam types).
● Low learning rate: Learns slowly but is less sensitive to noise or outliers.
A major challenge is bad data, which can gradually degrade performance. This is risky
for live systems (e.g., a malfunctioning robot sensor or spam affecting search rankings).
To mitigate this:
● Closely monitor the system and switch off learning if performance drops.
14
Instance-Based Versus Model-Based Learning
Instance-based learning
This simplest form involves learning by heart. A basic spam filter might flag emails
identical to those already flagged by users, but this isn't very effective.
Instance-Based Learning: This improves upon memorization. Instead of just matching
identical emails, the filter could flag similar ones. To measure similarity, the system
might count common words between emails. An email with many common words to
known spam would be flagged.
Instance-based learning essentially memorizes examples and uses a similarity measure to
classify new cases. In Figure 1-15, the new instance is classified as a triangle because
most similar memorized examples belong to that class.
Model-based learning
Data Acquisition and Exploration:
15
1. You gather data from relevant sources (e.g., Better Life Index, IMF) on life
satisfaction and GDP per capita for various countries (Table 1-1).
2. This data might have some randomness (noise).
Model Selection:
Based on the data, you choose a model to represent the relationship. In this
case, you select a linear model where life satisfaction is a function of GDP per
capita (Equation 1-1).
Model Training:
1. To assess how well the model fits the data, you define a cost function that
measures the distance between the model's predictions and the actual life
satisfaction values.
2. The goal is to minimize this cost function. A training algorithm (e.g., Linear
Regression) then finds the parameters (theta values) that make the linear
model best fit the training data.
Prediction:
1. Once trained, you can use the model to predict life satisfaction for new
countries. For instance, if you don't have data for Cyprus, you can look up its
GDP per capita ($22,587) and use the model to predict a life satisfaction
score around 5.96 (Equation 1-1 with the trained theta values).
Evaluation (Optional):
1. The text mentions that if the predictions aren't accurate, you might need to:
This simplified overview outlines the steps involved in a typical Machine Learning
project. The next chapter will provide a hands-on experience.
16
Equation 1-1. A simple linear model
life_satisfaction = θ0 + θ1 × GDP_per_capita
This model has two model parameters, θ0 and θ1 . 5 By tweaking these parameters, you
can make your model represent any linear function, as shown in Figure 1-18.
17
18
Main Challenges of Machine Learning
Main challenges in Machine Learning can be boiled down to two issues: bad data and bad
algorithms.
Bad Data: This refers to issues with the training data used to train the machine
learning model. One specific problem is having an insufficient quantity of data. Unlike
a toddler who can learn about apples with just a few examples, machine learning
algorithms typically need a lot of data to function well. This can range from thousands
of examples for simple tasks to millions for complex tasks like image recognition.
19
problems, data might be more important than complex algorithms. However, small and
medium datasets are still common, and acquiring more data can be expensive, so
algorithms remain valuable.
For instance, our initial training data for the happiness vs. wealth model lacked some
countries. Adding these missing countries (Figure 1-21) significantly alters the model's
prediction (solid line vs. dotted line). This highlights two issues:
Limited Representativeness: The simple linear model might not be suitable. Very rich
countries seem less happy, and some poor countries appear happier than rich ones.
Using a representative training set is crucial but challenging. Small samples suffer from
sampling noise (unrepresentative data due to chance), and even large samples can be
biased if collected incorrectly (sampling bias).
20
A Famous Example of Sampling Bias
The text explains how sampling bias can distort results by giving two examples:
● Problem: The pollsters used phone directories, magazine subscriptions, and club
memberships to find people to survey. These sources tend to have more wealthy people,
who at that time leaned Republican.
● Bias: The sample was skewed towards wealthy Republicans, not representative of the
entire population.
● Result: The poll predicted a win for the Republican candidate (Landon) who actually lost
to the Democrat (Roosevelt).
● Problem: The training data came from YouTube searches for "funk music." YouTube's
search prioritizes popular artists and local variations can influence results (e.g., "funk
carioca" in Brazil).
● Bias: The system would be biased towards popular artists and specific styles of funk
music, neglecting the genre's wider range.
● Result: The system wouldn't recognize a broad variety of funk music videos.
The text highlights that sampling bias can lead to misleading conclusions. Just because a
sample seems large (like the millions of people reached by the Literary Digest poll)
doesn't mean it's accurate if the way it was collected is biased.
Poor-Quality Data
Dirty training data (errors, outliers, noise) hinders a system's ability to learn patterns,
reducing its performance. Cleaning data is crucial, and data scientists spend a significant
amount of time on it.
21
Here's how to address common issues:
Irrelevant Features
As the saying goes, "garbage in, garbage out" applies to machine learning. The quality of
training data directly impacts the system's learning ability. A crucial factor for success is
crafting a robust set of features for training. This process, called feature engineering,
involves three key techniques:
1. Feature Selection: Choosing the most informative features from existing ones.
2. Feature Extraction: Combining existing features to create a more meaningful
feature. Dimensionality reduction techniques can be helpful here.
3. Feature Creation: Gathering new data to generate entirely new features.
By carefully selecting, extracting, and potentially creating new features, machine learning
practitioners lay a solid foundation for successful model training.
22
● Model Simplification: Choose models with fewer parameters (e.g., linear vs.
high-degree polynomial), reduce training data attributes, or apply constraints to
the model.
● Increased Training Data: Gather more data to provide the model with a richer
foundation for learning.
● Reduced Training Data Noise: Cleanse the training data by fixing errors and
removing outliers.
23
model trained without some countries. The dashed line is the model trained with all
countries, and the solid line is a regularized linear model trained with the same data as
the original model. As you can see, regularization forces a smaller slope, slightly
compromising the fit on the training data but enabling better generalization to new
examples.
The amount of regularization applied during learning is controlled by a
hyperparameter. Unlike model parameters, hyperparameters are external to the
learning algorithm. They are set before training and remain constant throughout. A
very high regularization hyperparameter value will result in an almost flat model
(near-zero slope). While this significantly reduces the risk of overfitting, it also
hinders the algorithm's ability to find an optimal solution. Tuning hyperparameters is
a crucial aspect of building machine learning systems, and we'll delve deeper into this
concept in the next chapter.
● Enhance Model Complexity: Utilize models with more parameters to allow for
greater flexibility in learning the data's structure.
● Feature Engineering: Craft more informative features that better represent the
underlying relationships within the data.
● Relax Model Constraints: Reduce regularization hyperparameters that might be
limiting the model's ability to learn complex patterns.
Stepping Back
24
Machine learning empowers machines to improve at tasks through data analysis,
eliminating the need for explicit rule coding. Various ML systems exist, categorized by
supervision (supervised vs. unsupervised), processing style (batch vs. online), and
learning approach (model-based vs. instance-based).
A typical ML project involves gathering data for a training set, which is then fed into a
learning algorithm. Model-based algorithms fine-tune parameters to fit a model to the
training data, enabling good predictions on both the training set and hopefully, new cases
as well. Instance-based algorithms, on the other hand, memorize examples and use
similarity measures to generalize to new instances.
The success of an ML project hinges on several factors:
Training a model is just the first step. Evaluating its performance on unseen data and fine-
tuning it as necessary are essential for optimal results. We'll delve into these techniques
next.
A better approach is splitting data into training and test sets. As the names suggest,
the model is trained on the training set and tested on the test set. The error rate on
unseen data is the generalization error (out-of-sample error). Evaluating the model on
the test set provides an estimate of this error, indicating how well the model performs
on entirely new data.
A low training error (few mistakes on the training set) paired with a high
generalization error suggests overfitting. The model memorizes the training data but
fails to generalize to unseen examples.
25
different values. Imagine finding the best value with a model achieving 5% error. This
model, however, performs poorly in production (15% error). Why?
The issue lies in repeatedly measuring generalization error on the test set. Adapting
the model and hyperparameters creates a model optimized for that specific data, likely
performing poorly on new data.
A common solution is holdout validation. Simply hold out part of the training set to
evaluate candidate models and pick the best one. This new set becomes the validation
set. Here's the process:
● Train multiple models with various hyperparameters on the reduced training set
(full training set minus validation set).
● Select the model performing best on the validation set.
● Train the best model on the full training set (including the validation set) to get
the final model.
● Evaluate the final model on the test set to estimate generalization error.
This works well, but a small validation set leads to imprecise evaluations, potentially
selecting a suboptimal model. Conversely, a large validation set shrinks the remaining
training set. Since the final model is trained on the full set, comparing models trained
on a much smaller set is disadvantageous. It's like picking the fastest sprinter for a
marathon!
Repeated cross-validation tackles this issue. Here, many small validation sets are
used. Each model is evaluated once per validation set, trained on the remaining data.
Averaging these evaluations provides a more accurate performance measure.
However, the training time increases with the number of validation sets.
Data Mismatch
Data mismatch can occur when training data is abundant but not representative of real-
world use. Imagine building a mobile app to identify flower species from pictures. While
millions of flower images are downloadable online, they might not reflect the quality
captured by the app's camera. If you only have 10,000 representative pictures (taken by
the app), prioritize using them for validation and testing sets. Split them randomly,
ensuring no duplicates exist in either set.
Training on web images can lead to misleading validation set performance. Poor
performance could indicate overfitting or data mismatch. To diagnose this, Andrew Ng
suggests a separate "train-dev" set from the web images. Evaluate the trained model on
this set. Good performance here suggests no overfitting, and poor performance points to
data mismatch. Techniques like preprocessing web images to resemble app-captured
pictures can address this. Conversely, poor train-dev set performance indicates
26
overfitting. Address this by simplifying the model, using regularization, acquiring more
training data, or cleaning the existing data as previously discussed.
27
WELL-POSED LEARNING PROBLEMS
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
29
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.
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.
30
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.
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
31
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:
● x5: the number of black pieces threatened by red (i.e., which can be captured on
red's next turn)
● x6: the number of red pieces threatened by black
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.
32
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))
Specify the learning algorithm for choosing the weights wi to best fit the set of
training examples {(b, Vtrain(b))}
A first step is to define what we mean by the bestfit to the training data.
One common approach is to define the best hypothesis, or set of weights, as that
which minimizes the squared error E between the training values and the values
predicted by the hypothesis.
33
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
̂
wi ← wi + ƞ (Vtrain (b) - V (b)) xi
Here ƞ is a small constant (e.g., 0.1) that moderates the size of the weight
̂
● When the error (Vtrain(b)- V (b)) is zero, no weights are changed.
̂ ̂
● When (Vtrain(b) - V (b)) is positive (i.e., when V (b) is too low), then
each weight is increased in proportion to the value of its corresponding
̂
feature. This will raise the value of V (b), reducing the error.
● If the value of some feature xi is zero, then its weight is not altered
regardless of the error, so that the only weights updated are those whose
features actually occur on the training example board.
34
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
35
PERSPECTIVES AND ISSUES IN MACHINE LEARNING
36
● 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?
CONCEPT LEARNING
Consider the example task of learning the target concept "Days on which Aldo enjoys
his favorite water sport”
37
2 Sunny Warm High Strong Warm Same Yes
3 Rainy Cold High Strong Warm Change No
4 Sunny Warm High Strong Cool Change Yes
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?
The hypothesis that PERSON enjoys his favorite sport only on cold days with high
humidity is represented by the expression
(?, Cold, High, ?, ?, ?)
Notation
38
● 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
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
● 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:
39
● Sky (with possible values Sunny, Cloudy, and Rainy),
● Determine:
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.
● Concept learning can be viewed as the task of searching through a large space of
hypotheses implicitly defined by the hypothesis representation.
40
● 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.
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
41
● 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
42
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>
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>
43
● Consider the fourth training example
x4 = <Sunny Warm High Strong Cool Change>, +
Unanswered by FIND-S
44
The key idea in the CANDIDATE-ELIMINATION algorithm is to output a
description of the set of all hypotheses consistent with the training examples
Representation
45
● List-Then-Eliminate works in principle, so long as version space is finite.
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:
46
1. let g, h, s be arbitrary members of G, H, S respectively with g g h g s
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
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
• 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
47
• 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 , , , , ,
48
● 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
● 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
49
Given that there are six attributes that could be specified to specialize G2, 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
50
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.
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
51
"Sky = Sunny or Sky = Cloudy."
● 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.
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
52
(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
c
= {(x , c(x))} be an arbitrary set of training
examples of c.
53
● Let L (x , D ) denote the
classification assigned to the
instance x
by L after training on
54
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
55
56