- Reproduce the data from slide 18 twice, but now instead of \(\pm 1.5\) use an adjustment of \(\pm .5\) and \(\pm 2.5\), respectively
- Add a column to the data sets that indicates a
Train (25%) and a Test (75%) part.
- Fit the
K-NN model to both data sets. Use k = 3.
- What is the percentage of correct predictions for each model?
- Plot the false and correct predictions for both models.
- Write a function that determines the optimum
k with respect to classification error. Have the function return the following:
- The optimum
k (i.e.ย the lowest k with the most correct predictions)
- The proportion correctly predicted for optimum
k
- A data frame with the proportion correct for every
k
- Execute your function twice: once for the data set based on the
.5 adjustment and once for the data set based on the 2.5 adjustment. Does the previously used k=3 yield the optimal classification prediction?
End of Practical