Curvingo · Made in India

Glossary

Select one of the keywords on the left…

Underfitting and OverfittingCode with Python

Reading time: ~5 min

scikit-learn's KNeighborsClassifier is KNN. n_neighbors is the k, and model.score returns the accuracy — the fraction of bushes predicted right. The loop tries four values of k and scores each on the known bushes and on the 12 new ones. Run the program.

KNN by Hand

KNN needs no training at all: to judge a new bush, measure its distance to every known bush, sort, and count the votes of the nearest k. math.dist gives the straight-line distance between two points. Run it, then change k.

To reveal more content, you have to complete all the activities and exercises above. 
Are you stuck? or reveal all steps

Next up:
Summary
Sina