Error:C5.0 models require a factor outcome

r
decision_trees

#1

I am currently working on titanic problem of kaggle while creating a classification model I am getting the error
C5.0 models require a factor outcomebut I am not able to resolve it.

library(C50)
train<-read.csv(“train2.csv”)
test<-read.csv(“test2.csv”)
test$Survived<-NA #both the train and test data set will have same factor levels.
test$Survived<-NA
combinedData <- rbind(train,test)
new_train <- combinedData[1:891,]
new_test <- combinedData[892:1309,]
m1 <- C5.0(new_train[,-2],new_train[,2])
Error in C5.0.default(new_train[, -2], new_train[, 2]) :
C5.0 models require a factor outcome


#2

@hinduja1234 - Did you converted the target variable “survived” to a factor ? By default it is an integer and in order to apply a classification algorithm, you should be converting the target variable to a factor.