SVM, KNN, and Neural Networks Investigated For Machine Learning in Written Word Decoding
SVM, KNN, and Neural Networks Investigated For Machine Learning in Written Word Decoding
Dr. M. D Gouse5
(Professor)
Department of CSE,
Koneru Lakshmaiah Education Foundation,
Vaddeswaram, AP, India
In order to compute HOG functions, we first set the size nine. This suggests that the HOG function vector may have a
of cells to be 14 × 14. Since the MNIST dataset is 28 by 28 dimension of 4 x 9 = 36. The classifier can then be kept in a
pixels in size, we can have four (4) blocks or cells that are report, as seen in parent four below, once we have created a
each 14 by 14. The vector of orientation is approximately Linear SVM object and completed the dataset's education.
B. K-Nearest_Neighbor (KNN)
The K-nearest_neighbours classifier is a popular
technique in the realm of image classification due to its
simplicity and effectiveness. Unlike more complex
algorithms that require extensive training processes, KNN
operates on a different principle. It doesn't undergo
traditional learning iterations with labeled data. Instead, KNN
relies on the inherent structure of the data itself.
We import the MNIST dataset and divide it into two parts: 25% for testing and 75% for training. Ten percent of the training
data were reserved for validation.
The classifier is then trained, and the optimal value for k—a parameter used in the K-nearest_neighbours (KNN)
algorithm—is ascertained. Furthermore, we compute the classifier's accuracy. We cycle over a range of k numbers, from 1 to 15,
in this process. The classifier's performance is next evaluated in order to confirm its efficiency, as shown in Figure seven below.
Afterward, we apply the trained classifier to the testing dataset, utilizing a k value set to 1. Following this, we conduct the final
evaluation of the classifier's performance, as illustrated in Figure seven.
Next, we will choose five (5) photos at random from the testing dataset in order to investigate each unique prediction. We'll
analyze the classifier's output for each of these images.
C. Multi-Layer Perceptron (MLP) Two files will be used to perform the classification
The Multi-layer Perceptron (MLP) is a supervised process: perform_Recognition.py for classification evaluation
learning algorithm that aims to learn a function: f(·) : Rm → and generate_Classifier-nn.py for handling the actual
Ro classification.
The number of input dimensions, denoted by m, and the Within generate_Classifier-nn.py, We'll take three crucial
number of output dimensions, denoted by o, are used to train steps:
the function on a dataset. For either regression or
classification problems, the MLP may learn a non-linear Calculating HOG Features: For every sample in the
function approximator given a target y and a set of features X database, this entails calculating the Histogram of
= x1, x2,... xm. By adding one or more non-linear layers— Oriented Gradients (HOG) features.
also referred to as hidden layers—between the input and Training a Multi-class MLP Neural Network: Utilising
output layers, it differs from logistic regression. Neural the HOG features of every sample together with their
network topologies called Multi-layer Perceptrons (MLPs) respective labels, we will train a Multi-Layer
may identify complex patterns in data. Multiple hidden layers Perceptron neural network which is multi-class.
with non-linear activation functions are a feature of MLPs, in Saving the classifier: Once the classifier is trained, we'll
contrast to more straightforward models like logistic save it into a file for later use.
regression. Consequently, they perform remarkably well in
fields such as natural language processing, picture
identification, and financial forecasting. Throughout training,
MLPs iteratively modify weights and biases to improve their
representations, enabling them to generalise and produce Fig 11 Download MNIST Dataset
precise predictions on fresh data. Because of their versatility,
MLPs are often used for a wide range of supervised learning Initially, we will download the MNIST dataset, which is
tasks involving intricate, non-linear interactions. made up of handwritten numbers. Next, we'll use a method
known as HOG (Histogram of Oriented Gradients) to take
these digit snapshots and extract features. The digit images
and the labels that go with them will be arranged into numpy
arrays. Next, for every image, we will compute the HOG
features and store them in a different numpy array. This
procedure's detailed coding instructions can be found in the
figure 12 beneath.
In order to calculate the HOG features, we will use a 14 Following that, we'll instantiate a MLP (Multi-Layer
× 14 cell size. Since the MNIST dataset images are 28 x 28 Perceptron) Neural Network object & train it using the
pixels, we'll divide them into four blocks or cells, each with a dataset. As seen in Figure 13, after training, we'll save the
size of 14X14 pixels. We'll define the orientation vector to 9, classification model into a file.
resulting in a feature vector of HOG size of 4 x 9 = 36.
IV. RESULT
V. CONCLUSION
Fig 19 Assessment of the test data
The outcomes show that the dataset is accurately
classified by both KNN (K-Nearest_Neighbours) and SVM
(Support Vector Machine) classifiers. But there are certain
inaccuracies with the MLP (Multi-Layer Perceptron) Neural
Network, especially when it comes to forecasting the number
nine (9). This disparity results from the fact that MLP uses a
non-linear function, whereas KNN and SVM predict based
only on the features that have been retrieved. Multiple local
minima result from the non-convex loss functions of MLPs,
particularly those with hidden layers. As a result, different
random weight initializations may produce varied validation
accuracy. This issue can be mitigated by employing
Convolutional Neural Networks (CNNs) with frameworks
like Keras, which are better suited for capturing complex,
non-linear relationships in data.
REFERENCES