You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/classification1.Rmd
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -460,6 +460,14 @@ the $K=5$ neighbors that are nearest to our new point.
460
460
You will see in the `mutate` \index{mutate} step below, we compute the straight-line
461
461
distance using the formula above: we square the differences between the two observations' perimeter
462
462
and concavity coordinates, add the squared differences, and then take the square root.
463
+
In order to find the $K=5$ nearest neighbors, we will use the `slice_min` function.
464
+
465
+
> **Note:** Recall that in Chapter \@ref(intro), we used `arrange` followed by `slice` to
466
+
> obtain the ten rows with the *largest* values of a variable. We could have instead used
467
+
> the `slice_max` function for this purpose. The `slice_min` and `slice_max` functions
468
+
> achieve the same goal as `arrange` followed by `slice`, but are slightly more efficient
469
+
> because they are specialized for this purpose. In general, it is good to use more specialized
470
+
> functions when they are available!
463
471
464
472
```{r 05-multiknn-1, echo = FALSE, fig.height = 3.5, fig.width = 4.5, fig.pos = "H", out.extra="", fig.cap="Scatter plot of concavity versus perimeter with new observation represented as a red diamond."}
0 commit comments