我想做一个二进制分类,一个级别是“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”指标等“顶部”做出更多预测?我应该将“顶部”翻转为正类,将“底部”翻转为负类,我该如何改变它?