Skip to content

Commit 8373e71

Browse files
Merge pull request #519 from joelostblom/knn-weights
Clarify what the weight function does
2 parents 1c791e0 + aaf1576 commit 8373e71

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

source/classification1.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,8 @@ cancer_train
719719

720720
Next, we create a *model specification* for \index{tidymodels!model specification} $K$-nearest neighbors classification
721721
by calling the `nearest_neighbor` function, specifying that we want to use $K = 5$ neighbors
722-
(we will discuss how to choose $K$ in the next chapter) and the straight-line
723-
distance (`weight_func = "rectangular"`). The `weight_func` argument controls
722+
(we will discuss how to choose $K$ in the next chapter) and that each neighboring point should have the same weight when voting
723+
(`weight_func = "rectangular"`). The `weight_func` argument controls
724724
how neighbors vote when classifying a new observation; by setting it to `"rectangular"`,
725725
each of the $K$ nearest neighbors gets exactly 1 vote as described above. Other choices,
726726
which weigh each neighbor's vote differently, can be found on

0 commit comments

Comments
 (0)