0% found this document useful (0 votes)
11 views

AI Assignment

The document describes experiments conducted to develop a machine learning solution for facial recognition. The experiments varied parameters like the number of hidden neurons and principal components in an artificial neural network model to achieve the highest accuracy. Accuracy levels between 92-99% were achieved across different experiments.

Uploaded by

mimonakarki7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

AI Assignment

The document describes experiments conducted to develop a machine learning solution for facial recognition. The experiments varied parameters like the number of hidden neurons and principal components in an artificial neural network model to achieve the highest accuracy. Accuracy levels between 92-99% were achieved across different experiments.

Uploaded by

mimonakarki7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

University of Bedfordshire

Concepts and Technologies of Artificial Intelligence


Assignment 1(Individual Report)

Submitted by:
Gaurav Deol

1916977
Unit code: CIS006-2
Assignment 1: Design of machine learning solution for biometric
recognition task.
Unit coordinator: Dr. Vitaly Schetinin

Student Name: Gaurav Deol

ID: 1916977

E-mail: [email protected]
Table of contents:
1.0 Introduction ………………………………………………………………………. 4

2.0 Designing a solution ……………………………………….…………………….. 5

3.0 Experiments ……………………………………………………………………… 8

4.0 Conclusion ………………………………………………………………………………… 22

5.0 References …………………………………………………………………………………. 23

6.0 Appendix …………………………………………………………………………………… 24


Individual Report

1.0 Introduction
The word AI may also refer to any computer that exhibits human-like characteristics like
learning and problem-solving (Frankenfield, 2021). It's becoming bigger and attracting almost
everyone.
Biometric recognition (also known as biometrics) is the process of automatically recognizing
people based on their biological and behavioral characteristics. Fingerprint, profile, iris, palm
print, retina, hand geometry, expression, signature, and gait are examples of biometric traits
(Jain, 2008). Biometric recognition system provides two functionalities:
1. Verification ("Is this the person who he/she claims to be?")
2. Identification ("Is this person in the database?")
Among all the fields, face recognition system also plays a significant role in today's world. Face
detection is a computer technology being used in a variety of applications that identifies human
faces in digital images. Face detection also refers to the psychological process by which humans
locate and attend to faces in a visual scene (Wikipidea, 2020). It's typically purposed to
authenticate users for verifications. It works by pinpointing and measuring facial features of
person.
There's no need of remembering the password or carry any ID. Face detection and recognition
are two different things and people often get confused in these two. Face recognition is a
broader form of face detection. Face detection only detects human face but face recognition
confirms identity as well.
Fig.1 Facial Recognition
https://percentotech.com/how-your-business-can-benefit-from-facial-recognition-technology/

It's used in various sectors like access control, security, image database investigation, general
identity verification and surveillance.

Assignment task and goal:


Our main aim is to develop a machine learning solution for a biometric recognition task that is
as accurate as possible. Since the facial images are taken from actual people in a number of
circumstances, they can be misclassified, making 100 percent accuracy almost impossible. Our
main target is to have as few recognition errors as possible.

2.0 Designing a solution


In order to design, I used the ML technologies like: Artificial Neural Networks (ANNs) that can
be taken into function by using a robust platform called Google Co-lab. It supports languages
that are connected with ML. This totally helped me to achieve minimum error. Co-lab permits
us to type and execute python code in the browser and it's very friendly for machine learning. It
has helped me to achieve my assignment goals i.e. having best accuracy.
Scripts were provided to us by the university. I ran those scripts and performed the
experiments. This project included facial images of 30 persons in total where each individual is
depicted by 50 images taken in various settings. So total images were 1500. There were 77*68
pixels and number of images were 5236.
We were provided with classify_yale and process_yale. At first, we read the images in grey scale
and after that we reset it and saved that in data file in vector form and then we performed
classify_yale. Applying the PCA and then training the neural network are explained below:
2.1 Applying PCA
We used PCA (Principal Component Analysis) to train and test images for dimensionality
reduction that that uses simple matrix operations from linear algebra and statistics. Basically, it
simplifies dataset. The original features will turn into principal components. If we don’t select
the number of principal components with care, then we may miss some information.
2.2 Training a neural network
For the training purpose, I used the hidden neurons. Our main goal is to get the best accuracy
so training is important. It uses an algorithm called optimization in order to get weights to best
map inputs to outputs (Brownlee, 2019).
Hidden

Input Output

Fig 2: Artificial Neural Network with one hidden layer

In the script of classify_yale, sklearn and Multi-Layer Perceptron Classifier are used. Various
parameters are present in sklearn MLPClassifier, that are explained below and I have also
mentioned the parameters that I used:
1. activation function: {'identity','logistic','tanh','relu'}

It's an equation to depict the output of a neural network. It's attached to each neuron and says
whether the neuron should be activated or not, on the basis of neuron's input for model's
prediction (missing link, 2021). I used tanh, the hyperbolic tan function.

2. solver: {'sgd', 'adam','lbfgs'}

Basically, the solver is for the weight optimizing process. I used 'sgd' as a solver. It's also called
Stochastic Gradient Descent. It's a simple but an efficient way to fit linear classifiers.

3. batch_size: int, default='auto'

We need more memory space if the batch size is high.

4. early_stopping:bool, default=False

When the validation score does not improve, early stopping is used to end the training. It's
effective if solver 'sgd' is used.

5. fit(X_train_pca,y)

Fit is a feature that changes the weight based on the input data values. It sets the weight for a
higher level of accuracy.

In summary, I extracted the zipped file and uploaded in Google drive. At first, I mounted images
in drive and converted it into vector form and then I split into testing and training sets by
applying PCA, activation function and other elements. I then imported sklearn model to
upgrade our design and gain more accuracy. Finally, I changed the number of hidden neurons
and principal components to achieve our goal of highest accuracy.

Artificial Neural Networks:


McCulloch and Pitts proposed the first model of ANN. It's a computer machine that mimics how
the human brain processes information. Artificial Intelligence is built on this basis. It's simply
referred to as neural networks, and it's based on biological neural networks. It is used to model
non-linear problems and is based on a set of connected units or nodes. It's highly used in the
image recognition and pattern analysis.

3.0 Experiments
I basically trained the machine by altering the parameters like number of hidden neurons
(noofhn) and number of principal components (noofpc) wherever required in order to achieve
our goal of maximum accuracy and minimum loss rate. I trained the machine for five times
varying the variables taken about five times. Below are the experiments in detail.

3.1 Experiment 1

At first, I put the value of hidden neurons as 200 and number of principal components as 200
and left the test size as 0.2. All these values were default values given by university already. The
screenshot and result is shown below:
Fig No. 3 Experiment 1
Table 1:

S. No. noofhn noofpc test_size Accuracy


1. 200 200 0.2 0.92
2. 200 200 0.2 0.98
3. 200 200 0.2 0.97
4. 200 200 0.2 0.96
5. 200 200 0.2 0.92

In the very first experiment, I got 0.98 i.e. 98% as highest accuracy and 0.92 i.e. 92% as lowest
accuracy. The average accuracy was 95%. The number of iterations is higher than 100.

3.2 Experiment 2

In second experiment I put number of hidden neurons and principal components both as 300. I
didn't change the test size. The screenshot and table is shown below:
Fig. 4 Experiment 2
Table 2:

S. No. noofhn noofpc test_size Accuracy


1. 300 300 0.2 0.94
2. 300 300 0.2 0.97
3. 300 300 0.2 0.99
4. 300 300 0.2 0.95
5. 300 300 0.2 0.95

In the second experiment, I got 0.99 i.e. 99% as highest accuracy and 0.94 i.e. 94% as lowest
accuracy. The average accuracy was 96%.

3.3 Experiment 3

In third experiment I put number of hidden neurons and principal components both as 400. I
didn't change the test size. The screenshot and table is shown below:
Fig. 5 Experiment 3
Table 3:

S. No. noofhn noofpc test_size Accuracy


1. 400 400 0.2 0.96
2. 400 400 0.2 0.97
3. 400 400 0.2 0.99
4. 400 400 0.2 0.95
5. 400 400 0.2 0.95

In the third experiment, I got 0.99 i.e. 99% as highest accuracy and 0.95 i.e. 95% as lowest
accuracy. The average accuracy was 96.4%.

3.4 Experiment 4

In the fourth experiment I put number of hidden neurons and principal components both as 350. I
didn't change the test size. The screenshot and table is shown below:
Fig. 6 Experiment 4
Table 4:

S. No. noofhn noofpc test_size Accuracy


1. 350 350 0.2 0.96
2. 350 350 0.2 0.97
3. 350 350 0.2 0.99
4. 350 350 0.2 0.97
5. 350 350 0.2 0.97
In the fourth experiment, I got 0.99 i.e. 99% as highest accuracy and 0.96 i.e. 96% as lowest
accuracy. The average accuracy was 97.2%.

3.5 Experiment 5

In the last experiment I put number of hidden neurons and principal components both as 250. I
didn't change the test size. The screenshot and table is shown below:
Fig. 7 Experiment 5
Table 5:

S. No. noofhn noofpc test_size Accuracy


1. 250 250 0.2 0.99
2. 250 250 0.2 0.94
3. 250 250 0.2 0.98
4. 250 250 0.2 0.99
5. 250 250 0.2 0.97

In the last experiment, I got 0.99 i.e. 99% as highest accuracy and 0.94 i.e. 94% as lowest
accuracy. The average accuracy was 97.4%.

We didn’t take random state so, we got different accuracies though we took same noofhn and
noofc.

K-Fold Cross Validation:

Basically, it's a resampling process to evaluate machine learning on a fixed data. Whenever we
take value for k, like we took k=10, then we say it as 10-fold cross validation.

It's popular and simple to understand and it gives less biased outcome.
The general process is as following:

1. Shuffling the dataset randomly

2. Splitting dataset into k groups

3. Take the group as test data and take remaining as train set

4. Fit model on training set and evaluate it on test set

5. Retain the evaluation score and discard model

6. Summarize the skill of model using sample of evaluation scores

Importantly, each finding in the data sample is assigned to a distinct category and remains
there throughout the process. This implies that each sample has the chance to be used in the
hold out set once and to train the model k times (Brownlee, 2018).

Basically, in my view, k fold is an effective tool to prevent over-fitting. Over- fitting is a case
where many features are given to machine and the machine gets confused so, k fold helps the
machine to get more accuracy.

3.6 Experiment 7(With K-Fold)

n_splits=5

Fold Validation score Corresponding loss


1 0.050000 3.30030361
2 0.070000 3.24720272
3 0.270000 2.52769367
4 0.310000 2.17029370
5 0.800000 0.52417741
Fig 8: Experiment 7

Fig. 9: Accuracy
4.0 Conclusion
I learnt a great platform, Google co-lab. I took random parameter, I found that when the
accuracy value is increased, the loss rate is decreased. I took hidden neurons and principal
components both as equal in each experiment and didn't vary them and found that it's effective
in getting best accuracy which is our ultimate goal. If we take different values, then we might
have to introduce K-Fold cross validation. My highest accuracy was 0.99 which I got about 5
times. I didn't change the test size since I didn't need it because the precision was already as
expected. I got many errors but my friends and tutors highly encouraged me and helped me.
This assignment totally helped me and boosted me up with huge interest in AI and face
detection, especially. I assure that I will make a real-time face detection system through various
tutorials and with the help of my tutor. I'm totally pushed ahead by this assignment.

5.0 References

Brownlee, J., 2018. machine learning mastery. [Online]


Available at: https://machinelearningmastery.com/k-fold-cross-validation/
[Accessed 14 March 2021].

Brownlee, J., 2019. machinelearningmastery.com. [Online]


Available at: https://machinelearningmastery.com/why-training-a-neural-network-is-
hard/#:~:text=Training%20a%20neural%20network%20involves,spots%2C%20and%20is%20highly%20m
ultidimensional.
[Accessed 13 3 2021].

Frankenfield, J., 2021. Investopedia. [Online]


Available at: https://www.investopedia.com/terms/a/artificial-intelligence-
ai.asp#:~:text=Artificial%20intelligence%20(AI)%20refers%20to,as%20learning%20and%20problem%2Ds
olving.
[Accessed 14 March 2021].

Jain, D. A. K., 2008. scholarpedia. [Online]


Available at:
http://www.scholarpedia.org/article/Biometric_authentication#:~:text=Biometric%20recognition%20(al
so%20known%20as,%2C%20voice%2C%20signature%20and%20gait.
[Accessed 14 March 2021].

missing link, 2021. missinglink.ai. [Online]


Available at: https://missinglink.ai/guides/neural-network-concepts/7-types-neural-network-activation-
functions-right/
[Accessed 13 March 2021].

Wikipidea, 2020. Wikipidea. [Online]


Available at: https://en.wikipedia.org/wiki/Face_detection
[Accessed 14 March 2021].

6.0 Appendix

You might also like