Error when I try to predict class probabilities in R - caret

后端 未结 5 953
隐瞒了意图╮
隐瞒了意图╮ 2020-12-09 08:38

I\'ve build a model using caret. When the training was completed I got the following warning:

Warning message: In train.default(x, y, weights = w, ...) : A

5条回答
  •  天涯浪人
    2020-12-09 09:05

    I have read through the answers above while facing a similar problem. A formal solution is to do this on the train and test datasets. Make sure you include the response variable in the feature.names too.

    feature.names=names(train)
    
    for (f in feature.names) {
      if (class(train[[f]])=="factor") {
        levels <- unique(c(train[[f]]))
        train[[f]] <- factor(train[[f]],
                       labels=make.names(levels))
      }
    }
    

    This creates syntactically correct labels for all factors.

提交回复
热议问题