C5.0 decision tree - c50 code called exit with value 1

前端 未结 6 1192
再見小時候
再見小時候 2020-12-06 17:38

I am getting the following error

c50 code called exit with value 1

I am doing this on the titanic data available from Kaggle

<
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-06 18:14

    Here is what worked finally:-

    Got this idea after reading this post

    library(C50)
    
    test$Survived <- NA
    
    combinedData <- rbind(train,test)
    
    combinedData$Survived <- factor(combinedData$Survived)
    
    # fixing empty character level names 
    levels(combinedData$Cabin)[1] = "missing"
    levels(combinedData$Embarked)[1] = "missing"
    
    new_train <- combinedData[1:891,]
    new_test <- combinedData[892:1309,]
    
    new_model <- C5.0(new_train[,-2],new_train$Survived)
    
    new_model_predict <- predict(new_model,new_test)
    
    submitC50 <- data.frame(PassengerId=new_test$PassengerId, Survived=new_model_predict)
    write.csv(submitC50, file="c50dtree.csv", row.names=FALSE)
    

    The intuition behind this is that in this way both the train and test data set will have consistent factor levels.

提交回复
热议问题