ALY 6020 Week 1 Midweek Assignment
ALY 6020 Week 1 Midweek Assignment
Liankai Ren
Then split the data to train set and test set with the ratio 80%. Also, set the target
scale that include all 4 attribute for iris.
After all preparation, we can build the k-NN model and set the k=1. The confusion
matrix shows the result of our k-NN model and answer the question that the accuracy of
the model is 0.967. The accuracy of the setosa is 100%, accuracy of the versicolor is
100% and accuracy of the virginica is 90%.
For further analyzing, the value of k can be varied to check the accuracy. From
the output, it shows when k=2, 3, 5, 10, the accuracy is 90%. Based on the results, all
accuracies if the k-NN model with different k is above 90%. Therefore, we can conclude
that the k-NN model is a good classification model for prediction the type of iris.
Reference
“K-NN Classifier in R Programming - GeeksforGeeks.” GeeksforGeeks, 18
June 2020, https://www.geeksforgeeks.org/k-nn-classifier-in-r-programming/.
skalskip. “Iris Data Visualization and KNN Classification | Kaggle.” Kaggle:
Your Machine Learning and Data Science Community, Kaggle, 27 Sept. 2017,
https://www.kaggle.com/code/skalskip/iris-data-visualization-and-knn-
classification.