Lab3 KNN
Lab3 KNN
Lab3 KNN
2. Get “Wine” dataset from https://archive.ics.uci.edu/ml/datasets.php (this link will show you a
list of datasets, you need to search for wine dataset in this page) and save the content of the file
as a csv file. (data is in wine.data and info is in data.names). Add attribute names as the first row
in the csv file. (For every row, first value is the class, remaining values are various attributes)
3. Explore and learn about the relevance of various attributes of the dataset.
5. Check how various attributes are converted in Weka. Class is considered as numeric instead of
nominal. Apply filter NumericToNominal to convert class datatype to nominal. When you apply
filer, you need to specify the index of the attribute you need to apply the filter. Make sure that
you are converting only the attributes to be converted. If you didn’t specify attribute index, by
default, all numeric attributes will be converted.
Now, you should see like this:
6. Now, we need to perform classification using kNN method. For that, click on “Classify” tab.
For that, choose IBk which is Instance Based k Nearest Neighbors from Lazy in the tree view.
7. As mentioned earlier, our first attribute is the class label. We need to set that now in the classify
panel. (Marked in red below)
8. There should be a lot of text in the right-hand side of the window with the results of the
algorithm. Find the line that says “Correctly classified instances”.
11. Repeat step 9 with “Percentage Split” of 70. Fill in the table in the answer document.
12. Take one instance as a test instance and show the calculations in Excel to find the class
of that instance by applying 5NN. You need to explain the process AND include the
screenshot of the excel file (of the final stage where you make the prediction of the class
of the test instance) in the Answer document.
This lab has 5 marks so ensure that you have all your answers filled in.
Both submission in Brightspace and demo during lab hours are required to get credits for the lab.