UNIHIVE

Study Hub UNIPORT CSC 494

CSC 494 · Introduction to Artificial Intelligence

Pattern recognition

Features, classification and clustering, nearest neighbour and simple classifiers, training and testing, and measuring accuracy.

Our notes

2 min read

What pattern recognition is

Assigning an input (an image, sound, signal, set of measurements) to a class (category), or finding groups in data. Examples: recognising handwritten digits, classifying cassava leaves as healthy or diseased, detecting fraud, recognising voices.

Stages of a pattern recognition system

  1. Sensing / data acquisition.
  2. Pre-processing: remove noise, normalise.
  3. Feature extraction: measurable properties (length, colour, texture, frequency content).
  4. Classification (or clustering).
  5. Post-processing / decision.

Supervised and unsupervised

  • Supervised (classification): learn from labelled examples, then classify new ones.
  • Unsupervised (clustering): find groups in unlabelled data (k-means).

k-nearest neighbour (k-NN)

Classify a new point by the majority class of its k closest training points (Euclidean distance).
Worked example: two features (leaf spot area, yellowing score). Training points: healthy (1, 1), (2, 1), (1, 2); diseased (5, 4), (6, 5), (5, 6). New leaf at (4, 4), k = 3.

  • Distances: to (5, 4) = 1.0; (6, 5) = 2.24; (5, 6) = 2.24; (2, 1) = 3.61; (1, 2) = 3.61; (1, 1) = 4.24.
  • The three nearest are all diseased: classify as diseased.

Other classifiers

  • Minimum-distance (nearest centroid): compare with each class's mean.
  • Bayes classifier: choose the class with the highest posterior probability.
  • Decision trees: a sequence of feature tests.
  • Perceptron / neural networks: weighted sums with a threshold (next topic area).
  • Support vector machines: the widest-margin boundary between classes.

Training, testing and evaluation

Split data into training and test sets (or use cross-validation). Measure on the test set:

Predicted positivePredicted negative
Actually positiveTPFN
Actually negativeFPTN
  • Accuracy = (TP + TN) / total.
  • Precision = TP / (TP + FP); Recall = TP / (TP + FN); F1 = 2PR / (P + R).

Worked example: TP = 40, FP = 10, FN = 20, TN = 130. Accuracy = 170/200 = 0.85; precision = 40/50 = 0.80; recall = 40/60 = 0.667; F1 = 0.727.

Overfitting

A classifier that memorises the training data (including noise) does badly on new data. Remedies: more data, simpler models, regularisation, validation sets.

Exams usually ask

  • Describe the stages of a pattern recognition system.
  • Classify a point by k-NN.
  • Calculate accuracy, precision and recall.

Common mistake

Judging a classifier on its training data. Always test on data it has not seen.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All CSC 494 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.