Something is wrong; all the Accuracy metric values are missing: getting this error while applying k-nn on iris data. ''' iris.knn<- iris
# Dividing data into test_train
set.seed(532)
sample.iris.knn <- sample.split(iris.knn, SplitRatio = 0.8)
train.iris.knn <- subset(iris.knn, sample.iris.knn== TRUE)
test.iris.knn <- subset(iris.knn, sample.iris.knn == FALSE)
dim(train.iris.knn)
str(train.iris.knn)
head(train.iris.knn)
# fitting K-nn model
set.seed(8237)
trControl.iris.knn <- trainControl(method = "repeatedcv",
number = 10,
repeats = 3)
iris.knn.model <- train(Species ~., data = train.iris.knn,
method = 'knn',
trainControl = trControl.iris.knn,
preProcess = c("center", "scale"),
tuneLength = 13)
# Model check
iris.knn.model
'''
CodePudding user response:
There is no argument in the function train
named trainControl
, it is trControl
so change it will solve your problem
iris.knn.model <- train(Species ~., data = train.iris.knn,
method = 'knn',
trControl = trControl.iris.knn,
preProcess = c("center", "scale"),
tuneLength = 13)