Question

Task 2: Use the dataset created for Task 1. Then use the KNN algorithm and show that

there are at least three types of crystals in the dataset, and you can classify them using

this (supervised) algorithm.

Working principles: Write briefly about the KNN algorithm based on the mathematics

involved based on your understanding (e.g., you can mention whether it is a

supervised/unsupervised learning).

Then use the dataset that you created for Task 1 and split the data set into two sets: 50%

of the data for training and 50% of the data for testing. Check whether the KNN algorithm

can accurately classify the type of crystals in the training and testing data set. For

consistency, fix the number of nearest neighbours' to 5 (if required, you can change this

value, but note that this number but make sure it is an integer). Generate the confusion

matrix. Based on the confusion matrix, explain how successful the KNN algorithm is

(check and explain whether the algorithm managed to classify the crystals in both

training and testing dataset?). Include the plots that you generated and add suitable

explanation based on what you observe from the chart (e.g., about the accuracy of the

algorithm based on the confusion chart).

Question image 1