【发布时间】:2016-02-11 23:13:36
【问题描述】:
我想做一个二进制分类,一个是“top”,另一个是“bottom”。我在 h2o 包中使用 gbm 并将“底部”作为正类,将“顶部”作为负类。 这是我的代码:
fit <- h2o.gbm(x = regr.var, y = max.var,
training_frame = ddd,
nfolds = 10,
distribution = 'multinomial',
balance_classes = TRUE)
pred <- as.data.frame(h2o.predict(fit, newdata = eee))
threshold <- 0.5
pred1 <- factor( ifelse(pred[, 'top'] > threshold, 'top', 'bottom') )
err.res<-confusionMatrix(pred1 , hh$score_class)
err.res
结果如下:
Confusion Matrix and Statistics
Reference
Prediction bottom top
bottom 420 123
top 1 6
Accuracy : 0.7745
95% CI : (0.7373, 0.8088)
No Information Rate : 0.7655
P-Value [Acc > NIR] : 0.3279
Kappa : 0.0657
Mcnemar's Test P-Value : <2e-16
Sensitivity : 0.99762
Specificity : 0.04651
Pos Pred Value : 0.77348
Neg Pred Value : 0.85714
Prevalence : 0.76545
Detection Rate : 0.76364
Detection Prevalence : 0.98727
Balanced Accuracy : 0.52207
'Positive' Class : bottom
但我想正确预测更多“顶部”。我尝试将阈值更改为 0.3,它的性能更好。但是,我是否应该在拟合过程中进行更改以对“ROC”指标等“顶部”做出更多预测?我应该将“顶部”翻转为正类,将“底部”翻转为负类,我该如何改变它?
【问题讨论】:
-
R 没有正负因子变量的概念。这完全由 h2o 包处理,所以你应该问那些人。通常大多数第三方工具都能正确理解 0 和 1。
标签: r classification roc gbm h2o