【问题标题】:Making AUC the metric to optimize training使 AUC 成为优化训练的指标
【发布时间】:2015-07-17 22:25:19
【问题描述】:

我的数据集中有 2 个水平因子结果变量

str(as.factor(train2$outcome))
 Factor w/ 2 levels "0","1": 1 1 1 1 2 1 2 1 1 1 ...

当我使用带有默认度量的训练函数来优化 evrt 时似乎还可以。

cvCtrl <- trainControl(method="repeatedcv", number=3, repeats=5,classProb = TRUE)
modelFit <- train(as.factor(outcome) ~., data=train2, method="rf", trControl =cvCtrl)

但我想优化 AUC。所以我使用这个代码

cvCtrl <- trainControl(method="repeatedcv", number=3, repeats=5, summaryFunction = twoClassSummary,classProb = TRUE)
modelFit <- train(as.factor(outcome) ~., data=train2, method="rf", trControl =cvCtrl, metric="ROC")

我得到一个错误:

Error in train.default(x, y, weights = w, ...) : 
  final tuning parameters could not be determined

我做错了什么?

【问题讨论】:

    标签: r random-forest r-caret training-data


    【解决方案1】:

    你看到警告了吗

    At least one of the class levels are not valid R variables names; This may cause errors if class probabilities are generated because the variables names will be converted to ...

    使用01 作为因子水平是一个坏主意,也是错误的根源。

    最大

    【讨论】:

    • 仍在寻找这个问题的答案。 train(metric = 'ROC', trControl = trainControl(summaryFunction = 'ROC'), ...) 能解决问题吗?
    猜你喜欢
    • 2019-06-27
    • 1970-01-01
    • 2018-03-28
    • 2019-02-13
    • 2020-08-25
    • 1970-01-01
    • 1970-01-01
    • 2022-12-20
    • 2014-02-21
    相关资源
    最近更新 更多