The k-nearest neighbors (KNN) algorithm is a simple, supervised machine learning algorithm that can be used to solve both classification and regression problems. kNN is most widely used as a first step in any machine learning setup. It is often used as a benchmark for more complex classifiers such as Artificial Neural Networks (ANN) and Support Vector Machines (SVM).
-
Write a python code to split the fruit dataset into 60:40 (train:test)
-
First 60% of the data is train and the bottom 40% is test
-
Write the code for the K-nearest neighbor algorithm using Euclidean distance as a measure of dissimilarity
-
Find the value of K which gives the best prediction accuracy (iterate K starting from 1 to 10)
-
Plot the graph for prediction accuracy vs the value of K