K-Nearest Neighbors calculation is skipping values

I posted the other day asking about a problem with my graphs, and got that figured out. However, I'm doing a kNN test on one of the tables, and the output CrossTable is skipping values and is not going 1-20 (for each possible final position in an F1 race) and is only outputting certain ones, and I cannot figure out why. Ideally, the table is 20x20.

y_ver = Verstappen2[,c("position")]

x_ver = Verstappen2[,c("grid", "laps")]

library(caret)
library(class)
library(gmodels)

inTrain <- createDataPartition(y = y_ver, p = 0.7, list = FALSE)

x_train_ver <- x_ver[inTrain,]

y_train_ver <- y_ver[inTrain]

x_test_ver <- x_ver[-inTrain,]

y_test_ver <- y_ver[-inTrain]

Verstappen_prediction <- knn(train = x_train_ver, test = x_test_ver, cl = y_train_ver, k = 3)

CrossTable( x = y_test_ver, y = Verstappen_prediction, prop.chisq = FALSE)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.