@@ -324,7 +324,7 @@ Figure \@ref(fig:05-knn-1).
324
324
perim_concav_with_new_point <- bind_rows(cancer,
325
325
tibble(Perimeter = new_point[1],
326
326
Concavity = new_point[2],
327
- Class = "unknown ")) |>
327
+ Class = "Unknown ")) |>
328
328
ggplot(aes(x = Perimeter,
329
329
y = Concavity,
330
330
color = Class,
@@ -379,7 +379,7 @@ not, if you consider the other nearby points.
379
379
perim_concav_with_new_point2 <- bind_rows(cancer,
380
380
tibble(Perimeter = new_point[1],
381
381
Concavity = new_point[2],
382
- Class = "unknown ")) |>
382
+ Class = "Unknown ")) |>
383
383
ggplot(aes(x = Perimeter,
384
384
y = Concavity,
385
385
color = Class,
@@ -466,7 +466,7 @@ In order to find the $K=5$ nearest neighbors, we will use the `slice_min` functi
466
466
perim_concav <- bind_rows(cancer,
467
467
tibble(Perimeter = new_point[1],
468
468
Concavity = new_point[2],
469
- Class = "unknown ")) |>
469
+ Class = "Unknown ")) |>
470
470
ggplot(aes(x = Perimeter,
471
471
y = Concavity,
472
472
color = Class,
@@ -950,7 +950,7 @@ whether you need to standardize your data.
950
950
attrs <- c("Area", "Smoothness")
951
951
952
952
# create a new obs and get its NNs
953
- new_obs <- tibble(Area = 400, Smoothness = 0.135, Class = "unknown ")
953
+ new_obs <- tibble(Area = 400, Smoothness = 0.135, Class = "Unknown ")
954
954
my_distances <- table_with_distances(unscaled_cancer[, attrs],
955
955
new_obs[, attrs])
956
956
neighbors <- unscaled_cancer[order(my_distances$Distance), ]
@@ -989,7 +989,7 @@ unscaled <- ggplot(unscaled_cancer, aes(x = Area,
989
989
), color = "black", linewidth = 0.5, show.legend = FALSE)
990
990
991
991
# create new scaled obs and get NNs
992
- new_obs_scaled <- tibble(Area = -0.72, Smoothness = 2.8, Class = "unknown ")
992
+ new_obs_scaled <- tibble(Area = -0.72, Smoothness = 2.8, Class = "Unknown ")
993
993
my_distances_scaled <- table_with_distances(scaled_cancer[, attrs],
994
994
new_obs_scaled[, attrs])
995
995
neighbors_scaled <- scaled_cancer[order(my_distances_scaled$Distance), ]
@@ -1141,7 +1141,7 @@ neighbors <- rare_cancer[order(my_distances$Distance), ]
1141
1141
rare_plot <- bind_rows(rare_cancer,
1142
1142
tibble(Perimeter = new_point[1],
1143
1143
Concavity = new_point[2],
1144
- Class = "unknown ")) |>
1144
+ Class = "Unknown ")) |>
1145
1145
ggplot(aes(x = Perimeter, y = Concavity, color = Class, shape = Class)) +
1146
1146
geom_point(alpha = 0.5) +
1147
1147
labs(color = "Diagnosis",
0 commit comments