November 2016
Beginner to intermediate
959 pages
43h 46m
English
The class package contains the knn function for KNN classification.
If you have not already installed the class and caret packages, install them now. Download the data files for this chapter from the book's website and place the vacation-trip-classification.csv file in your R working directory. KNN requires all the independent/predictor variables to be numeric, and the dependent variable or target to be categorical. So, if needed, you should first convert variables accordingly—refer to the recipes Creating dummies for categorical variables and Binning numerical data in Chapter, Acquire and Prepare the Ingredients – Your Data.
To classify using the K-Nearest Neighbours method, follow ...
Read now
Unlock full access