@@ -1273,7 +1273,7 @@ The overall workflow for performing K-nearest neighbors classification using `ti
1273
1273
In these last two chapters, we focused on the K-nearest neighbors algorithm,
1274
1274
but there are many other methods we could have used to predict a categorical label.
1275
1275
All algorithms have their strengths and weaknesses, and we summarize these for
1276
- the $K$ -NN here.
1276
+ the K -NN here.
1277
1277
1278
1278
** Strengths:** K-nearest neighbors classification
1279
1279
@@ -1329,7 +1329,7 @@ cancer_irrelevant |>
1329
1329
select(Class, Smoothness, Concavity, Perimeter, Irrelevant1, Irrelevant2)
1330
1330
```
1331
1331
1332
- Next, we build a sequence of $K$ -NN classifiers that include ` Smoothness ` ,
1332
+ Next, we build a sequence of K -NN classifiers that include ` Smoothness ` ,
1333
1333
` Concavity ` , and ` Perimeter ` as predictor variables, but also increasingly many irrelevant
1334
1334
variables. In particular, we create 6 data sets with 0, 5, 10, 15, 20, and 40 irrelevant predictors.
1335
1335
Then we build a model, tuned via 5-fold cross-validation, for each data set.
@@ -1485,7 +1485,7 @@ In particular, you
1485
1485
2 . tune each one using cross-validation, and
1486
1486
3 . pick the subset of predictors that gives you the highest cross-validation accuracy.
1487
1487
1488
- Best subset selection is applicable to any classification method ($K$ -NN or otherwise).
1488
+ Best subset selection is applicable to any classification method (K -NN or otherwise).
1489
1489
However, it becomes very slow when you have even a moderate
1490
1490
number of predictors to choose from (say, around 10). This is because the number of possible predictor subsets
1491
1491
grows very quickly with the number of predictors, and you have to train the model (itself
@@ -1584,7 +1584,7 @@ one over increasing predictor set sizes
1584
1584
and another to check which predictor to add in each round (where you see ` for (j in 1:length(names)) ` below).
1585
1585
For each set of predictors to try, we construct a model formula,
1586
1586
pass it into a ` recipe ` , build a ` workflow ` that tunes
1587
- a $K$ -NN classifier using 5-fold cross-validation,
1587
+ a K -NN classifier using 5-fold cross-validation,
1588
1588
and finally records the estimated accuracy.
1589
1589
1590
1590
``` {r 06-fwdsel-2-seed, warning = FALSE, echo = FALSE, message = FALSE}
0 commit comments