Hi I am using the caret package and training a model with a knn algorithm but I am running into an error. I am using the german credit data and this is the structure of the data frame
'data.frame': 1000 obs. of 21 variables:
$ checking_balance : Factor w/ 4 levels "< 0 DM","> 200 DM",..: 1 3 4 1 1
$ months_loan_duration: int 6 48 12 42 24 36 24 36 12 30 ...
$ credit_history : Factor w/ 5 levels "critical","delayed",..: 1 5 1 5
$ purpose : Factor w/ 10 levels "business","car (new)",..: 8 8 5
$ amount : int 1169 5951 2096 7882 4870 9055 2835 6948 3059
$ savings_balance : Factor w/ 5 levels "< 100 DM","> 1000 DM",..: 5 1
$ employment_length : Factor w/ 5 levels "> 7 yrs","0 - 1 yrs",..: 1 3 4
$ installment_rate : int 4 2 2 2 3 2 3 2 2 4 ...
$ personal_status : Factor w/ 4 levels "divorced male",..: 4 2 4 4 4
$ other_debtors : Factor w/ 3 levels "co-applicant",..: 3 3 3 2 3 3
$ residence_history : int 4 2 3 4 4 4 4 2 4 2 ...
$ property : Factor w/ 4 levels "building society savings",..:
$ age : int 67 22 49 45 53 35 53 35 61
$ installment_plan : Factor w/ 3 levels "bank","none",..: 2 2 2 2 2 2
$ housing : Factor w/ 3 levels "for free","own",..: 2 2 1 2 3
$ existing_credits : int 2 1 1 1 2 1 1 1 ...
$ default : Factor w/ 2 levels "1","2": 1 2 1 1 2 1 1 2 ...
$ dependents : int 1 1 2 2 2 2 1 1 ...
$ telephone : Factor w/ 2 levels "none","yes": 2 1 1 1 2 1 1 .
$ foreign_worker : Factor w/ 2 levels "no","yes": 2 2 2 2 2 2 2 ...
$ job : Factor w/ 4 levels "mangement self-employed",..: 2
the target variable is credit$default
when I run the code
cv_opts = trainControl(method="repeatedcv", repeats = 5)
model_knn<-train(trainSet[,predictors],trainSet[,outcomeName],method="knn", trControl=cv_opts)
I get this error
Something is wrong; all the Accuracy metric values are missing:
Accuracy Kappa
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
NA's :3 NA's :3
Error: Stopping
In addition: There were 50 or more warnings (use warnings() to see the first 50)
I use that same code with other methods, rpart, ada, and it works, it seems I am like I am missing something in the trControl for the knn?