Professional Documents
Culture Documents
KSV
Kashif Javed
Vaseem Ahmed
Shrey Gupta
CS Department
McGill University
kashif.javed@mail.mcgill.ca
ECE Department
McGill University
vaseem.ahmed@mail.mcgill.ca
AbstractThe problem of digit classification in machine learning is well studied over the years, and significant amount of work
has been done on numerous datasets. In this paper, we attempt to
classify images of hand-written digits (0-9) represented in cropped
images, obtained from transformed version of MNIST dataset.We
have discussed various data pre-processing and feature extraction
techniques.Furthermore, we discuss the performance of Naive
Bayes(NB), K-Nearest Neighbor (KNN), Support Vector Machine
(SVM), Neural Network algorithm (NN), and Convoluted Neural
Network(CNN). Results show that the best classifier was CNN
with an accuracy of 0.848 for the given dataset.
I.
I NTRODUCTION
A. Averaging Filters
Adding of texture to the data made the original image of the
digits very noisy. Averaging filters are useful in noise removal
as each pixel of the image gets the value equal to the average
of its neighboring pixels.
Median filter: Each output pixel in the image is replaced
by the median of its 3x3 neighborhood pixels. A median filter
was used since median filters are effecting in removing noise
while preserving edges at the same time [7]. Thus we expected
median filter to help in detecting strokes of the digits.
Gaussian filter: Each output pixel in the image is replaced
by a weighted average of its 3x3 neighborhood pixels. Gaussian filter are particularly smoothing filters. They are better
than mean noise removing filters in the sense that they provide
gentler smoothing and preserve edges better than a similar
sized median filter [8]. The value of sigma used was 0.5.
B. FFT and IFFT
Fast Fourier Transform converts the image signal from
spatial domain to frequency domain. High frequency noise can
then be filtered in the frequency domain. The image is then
converted back to spatial domain using an Inverse Fast Fourier
Transform. This helps in removing background texture, and
noise as shown in the Fig.1.
III.
F EATURE E XTRACTION
II.
DATA P RE - PROCESSING
Fig. 1: Images on the left show the original image data and
on the right data after being transformed through a FFT and
IFFT transform.
A LGORITHMS
A. Naive Bayes
Naive Bayes algorithm classifies the data on the basis of
P(class|features) which is equivalent to the product of prior
probability, and likelihood. In addition to that, there is a
general probability term in the denominator but it is same for
all the classed therefore can be ignored. The formula for Naive
Bayes:
P (class)P (f eatures|class)
P (f eatures)
(1)
D. Neural Network
Results have shown that carefully designed Neural Networks can very efficiently classify hand written digits. Human
brain which is exceptionally good at classifying objects inspired the idea of Neural Networks. Just like human brain
Neural Network contains many neurons placed in various
layers. First layer is the input layer and in case of our problem
pixel values of the images were used as the input values
for that layer. Intermediate layers are called hidden layers
which can contain arbitrary number of neurons depending
on the architecture of the Neural Network. A neuron has
various inputs and has different weights assigned to these input
links. The output of a particular neuron is a sigmoid function
applied to the linear combination of its input and weights
(2 x2 + 1 x1 + b), where sigmoid function is defined by:
a = (z) =
1
1 + exp z
(3)
= l+1 ((a)l )T +
(l)
and achieved an accuracy of .35 on raw features. The confusion
matrix for the NB is shown in Fig.4.
B. K-nearest Neighbor
We also tested K-nearest neighbor (KNN) algorithm for
this project. We used Euclidean distance as a measure to
calculate the closest training set instances to a test point. The
test point is then assigned the class that is in majority among
these k neighbors. The Euclidean distance is calculated using
the formula:
v
u k
uX
D(x, y) = t (xi yi )2
(2)
i=1
(4)
(5)
R ESULTS
D ISCUSSION
C ONCLUSION
The important aspect of digit classification is feature selection. Pre-processing of images using different filters was
unable to identify the correct feature set necessary to classify
the images properly. Thus more sophisticated algorithms such
as Convoluted Neural Network which acts as localized feature
selector and classifier reached an overall accuracy of .848. For
future work, we would like to compare the performance of
CNN to more advanced classifiers e.g. deep learning.
VIII.
A PPENDIX
[3]
[4]
[5]
[6]
[7]
[8]