Docsity

Machine Learning module 1, Study notes of Machine Learning

Toggle sidebar
bg1
Machine Learning
15CS73
1
Deepak D, Asst. Prof., Dept. of CS&E, Canara Engineering College, Mangaluru
MODULE 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 successful applications of machine learning
Learning to recognize spoken words
Learning to drive an autonomous vehicle
Learning to classify new astronomical structures
Learning to play world-class backgammon
Why is Machine Learning Important?
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”.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Machine Learning module 1 and more Study notes Machine Learning in PDF only on Docsity!

MODULE 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 successful applications of machine learning

 Learning to recognize spoken words  Learning to drive an autonomous vehicle  Learning to classify new astronomical structures  Learning to play world-class backgammon

Why is Machine Learning Important?

 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”.

WELL-POSED LEARNING PROBLEMS

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.

To have a well-defined learning problem, three features needs to be identified:

  1. The class of tasks
  2. The measure of performance to be improved
  3. The source of experience

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.

Fig: Checker game board A checkers learning problem :  Task T: playing checkers  Performance measure P: percent of games won against opponents  Training experience E: playing practice games against itself

2. A handwriting recognition learning problem:  Task T: recognizing and classifying handwritten words within images  Performance measure P: percent of words correctly classified  Training experience E: a database of handwritten words with given classifications 3. A robot driving learning problem :  Task T: driving on public four-lane highways using vision sensors  Performance measure P: average distance travelled before an error (as judged by human overseer)  Training experience E: a sequence of images and steering commands recorded while observing a human driver

  1. The degree to which the learner controls the sequence of training examples

For example, in checkers game: The learner might depends on the teacher to select informative board states and to provide the correct move for each.

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.

  1. How well it represents the distribution of examples over which the final system performance P must be measured

For example, in checkers game: In checkers learning scenario, the performance metric P is the percent of games the system wins in the world tournament.

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.

2. Choosing the Target Function

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.

  1. Let ChooseMove be the target function and the notation is

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

  1. An alternative target function is an evaluation function that assigns a numerical score to any given board state Let the target function V and the notation V : B → R

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) = -  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

3. Choosing a Representation for the Target Function

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:

 xl: the number of black pieces on the board  x 2 : the number of red pieces on the board  x 3 : the number of black kings on the board  x 4 : the number of red kings on the board  x 5 : the number of black pieces threatened by red (i.e., which can be captured on red's next turn)  x 6 : the number of red pieces threatened by black

Thus, learning program will represent as a linear function of the form

  1. Adjusting the weights

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.

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

wi ← wi + ƞ (Vtrain (b) - V̂(b)) xi

Here ƞ is a small constant (e.g., 0.1) that moderates the size of the weight update.

Working of weight update rule

 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.

5. The Final Design The final design of checkers learning system can be described by four distinct program modules that represent the central components in many learning systems 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

 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

 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).

Definition: Concept learning - Inferring a Boolean-valued function from training examples of its input and output

A CONCEPT LEARNING TASK

Consider the example task of learning the target concept "Days on which Aldo enjoys

his favorite water sport”

Example Sky AirTemp Humidity Wind Water Forecast EnjoySport 1 Sunny Warm Normal Strong Warm Same Yes 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?

What hypothesis representation is provided to the learner?

 Let’s consider a simple representation in which each hypothesis consists of a conjunction of constraints on the instance attributes.  Let each hypothesis be a vector of six constraints, specifying the values of the six attributes Sky, AirTemp, Humidity, Wind, Water , and Forecast.

 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).

 Hypotheses H : Each hypothesis is described by a conjunction of constraints on the attributes Sky, AirTemp, Humidity, Wind, Water , and Forecast. The constraints may be "?" (any value is acceptable), “Φ” (no value is acceptable), or a specific value.

 Target concept c : EnjoySport : X → {0, l}  Training examples D : Positive and negative examples of the target function

 Determine:  A hypothesis h in H such that h(x) = c(x) for all x in X.

Table: The EnjoySport concept learning task.

The inductive learning hypothesis

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 AS SEARCH

 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

General-to-Specific Ordering of Hypotheses

Consider the two hypotheses h 1 = (Sunny, ?, ?, Strong, ?, ?) h 2 = (Sunny, ?, ?, ?, ?, ?)

 Consider the sets of instances that are classified positive by hl and by h 2.  h 2 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 h 2. Therefore, h 2 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

( xX ) [(hk (x) = 1) → (hj (x) = 1)]

To illustrate this algorithm, assume the learner is given the sequence of training examples from the EnjoySport task

Example Sky AirTemp Humidity Wind Water Forecast EnjoySport 1 Sunny Warm Normal Strong Warm Same Yes 2 Sunny Warm High Strong Warm Same Yes 3 Rainy Cold High Strong Warm Change No 4 Sunny Warm High Strong Cool Change Yes

 The first step of FIND-S is to initialize h to the most specific hypothesis in H h - (Ø, Ø, Ø, Ø, Ø, Ø)

 Consider the first training example x 1 = , +

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 h 1 =

 Consider the second training example x 2 = <Sunny, Warm, High, 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 h 2 = <Sunny Warm? Strong Warm Same>

 Consider the third training example x3 = <Rainy, Cold, High, Strong, Warm, Change>, -

Upon encountering the third training the algorithm makes no change to h. The FIND-S algorithm simply ignores every negative example. h 3 = < Sunny Warm? Strong Warm Same>

 Consider the fourth training example x 4 = , +

The fourth example leads to a further generalization of h h 4 = < Sunny Warm? Strong?? >

The key property of the FIND-S algorithm  FIND-S is guaranteed to output the most specific hypothesis within H that is consistent with the positive training examples  FIND-S algorithm’s final hypothesis will also be consistent with the negative examples provided the correct target concept is contained in H, and provided the training examples are correct.

Unanswered by FIND-S

  1. Has the learner converged to the correct target concept?
  2. Why prefer the most specific hypothesis?
  3. Are the training examples consistent?
  4. What if there are several maximally specific consistent hypotheses?

A More Compact Representation for Version Spaces

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

G { gH | Consistent ( g, D )( g'H )[( g'g g )  Consistent ( g', 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.

S { sH | Consistent ( s, D )( s'H )[( sgs' )  Consistent ( s', D )]}

Theorem: Version Space representation theorem

Theorem: Let X be an arbitrary set of instances and Let H be a set of Boolean-valued hypotheses defined over X. Let c: X →{O, 1} be an arbitrary target concept defined over X, and let D be an arbitrary set of training examples {(x, c(x))). For all X, H, c, and D such that S and G are well defined,

VSH,D= { hH | ( sS ) ( gG ) ( gg hg s )}

To Prove:

  1. Every h satisfying the right hand side of the above expression is in VS (^) H, D
  2. Every member of VS (^) H, D satisfies the right-hand side of the expression

Sketch of proof:

  1. let g, h, s be arbitrary members of G, H, S respectively with gg hg s  By the definition of S, s must be satisfied by all positive examples in D. Because hg 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 gg 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

CANDIDATE-ELIMINATION Learning Algorithm

The CANDIDATE-ELIMINTION algorithm computes the version space containing all hypotheses from H that are consistent with an observed sequence of training examples.

Initialize G to the set of maximally general hypotheses in H Initialize S to the set of maximally specific hypotheses in H For each training example d, do

  • If d is a positive example
    • Remove from G any hypothesis inconsistent with d
    • For each hypothesis s in S that is not consistent with d
      • Remove s from S
      • Add to S all minimal generalizations h of s such that
        • h is consistent with d, and some member of G is more general than h
      • Remove from S any hypothesis that is more general than another hypothesis in S
  • 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

CANDIDATE- ELIMINTION algorithm using version spaces

An Illustrative Example

Example Sky AirTemp Humidity Wind Water Forecast EnjoySport 1 Sunny Warm Normal Strong Warm Same Yes 2 Sunny Warm High Strong Warm Same Yes 3 Rainy Cold High Strong Warm Change No 4 Sunny Warm High Strong Cool Change Yes