what is pattern_recognition (lecture 1 of 6)

43
ERI SUMMER TRAINING COMPUTERS & SYSTEMS DEPT. Dr. Randa Elanwar Lecture 1

Upload: randa-elanwar

Post on 16-Jul-2015

166 views

Category:

Science


1 download

TRANSCRIPT

Page 1: What is pattern_recognition (lecture 1 of 6)

ERI SUMMER TRAININGCOMPUTERS & SYSTEMS DEPT.

Dr. Randa ElanwarLecture 1

Page 2: What is pattern_recognition (lecture 1 of 6)

Content

� What is a "pattern"?

� What is Pattern Recognition?

� What is a "feature"?

� What is a "classification problem"?

2

ERI Summer training (C&S) Dr. Randa Elanwar

� What is a "classification problem"?

Page 3: What is pattern_recognition (lecture 1 of 6)

What is a Pattern?3

� A pattern is an entity, vaguely defined, that could be given a name, e.g. fingerprint image, handwritten word, human face, speech signal, DNA sequence.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 4: What is pattern_recognition (lecture 1 of 6)

What is meant by recognition?4

� Discover to which class of entities the "pattern" belongs and the name of the "pattern".

� This means when you have an image of an orange, if you can tell that this image belong to the "class" of you can tell that this image belong to the "class" of "fruits" then you "classified" the "pattern" which is the orange "image". If you can tell that it is an "orange" then you "recognized" the "pattern" because you did the following:1. You discovered its membership to some class

2. You labeled the pattern and gave it a name

ERI Summer training (C&S) Dr. Randa Elanwar

Page 5: What is pattern_recognition (lecture 1 of 6)

What is meant by recognition?5

� if you claimed that the pattern belongs to "vegetables", then you "misclassified" the pattern. If you couldn't tell its name, then the pattern is "unrecognized".

� When you have only one class of labeled patterns Fruits = {Banana, orange, apple, peach, etc.}, and you can tell that it is an "orange" then you "identified" the "pattern".

ERI Summer training (C&S) Dr. Randa Elanwar

Page 6: What is pattern_recognition (lecture 1 of 6)

What is meant by recognition?6

� Caution

� Sometimes, "identification" and "recognition" are used interchangeably but this is not always true.

� Other times, "classification" and "recognition" are used interchangeably but this is only true when the label of the pattern is the class name in the same time.

� Let's have more examples:

ERI Summer training (C&S) Dr. Randa Elanwar

Page 7: What is pattern_recognition (lecture 1 of 6)

Examples7

� 1. Face identification and Face recognition:

� If you have a security system on some door and only allowed employees can enter, you take a photo of the person trying to enter to match it with the data base of permitted employees.permitted employees.

� If your system searches the database of multiple photos for each employee and found one similar photo to his and gave permission "Oh yes, this photo has permission open the door" then he made "Face identification". or "verification"

ERI Summer training (C&S) Dr. Randa Elanwar

Page 8: What is pattern_recognition (lecture 1 of 6)

Examples8

� 1. Face identification and Face recognition:

� If your system searches the database of multiple photos for each employee and found one similar photo to his and gave permission "Oh yes, this is photo to his and gave permission "Oh yes, this is John Smith, he has permission, open the door" then he made "Face recognition".

� In both cases the pattern "Face" photo has been "classified" as "Permitted"

ERI Summer training (C&S) Dr. Randa Elanwar

Page 9: What is pattern_recognition (lecture 1 of 6)

Examples9

� 2. Signature Verification:

� Assume you have a bank account and you want to withdraw some money via an application or bank check. check.

� The employee will ask you to sign a paper. Then he scans your signature to check if it's really yours. The system should match if the signature you wrote is exactly similar to the one they have.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 10: What is pattern_recognition (lecture 1 of 6)

Examples10

� 2. Signature Verification:

� If the signature is a perfect match to the one they have, then it's ok to give you the money. They have "verified" that it's your signature. "verified" that it's your signature.

� This is not "recognition" they already know you but they are checking or making sure that the signature "pattern" is "significantly similar to" the samples they have "1 class".

ERI Summer training (C&S) Dr. Randa Elanwar

Page 11: What is pattern_recognition (lecture 1 of 6)

Examples11

� 3. Speech Recognition:

� Assume you want to call someone on phone while driving, you speak to your phone via the blue tooth you are wearing and say "Call Jane Arthur", and you are wearing and say "Call Jane Arthur", and what happens?. The phone actually calls Jane.

� Well, there is no magic.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 12: What is pattern_recognition (lecture 1 of 6)

Examples12

� 3. Speech Recognition:

� The blue tooth sent your speech signal to the application on your mobile, then the application began to segment this signal to sequential patterns (represent characters). characters).

� Each pattern is "classified" and "recognized" to be one of 26 classes A --> Z. Thus, now your speech signal has been recognized to be a sequence of characters. The application searches your contact list, finds the name and dials the corresponding number.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 13: What is pattern_recognition (lecture 1 of 6)

Examples13

� 4. Pdf to word converter

� Assume you have a document on paper or a book page that you want to edit, actually you don't have to re-write it on any word processing software like MS word for example. You can simply use a scanner supported with OCR facility like ABBYY or IRIS. with OCR facility like ABBYY or IRIS.

� You scan the paper and the scanner gives you a (.pdf) file. When you open this file on your computer and use the OCR program, you get another (.doc) file containing the same content where you can edit and save the new version. This is not magic either.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 14: What is pattern_recognition (lecture 1 of 6)

Examples14

� 4. Pdf to word converter

� The (.pdf) file is an image. The OCR software takes this image and segment it to sequential series of smaller images, each correspond to one word or even one character.

� Then each pattern (character image) is "classified" and "recognized" � Then each pattern (character image) is "classified" and "recognized" to be one of 26 classes A --> Z. Thus, now your page content has been recognized to a sequence of characters. The characters are grouped into words and their corresponding ASCII characters are re-written automatically in a (.doc) file it creates.

� From here comes the name OCR, or Optical Character Recognition. "Optical" because it is scanned and "Character Recognition" because it recognize the characters images to the real ASCII codes of characters.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 15: What is pattern_recognition (lecture 1 of 6)

Applications15

ERI Summer training (C&S) Dr. Randa Elanwar

Page 16: What is pattern_recognition (lecture 1 of 6)

Applications16

� Count millions of applications depending on recognizing patterns. Actually the scientific definition of pattern recognition: "The act of taking in raw data and making an action based on the “category” of the pattern.“

If the pattern was image or sound or video, your target � If the pattern was image or sound or video, your target can be categorization, verification, identification, recognition, clustering, etc.

� A person can be categorized as African or Japanese, verified for his/her eye color, identified to be Jim/Jane, recognized as being happy or sad, clustered to be tall/short – thin/fat

ERI Summer training (C&S) Dr. Randa Elanwar

Page 17: What is pattern_recognition (lecture 1 of 6)

What is a feature?17

� The questions here :� how exactly "recognition" happens?

� How patterns are matched to classes?

� How do we know the class?

� How do we know the name? � How do we know the name?

� How do we know if the pattern is misclassified or unrecognized?

� If we take the first example of the orange. How do you know it's an orange?. Simply because oranges are round and color is orange.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 18: What is pattern_recognition (lecture 1 of 6)

What is a feature?18

� How do you know your friend in a photo?

� Simply you know how his eyes looks, his hair, the color of his skin. You know he is tall. He is thin.

� How do you read a word "Cat"?

� You know that a "C" looks like a left curve, and "a" looks like a circle or a loop with a tail, and "t" is a stick with curved end and a horizontal dash near the top.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 19: What is pattern_recognition (lecture 1 of 6)

What is a feature?19

� Then what do you call these characteristics?

� They are called features.

� Feature is a mark or a symbol that says something about the entity it describes.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 20: What is pattern_recognition (lecture 1 of 6)

What is a feature?20

� Assume we have these samples

� If you want to discriminate Africans from Europeans, what Africans from Europeans, what feature should you take?

� skin color ..... that's right

ERI Summer training (C&S) Dr. Randa Elanwar

Page 21: What is pattern_recognition (lecture 1 of 6)

What is a feature?21

� If you want to discriminate men from women, what feature should you take?

� Long hair .. not accurate, some women has short hair and some men have long hair

ERI Summer training (C&S) Dr. Randa Elanwar

Page 22: What is pattern_recognition (lecture 1 of 6)

What is a feature?22

� Moustache or beard .. that's better , but still some men has no moustache or beard

� Baldness (No hair) for men .. still a problem some men has hair and some women wear a hat or hijab

ERI Summer training (C&S) Dr. Randa Elanwar

Page 23: What is pattern_recognition (lecture 1 of 6)

What is a feature?23

� Then how could we find a feature?� Well may be you need more than 1 feature and you

need more than 2 classes, you shall have:

1. Bald men, Men with moustache, Men with beard

2. Women with long hear, women with short hear, women 2. Women with long hear, women with short hear, women with hair covered

� Here you are using these features all together {hair presence, hair length, beard presence, moustache presence}

ERI Summer training (C&S) Dr. Randa Elanwar

Page 24: What is pattern_recognition (lecture 1 of 6)

What is a feature?24

� But what about this?

� This looks problematic. We need another way to know. We need more data or better features.

� Think of more complex problems

ERI Summer training (C&S) Dr. Randa Elanwar

Page 25: What is pattern_recognition (lecture 1 of 6)

What is a feature?25

� Recognize the same person after getting old (wrinkles everywhere)

� Recognize the same person in different moods (eyes, nose and mouth shapes vary)

� How could you understand face gestures?

ERI Summer training (C&S) Dr. Randa Elanwar

Page 26: What is pattern_recognition (lecture 1 of 6)

What is a feature?26

� Therefore, features can be representative such that each group of entities can have unique range of values and might be misleading if they cannot discriminate between distinct groups of entities

� We need something more powerful. We need some rules or numbers such that we can have an accurate decision whether or not a pattern belongs to certain class.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 27: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?27

� Let's do this on an example

� This is a very famous example you'll find in Richard Duda and Peter Hart book "Pattern Classification", John Wiley & Sons Inc.

� A fish packing plant wants to automate the process of sorting incoming Fish on a conveyor according to species using optical sensing.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 28: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?28

� We set up a camera and take some sample images to extract features that could help us to distinguish between the two species of fish. We can use these features:� Length� Length

� Lightness (brightness)

� Width

� Number and shape of fins

� Position of the mouth, etc…

ERI Summer training (C&S) Dr. Randa Elanwar

Page 29: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?29

� How can we classify fish?

� A sea bass is generally longer than a salmon: Sea bass has some typical length and this is greater than the salmon one. than the salmon one.

� If we select the length of the fish as a possible feature for discrimination, we can classify the fish seeing whether or not the length "l" of the fish exceeds some critical value "l*".

ERI Summer training (C&S) Dr. Randa Elanwar

Page 30: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?30

� Sea bass is longer than salmon, on average, but this simple criterion is quite poor. Some sea bass fish are small, thus short and some salmon fish are big, thus tall.

� When we graph the lengths versus the fish count (histogram), no matter how we choose l*, we cannot reliably separate sea bass from salmon by length only.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 31: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?31

� The same applies if we used lightness for example. we cannot find a single threshold or number above which we can decide the fish is sea bass and salmon otherwise.

To improve the recognition task, we can work with more � To improve the recognition task, we can work with more than one feature.1. Adopt the lightness and add the width of the fish.2. Sea bass is typically wider than salmon.

� Each fish will be represented by a feature vector of 2 elements

ERI Summer training (C&S) Dr. Randa Elanwar

Page 32: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?32

� Now if we tried to plot the fish samples according to both features it will look like this

� This is what we call "feature space". Each fish represent a "sample" or a "pattern" or a "feature vector XT" in the feature space.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 33: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?33

� Our problem is now to partition the feature space into two regions, where for all patterns in one region we will call the fish a sea bass, and all patterns in the other, salmon.

� The dark line might serve as a "decision boundary" of our "classifier". This means that if we have an equation for this straight dark line then we can substitute any pattern feature values in such equation, and find out the output. If it is positive (above the line for example) then the fish should be a sea bass, otherwise it would be a salmon.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 34: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?34

� We can assume if the value is zero (i.e. the sample lies on the line) to be any of the two classes.

� Don't bother about the few samples lying in the wrong partition now. We will talk about this later when we discuss features in more details.details.

� For now, Did you notice what have we done?1. We had a classification problem of images and we converted it to a

mathematical problem

2. We represented images by feature vectors and got a mathematical solution (straight line)

3. The solution is a mathematical model of the problem that we can use by substituting with the feature vector (image representation) of any new pattern/sample.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 35: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?35

� This means that, if you have any problem or application that can be interpreted as a classification problem, all what you need is to think of:

1. What classes do you have?

2. Are they distinct?

3. Are there specific features for each class?

4. let's find a decision boundary between the classes.

� Let's have some more questions:

ERI Summer training (C&S) Dr. Randa Elanwar

Page 36: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?36

� What if we need more than two features? Three for example?

� Then the feature space will be 3D and the classifier will then be a plane rather than a straight line.

� What if 4 or more features?

� Then the feature space will have dimensions equal to the number of features and the classifier will then be a hyper-plane.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 37: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?37

� Returning to the 2 features case, If we have some data to plot, this means we have known examples as training data set to our model (straight line).

� We can know the equation pretty simple. just assume any two points to be passing through the line and deduce the line coefficients (slope and constant).

ERI Summer training (C&S) Dr. Randa Elanwar

Page 38: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?38

� Let p1 = (1,0), p2 = (0,-1) . Constructing g(y) = 0

� This is a straight line equation: a1y1 + a2y2 + a3 = 0 .... right?!

� If you want to classify sample as Class 1 then whenever you add Y = (y1, y2) the result should be positive (>0) and if it belongs to Class 2 then whenever you add Y = (y1, y2) the result should be negative (<0).

ERI Summer training (C&S) Dr. Randa Elanwar

Page 39: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?39

� Then all what we need to know is the coefficient values a1, a2 and a3, and it will be great if we could compute them automatically without plotting.

� BUT!� BUT!

� What if we have more than 2 classes? (<0 and >0 are not sufficient)

ERI Summer training (C&S) Dr. Randa Elanwar

Page 40: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?40

� How can we do this for three or more dimensions (y3, y4, etc.)?

� In these cases data samples cannot be visualized. This is one of the main reasons we need "Machine learning". one of the main reasons we need "Machine learning".

� We need an intelligent model "classifier" which we can feed it with samples and tell it to which class it belongs and it learns automatically the equation of the decision boundary so that every time we have a new sample the model can correctly discover to which class it belongs.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 41: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?41

� Important notes

� This type of classification (straight line or plane decision boundary) is just one of many classification approaches but it is the simplest. The classifier that works using this approach is "Neural networks“works using this approach is "Neural networks“

� The other classification approaches are: (Template Matching, Statistical methods, Stochastic Processes (Marhov Chains), Structural/Graph Matching (Trees, Chains, etc.)., Rule-based methods). We can discuss them later. Our focus now is on Neural networks.

ERI Summer training (C&S) Dr. Randa Elanwar

Page 42: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?42

� Important notes

� The features are not always as simple as length, weight, age, etc., because simplicity means they might not be discriminative enough.

� Some problems cannot use such features, like face recognition for example how can you describe eyes or nose shape? � How can you describe a fingerprint?

� How could you describe a speech signal?

ERI Summer training (C&S) Dr. Randa Elanwar

Page 43: What is pattern_recognition (lecture 1 of 6)

What is a "classification problem"?43

� Therefore, in such cases the image is decomposed to number of lines that draw the image. Each line is represented by an equation or polynomial that describe the line shape.

� The coefficients of these polynomials are the features � The coefficients of these polynomials are the features you can use and make as a feature vector.

� Therefore we have different types of features:� Structural Decomposition like number of loops, curves, cross

points, area, length, width, angle, etc.

� Series Expansion (Transforms) like Moments, Fourier transform, Gabor transform, Hough transform, and wavelets.

ERI Summer training (C&S) Dr. Randa Elanwar