Message error when trying to train a regression model using KNN method

Viewed 88

I'm currently taking an analytics class and i'm pretty much new to this. I'm trying to train a regression model using KNN, when I try set up the model using the train function, I keep receiving the following error message:

Error in `colnames<-`(`*tmp*`, value = gsub("^\\.", "", colnames(printed))) : attempt to set 'colnames' on an object with less than two dimensions

The code is:

TrControl <- trainControl(method = "repeatedcv",
                                 number = 10,
                          repeats = 3)
modele <- train(outcome ~ .,
                 data = Train,
                 tuneGrid = expand_grid(k=1:70),
                 method = 'knn',
                 trControl = TrControl,
                 preProc = c('center','scale'))

If anybody can help that would be great :)

PS : The data used for the model is a dataframe with 23 variables and 2580 observations with column names as the first row and observations in the others.

0 Answers
Related