Predicting Probabilities for GBM with caret library

前端 未结 3 1828
谎友^
谎友^ 2020-12-10 17:44

A similar question was asked however the link in the answer points to random forest example, it doesn\'t seem to work in my case.

Here is an example what I\'m trying

相关标签:
3条回答
  • 2020-12-10 18:14

    As topepo explained above, the function is getting confused by the variable names being generated.

    If you run:

    make.names(levels(traintestClass_subset))
    

    and the result is different to how you have labelled the classes in your outcome variable than this issue will occur. Just make sure names generated by the piece of code above align with the class names you have provided to your factor and it should work.

    0 讨论(0)
  • 2020-12-10 18:32

    It's the key:

    I get a binary vector of predictions, which is good:

    [1] 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0 1 ...

    Your factor labels could be interpret as numeric. I don't know why, but if you change 0 on 'a' and 1 on 'b' for instance, it will work without errors.

    0 讨论(0)
  • 2020-12-10 18:36

    When class probabilities are requested, train puts them into a data frame with a column for each class. If the factor levels are not valid variable names, they are automatically changed (e.g. "0" becomes "X0"). train issues a warning in this case that goes something like "At least one of the class levels are not valid R variables names. This may cause errors if class probabilities are generated."

    0 讨论(0)
提交回复
热议问题