C5.0 models require a factor outcome

Your problem is that C5.0 models require a factor outcome. You have given the outcome as credit_train$default, which is a 1/2 outcome, but R has read it as numeric, rather than a factor:

str(credit_train$default)
int [1:900] 2 1 1 1 2 1 2 2 1 1 ...

The solution then is to convert it to a factor:

credit_train$default<-as.factor(credit_train$default)
str(credit_train$default)

Factor w/ 2 levels "1","2": 2 1 1 1 2 1 2 2 1 1 ...

And then run your training:

 credit_model<-C5.0(credit_train[-21],credit_train$default)

Tags:

R