Question: Implement a k-nearest neighbor classifier for k=1,3,5 on the Iris dataset available from UCI Machine Learning repository in the iris.data file at http://archive.ics.uci.edu/ml/machine-learning-databases/iris/ . This

Implement a k-nearest neighbor classifier for k=1,3,5 on the Iris dataset available from UCI Machine Learning repository in the iris.data file at http://archive.ics.uci.edu/ml/machine-learning-databases/iris/ . This dataset consists of 3 classes of 50 examples each (150 examples total) where each class is a type of an Iris plant (more information about the dataset can be found in the iris.names file). Divide the dataset into a training set and the testing set of 75 examples each such that the training and the testing set will have 25 examples of each class. Report the percent accuracy ((# correctly classified examples / total number of examples) * 100) on the testing set for each k=1,3,5. You can use the following programming languages: Java. Your program will accept arguments in the following order: the name of the file containing the training set, the name of the file containing the testing set, and a value of k (e.g. java NearestNeighbor train.data test.data 1).

IN JAVA

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!