I need to solve a classification using knn3()
, package caret
, from a data of airline service quality rate which is ordinal data ranging from 1-5 and categorical data like types of flying class like eco, business and eco plus. The target variable is satisfied or dissatisfied. I used model.matrix() to convert the categorical data to dummy variables and when I use the new dataset with the dummies, it gives me:
Error in
[.data.frame
(m, xvars) : undefined columns selected.
When I fit the original dataframe, the prediction of the knn model is wrong (it gave me decimals instead of 0 or 1 for satisfied and dissatisfied).
original data
head of original data
This is how I transformed the data:
transforming data
transformed data
When i fit in the knn3() function, this happens: error