Python Scikit-learn: K Nearest Neighbors - Create a plot of k values vs accuracy
Python Machine learning K Nearest Neighbors: Exercise-8 with Solution
Write a Python program using Scikit-learn to split the iris dataset into 80% train data and 20% test data. Out of total 150 records, the training set will contain 120 records and the test set contains 30 of those records. Train or fit the data into the model and using the K Nearest Neighbor Algorithm and create a plot of k values vs accuracy.
Sample Solution:
Python Code:
Sample Output:
Preliminary model score: 0.9666666666666667![]()
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?