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

后端 未结 5 944
隐瞒了意图╮
隐瞒了意图╮ 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:30

    The answer is in bold at the top of your post =]

    What are you modeling? Is it alchemy_category? The code only says formula and we can't see it.

    When you ask for class probabilities, model predictions are a data frame with separate columns for each class/level. If alchemy_category doesn't have levels that are valid column names, data.frame converts then to valid names. That creates a problem because the code is looking for a specific name but the data frame as a different (but valid) name.

    For example, if I had

    > test <- factor(c("level1", "level 2")) 
    > levels(test)
    [1] "level 2" "level1" 
    > make.names(levels(test))
    [1] "level.2" "level1"
    

    the code would be looking for "level 2" but there is only "level.2".

提交回复
热议问题