Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

python - Why testing error rate increases at high values of K in KNN algorithm?

I am getting the error rates like this up to 20 values what might be the reason for this ? k_values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] Error [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0020000000000000018, 0.0020000000000000018, 0.0020000000000000018, 0.0020000000000000018,0.0020000000000000018, 0.0020000000000000018, 0.006000000000000005, 0.0040000000000000036, 0.008000000000000007,0.006000000000000005, 0.010000000000000009, 0.008000000000000007, 0.014000000000000012, 0.01200000000000001] these are my testing error rates

I want to know the reason why the error rate increases with increase in k values?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The parameter K in KNN controls the complexity of the model. You don't give details of your specific problem, but what you likely seeing is the the bias/variance trade-off. This post is a good read about it.

Usually you try different values of the hyper parameters from the model (the value of K in the KNN) in a validation set and keep the best one. Notice that this validation set is not the same as the test set.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...