Catalog what is the three basic elements of the K-nearest neighbor algorithm model to construct KD tree search kd Tree python code (Sklearn Library)
what K-nearest neighbor algorithm (k-nearest neighbor,knn) |
Cited examples
Assuming there is a dataset, where the first 6 are training sets (with attribute values and tags), we train a KNN model based on the training set to predict the movie type of the last movie.
First, all the samples in the training set are drawn into the coordinate system, and the sample to be tested is drawn
Then calculate the Euclidean distance between the movie to be tested and all the movies that are known to be classified
Then, sort these movies in ascending order of distance, take the first k movies, assuming k=3, then we get the movie in turn "He's not really into Dudes", "Beautiful Woman" and "California Man". And these three movies are all love films, so we decided that the unknown movie is a love film.
"The dawn passes the number ==> machine learns the quick treasure" the model article 04--k nearest neighbor Method "KNN" (with Python code)