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

前端 未结 6 1199
再見小時候
再見小時候 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:28

    I also struggled some hours with the same Problem (Return code "1") when building a model as well as when predicting. With the hint of answer of Marco I have written a small function to remove all factor levels equal to "" in a data frame or vector, see code below. However, since R does not allow for pass by reference to functions, you have to use the result of the function (it can not change the original dataframe):

    removeBlankLevelsInDataFrame <- function(dataframe) {
      for (i in 1:ncol(dataframe)) {
        levels <- levels(dataframe[, i])
        if (!is.null(levels) && levels[1] == "") {
          levels(dataframe[,i])[1] = "?"
        }
      }
      dataframe
    }
    
    removeBlankLevelsInVector <- function(vector) {
      levels <- levels(vector)
      if (!is.null(levels) && levels[1] == "") {
        levels(vector)[1] = "?"
      }
      vector
    }
    

    Call of the functions may look like this:

    trainX = removeBlankLevelsInDataFrame(trainX)
    trainY = removeBlankLevelsInVector(trainY)
    model = C50::C5.0.default(trainX,trainY)
    

    However, it seems, that C50 has a similar Problem with character columns containing an empty cell, so you will have probably to extend this to handle also character attributes if you have some.

提交回复
热议问题