Skip to content

Commit 9daab50

Browse files
KNN to K-NN
1 parent 7c53143 commit 9daab50

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

source/classification2.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,10 +1524,10 @@ set the number of neighbors $K$ to 1, 7, 20, and 300.
15241524

15251525
### Evaluating on the test set
15261526

1527-
Now that we have tuned the KNN classifier and set $K =$ {glue:text}`best_k_unique`,
1527+
Now that we have tuned the K-NN classifier and set $K =$ {glue:text}`best_k_unique`,
15281528
we are done building the model and it is time to evaluate the quality of its predictions on the held out
15291529
test data, as we did earlier in {numref}`eval-performance-clasfcn2`.
1530-
We first need to retrain the KNN classifier
1530+
We first need to retrain the K-NN classifier
15311531
on the entire training data set using the selected number of neighbors.
15321532
Fortunately we do not have to do this ourselves manually; `scikit-learn` does it for
15331533
us automatically. To make predictions and assess the estimated accuracy of the best model on the test data, we can use the
@@ -1654,7 +1654,7 @@ The overall workflow for performing K-nearest neighbors classification using `sc
16541654
In these last two chapters, we focused on the K-nearest neighbors algorithm,
16551655
but there are many other methods we could have used to predict a categorical label.
16561656
All algorithms have their strengths and weaknesses, and we summarize these for
1657-
the $K$-NN here.
1657+
the K-NN here.
16581658

16591659
**Strengths:** K-nearest neighbors classification
16601660

@@ -1927,7 +1927,7 @@ In particular, you
19271927
2. tune each one using cross-validation, and
19281928
3. pick the subset of predictors that gives you the highest cross-validation accuracy.
19291929

1930-
Best subset selection is applicable to any classification method ($K$-NN or otherwise).
1930+
Best subset selection is applicable to any classification method (K-NN or otherwise).
19311931
However, it becomes very slow when you have even a moderate
19321932
number of predictors to choose from (say, around 10). This is because the number of possible predictor subsets
19331933
grows very quickly with the number of predictors, and you have to train the model (itself

source/regression1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ to be too small or too large, we cause the RMSPE to increase, as shown in
706706

707707
{numref}`fig:07-howK` visualizes the effect of different settings of $K$ on the
708708
regression model. Each plot shows the predicted values for house sale price from
709-
our KNN regression model for 6 different values for $K$: 1, 3, 25, {glue:text}`best_k_sacr`, 250, and 699 (i.e., all of the training data).
709+
our K-NN regression model for 6 different values for $K$: 1, 3, 25, {glue:text}`best_k_sacr`, 250, and 699 (i.e., all of the training data).
710710
For each model, we predict prices for the range of possible home sizes we
711711
observed in the data set (here 500 to 5,000 square feet) and we plot the
712712
predicted prices as a orange line.

0 commit comments

Comments
 (0)