Recognizing a road sign with kNN
After several trips with a human behind the wheel, it is time for the self-driving car to attempt the test course alone.
As it begins to drive away, its camera captures the following image:

Can you apply a kNN classifier to help the car recognize this sign?
The dataset signs is loaded in your workspace along with the data frame next_sign, which holds the observation you want to classify.
Latihan ini adalah bagian dari kursus
Supervised Learning in R: Classification
Petunjuk latihan
- Load the
classpackage. - Create a vector of sign labels to use with kNN by extracting the column
sign_typefromsigns. - Identify the
next_signusing theknn()function.- Set the
trainargument equal to thesignsdata frame without the first column. - Set the
testargument equal to the data framenext_sign. - Use the vector of labels you created as the
clargument.
- Set the
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# Load the 'class' package
# Create a vector of labels
sign_types <- ___
# Classify the next sign observed
knn(train = ___[-1], test = ___, cl = ___)