Unit 5-1
Unit 5-1
UNIT – 5
Pattern Recognition
Pattern recognition is a branch of machine learning that focuses on the recognition of patterns and
regularities in data, It is the study of how machines can observe the environment intelligently , learn to
distinguish patterns of interest from their backgrounds and make reasonable & correct decisions about the
different classes of objects. Patterns may be a finger print image, handwritten cursive word, a human face,
iris of human eye ora speech signal. These examples are called input stimuli. Recognition establishes a
close match between some new stimulus and previously stored stimulus patterns. Pattern recognition
systems are in many cases trained from labeled "training" data (supervised learning), but when no labeled
data are available other algorithms can be used to discover previously unknown patterns (unsupervised
learning). At the most abstract level patterns can also be some ideas , concepts , thoughts , procedures
Activated in human brain and body. This is known as the study of human psychology (Cognitive
Science)
Example: In automatic sorting of integrated circuit amplifier packages, there can be three possible types :
metal –cane , dual –in-line and flat pack. The unknown object should be classified as being one of these
types.
After this appropriate neural network set up is trained with these attribute sets to make system learn for
unknown set of patterns and objects.
Steps of classification process are as follows:
Step 1. Stimuli produced by the objects are perceived by sensory devices. Important attributes like ( shape ,
size , color , texture) produce the strongest inputs. Data collection involves identification
of attributes of objects and creating Measurement space.
Measurement space: This is the set of all pattern attributes which are stored in a vector form.
It is a range of characteristic attribute values. In vector form measurement space is also called
observation space /data space. E.g : W = [ W1 , W2 ,……,Wn-1, Wn ] for n pattern classes.
Step 2.After this features are selected and feature space vector is designed. The range of subset of
attribute values is called Feature Space F. This subset represents a reduction in attribute space and pattern
classes are divided into sub classes. Feature space signifies the most important attributes of a pattern
class observed in measurement space. Feature space is shown in smaller size than M- space.
Step 3.AI models based on probability theory, E.g : Bayesian Model and Hidden Markov Models are
Used for grouping or clustering the objects. Attributes selected are those which provide High Inter
Class and Low Inter Class groupings.
Step 5.In evaluation of classifier testing is performed. In this an unknown pattern is given to the PR
System for identifying its correct class .Using the selected attribute values, object/class
characterization models are learned by forming generalized prototype descriptors, Classification
rules or Decision Functions. The range of decision function values is known as Decision space D
of r – dimensions. We also evaluate performance, efficiency of the classifier for further
improvement.
Recognition of familiar objects is achieved through the application of the rules learned in step
4, by comparing and matching of objects feature with stored models.
This system comprises of mainly five components namely sensing, segmentation, feature extraction,
classification and post processing.
All of these together generates a System and works as follows:
1. Sensing and Data Acquisition: It includes, various properties that describes the object, such as its
entities and attributes which are captured using sensing device.
2. Segmentation: Data objects are segmented into smaller segments in this step.
3. Post Processing & Decision: Certain refinements and adjustments are done as per the changes in
features of the data objects which are in the process of recognition. Thus, decision making can be
done once, post processing is completed.
Approaches of PR system
1). Template Matching 2). Statistical Approach 3). Syntactic Approach 4). ANN Approach.
TEMPLATE MATCHING: This approach of pattern recognition is based on finding the similarity
between two entities ( points , curves / shapes) of same type. A 2-D shape or a prototype of a pattern to be
recognized is available. Template is a d x d mask or window. Pattern to be recognized is matched against
stored template in a knowledge base.
NEURAL NETWORKS APPROACH: Artificial neural networks are massively parallel computing
systems consisting of extremely large number of simple processors with many interconnections.
Network Models attempt to use some principles like Learning , Generalization , Adaptivity, Fault
Tolerance , Distributed representation & computation. Learning process involves updating network
architecture and connection mapping and weights so that network may perform better clustering.
Measurement space: This is the set of all pattern attributes which are stored in a vector form.
It is a range of characteristic attribute values. In vector form measurement space is also called
observation space /data space. E.g : W = [ W1 , W2 ,……,Wn-1, Wn ] for n pattern classes.
W is a pattern vector. Let X = width.[ ] , X is a pattern vector for flower , x1 is petal length and x2 is
𝑥
𝑥2 1
petal
Feature Space: The range of subset of attribute values is called Feature Space F. This subset represents a
reduction in attribute space and pattern classes are divided into sub classes. Feature space signifies the most
important attributes of a pattern class observed in measurement space.
d1(x) , d2 (x) ,……dw (x). with property that if a pattern X belongs to class Wi , then
di(X) > dj (x) , for j = 1, 2, ….,w ; j ≠ i.
Linear decision function can be in the form of line equation as : d (X) = W1 X1 + W1 X1 for
a 2-D pattern vector.
If d (x) =0 then it is
indeterminate.
Class.
Fig : (a)
Decision Boundary: di (x) – dj ( x) = 0 . Aim is to identify decision boundary between two
classes by a Single function dij (x) = di(x) – dj (x) =0.
When a line can be found that separates classes into two or more clusters we say classes are Linearly
Separable else they are called Non Linear Separable Classes.
Estimation model consists of a number of parameters. So, in order to calculate or estimate the parameters of
Logarithmic Form : Since Log makes the expressions simpler in the form of addition , 𝜃 that
maximizes log likelihood also maximizes likelihood. If number of parameters to be estimated is p,
we let 𝜽 denote p – component vector i.e 𝜽 = (𝜽𝟏 , 𝜽𝟐 , 𝜽𝟑 … . . 𝜽𝒑−𝟏, 𝜽𝒑)𝒕.
K –Nearest Neighbor Estimation:
1.
Calculate “d(x,xi)” i =1, 2,….., n; where d denotes the Euclidean distance between the
points.
2.
Arrange the calculated n Euclidean distances in non-decreasing order.
3.
Let k be a +ve integer, take the first k distances from this sorted list.
4.
Find those k-points corresponding to these k-distances.
( B ) Advantages of KNN :
1. Easy to understand
2. No assumptions about data
3. Can be applied to both classification and regression
4. Works easily on multi-class problems
Disadvantages are:
1. Memory Intensive / Computationally expensive
2. Sensitive to scale of data
3. Not work well on rare event (skewed) target variable
4. Struggle when high number of independent variables
Clustering
Cluster analysis or clustering is the task of grouping a set of objects in such a way that objects in the
same group (called a cluster) are more similar (in some sense) to each other than to those in other groups
(clusters). It is a main task of exploratory data mining, and a common technique for statistical data
analysis, used in many fields, including machine learning, pattern recognition, image
analysis, information retrieval, bioinformatics, data compression, and computer graphics.
. Partitioning algorithms are clustering techniques that subdivide the data sets into a set of k groups, where
k is the number of groups pre-specified by the analyst. There are different types of partitioning clustering
methods. The most popular is the K-means clustering , in which, each cluster is represented by the center
or means of the data points belonging to the cluster. The K-means method is sensitive to outliers.
To measure the quality of clustering ability of any partitioned data set, criterion function is used.
1. Consider a set , B = { x1,x2,x3…xn} containing “n” samples, that is partitioned exactly into “t”
disjoint subsets i.e. B1, B2,…..,Bt.
The main highlight of these subsets is, every individual subset represents a cluster.
Sample inside the cluster will be similar to each other and dissimilar to samples in other clusters.
To make this possible, criterion functions are used according the occurred situations.
For Example:
Subject A B
1 1.0 1.0
2 1.5 2.0
3 3.0 4.0
4 5.0 7.0
5 3.5 5.0
6 4.5 5.0
7 3.5 4.5
This data set is to be grouped into two clusters. As a first step in finding a sensible initial partition, let the
A & B values of the two individuals furthest apart (using the Euclidean distance measure), define the
initial cluster means, giving:
Mean Vector
Individual
(centroid)
Group 1 1 (1.0, 1.0)
Group 2 4 (5.0, 7.0)
The remaining individuals are now examined in sequence and allocated to the cluster to which they are
closest, in terms of Euclidean distance to the cluster mean. The mean vector is recalculated each time a
new member is added. This leads to the following series of steps:
Cluster 1 Cluster 2
Mean Mean
Step Individual Vector Individual Vector
(centroid) (centroid)
1 1 (1.0, 1.0) 4 (5.0, 7.0)
2 1, 2 (1.2, 1.5) 4 (5.0, 7.0)
3 1, 2, 3 (1.8, 2.3) 4 (5.0, 7.0)
4 1, 2, 3 (1.8, 2.3) 4, 5 (4.2, 6.0)
5 1, 2, 3 (1.8, 2.3) 4, 5, 6 (4.3, 5.7)
6 1, 2, 3 (1.8, 2.3) 4, 5, 6, 7 (4.1, 5.4)
Now the initial partition has changed, and the two clusters at this stage having the following
characteristics:
Mean Vector
Individual
(centroid)
Cluster 1 1, 2, 3 (1.8, 2.3)
Cluster 2 4, 5, 6, 7 (4.1, 5.4)
But we cannot yet be sure that each individual has been assigned to the right cluster. So, we compare each
individual’s distance to its own cluster mean and to that of the opposite cluster. And we find:
Distance to Distance to
mean mean
Individual
(centroid) of (centroid)
Cluster 1 of Cluster 2
1 1.5 5.4
2 0.4 4.3
3 2.1 1.8
4 5.7 1.8
5 3.2 0.7
6 3.8 0.6
7 2.8 1.1
Only individual 3 is nearer to the mean of the opposite cluster (Cluster 2) than its own (Cluster 1). In
other words, each individual's distance to its own cluster mean should be smaller that the distance to the
other cluster's mean (which is not the case with individual 3). Thus, individual 3 is relocated to Cluster 2
resulting in the new partition:
Mean Vector
Individual
(centroid)
Cluster 1 1, 2 (1.3, 1.5)
Cluster 2 3, 4, 5, 6, 7 (3.9, 5.1)
4. The points in each cluster tend to be near Combines the classification of the K
each other. nearest points
features, the harder it gets to visualize the training set and then work on it. Sometimes, most of these
features are correlated, and hence redundant. This is where dimensionality reduction algorithms come into
play. Dimensionality reduction is the process of reducing the number of random variables under
consideration, by obtaining a set of principal variables. It can be divided into feature selection and feature
extraction. The various methods used for dimensionality reduction include:
A very common problem in statistical pattern recognition is of Feature Selection i.e. a process of
transforming Measurement Space to Feature Space (Set of data which are of interest).
Transformation reduces the dimensionality of data features . Let we have a m- dimensional vector , X =
[𝑋1, 𝑋2, … . . 𝑋𝑚 ] and we want to convert it in l-dimensions ( where l << m) .
This reduction causes mean square error . So we need to find that does there exist an invertible transform T,
such that truncation of 𝑇𝑥 is optimal in terms of Mean Square Error. So T must have some components of
low variance( 𝜎2) where 𝝈𝟐 = E [ (𝒙 − 𝝁)𝟐 ] , E is expectation function, x is random variable , and 𝜇 is
mean value. 𝝁 = 𝟏 ∑𝒎 𝑿
𝒙 𝒌=𝟏 𝒌
PCA: This is a mathematical procedure that uses Orthogonal transforms to convert a set of observations
of possibly correlated variables into a set of linearly uncorrelated variables known as Principal
Components. So here we preserve the most variance with reduced dimensions and minimum mean
square error.
Number of principal components are less than or equal to number of original variables.
First Principal component has largest variance. Successively it decreases.
These are defined by Best Eigen Vectors of Covariance Matrix of vector X.
• S I 0
•
The eigenvalues, 1, 2, ... p are the variances of the coordinates on each principal component
axis. Coordinates of eac…h object i on the kth principal axis, known as the scores on PC k, are
computed as mentioned below:
zki u1k u2k u pk x pi
x1i x2i
Let 𝜇 be the mean vector (taking the mean of all rows)
Steps of PCA
•
•
Adjust the original data by the mean 𝜑 = Xk – 𝜇
•
Compute the covariance matrix C of adjusted X
•
Find the eigenvectors and eigenvalues of C.
•
For matrix C, vectors e (=column vector) having same direction as Ce :
•
eigenvectors of C is e such that Ce=e,
•
is called an eigenvalue of C. Ce=e (C-I)e=0
PCA finds components that are useful for data representation , but drawback is that PCA can not
discriminate components /data between different classes. If we group all the samples , then those
directions that are discarded by PCA might be exactly the directions needed for distinguishing
between classes.
PCA is based on representation for efficient direction
LDA is based on discrimination for efficient direction.
Objective of LDA is to perform dimensionality reduction while preserving as much of the class
discrimination information as possible. Here in LDA data is projected from d – dimensions onto a line.
If the samples formed well separated compact clusters in d- space then projection onto an arbitrary line
will usually produce poor recognition performance. By rotating the line we can find an orientation for
which projected samples are well separated.
In order to find a good projection vector, we need to define a measure of separation between the
projections.
The solution proposed by Fisher is to maximize a function that represents the difference between the
means, normalized by a measure of the within-class variability, or the so-called scatter. • For each class
we define the scatter, an equivalent of the variance, as; (sum of square differences between the projected
samples and their class mean).
The Fisher linear discriminant is defined as the linear function w Tx that maximizes the criterion function:
(the distance between the projected means normalized by the within class scatter of the projected
samples.
In order to find the optimum projection w*, we need to express J(w) as an explicit function of w.. We will
define a measure of the scatter in multivariate feature space x which are denoted as scatter matrices.
A good example of such a system is classifying a set of new documents into positive or negative sentiment
groups, based on other documents which have already been classified as positive or negative. Similarly, we
could classify new emails into spam or non-spam, based on a large corpus of documents that have already
been marked as spam or non-spam by humans. SVMs are highly applicable to such situations.
SVM is an approximate implementation of Structural Risk Minimization.
Error rate of a machine on test data is bounded by the sum of training error rate and term
that depends on Vapnik Chervonenki’s dimension.
SVM sets first term to zero and minimizes second term. We use SVM learning algorithm
to construct following three types of learning machines :
notation for this equation by introducing the summation sign: b0+p∑ j=1bj xj=0. The line that
maximizes the minimum margin is better. Maximum margin separator is determined by a subset of
data
points. Data points in the subset are called Support Vectors. Support vectors are used to decide which side
of separator a test case is ON.
Consider a training set { ( 𝑿𝒊 , 𝒅𝒊 ,) } for i= 1 to n , where Xi is input pattern for ith example.
And di is the desired response (Target output). Let 𝒅𝒊 , = +𝟏 and 𝒅𝒊 , = −𝟏 Pattern classes for
positive and negative examples are linearly separable. Hyper Plane decision surface is given as below
equation:
𝑾𝑻 X + b = 0 , then di =0(when data point is on the line)
where W : adjustable weight factor and b is Bias .
Therefore, 𝑾𝑻 Xi + bi ≥ 𝟎 for 𝒅𝒊 , = +𝟏 and 𝑾𝑻 Xi + bi < 𝟎 for 𝒅𝒊 , = −𝟏 .
Closest data point is called Margin of Separation. Denoted by ρ. Objective of SVM is to
maximize ρ for Optimal Hyper plane.