出于某种原因,在通过 混淆矩阵 和 AUC ROC 检查其准确性时,我的模型一直显示为较差的模型。这是我在进行向后消除后坚持使用的模型。这是逻辑输出:
`Call:
glm(formula = DEATH_EVENT ~ age + ejection_fraction + serum_sodium +
time, family = binomial(link = "logit"), data = train, control = list(trace = TRUE))
Deviance Residuals:
Min 1Q Median 3Q Max
-2.1760 -0.6161 -0.2273 0.4941 2.6827
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 15.741338 7.534348 2.089 0.03668 *
age 0.063767 0.018533 3.441 0.00058 ***
ejection_fraction -0.080520 0.019690 -4.089 4.33e-05 ***
serum_sodium -0.111499 0.053639 -2.079 0.03765 *
time -0.020543 0.003331 -6.167 6.95e-10 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1`
这是混淆矩阵输出
glm.pred Survived Dead
0 46 10
1 5 14
auc 显示为 0.178
library(pROC)
# Calculate predicted probabilities for test set
glm.probs <- predict(glm9, newdata=test, type="response")
# Create prediction object for test set
pred <- prediction(glm.probs, test$DEATH_EVENT)
# Create ROC curve for test set
roc.perf <- performance(pred, measure = "tpr", x.measure = "fpr")
# Plot ROC curve for test set
plot(roc.perf, legacy.axes = TRUE, percent = TRUE,
xlab = "False Positive Percentage", ylab = "True Positive Percentage",
col = "#3182bd", lwd = 4, print.auc = TRUE)
# Add AUC to ROC curve
auc <- as.numeric(performance(pred, measure = "auc")@y.values)
text(x = 0.5, y = 0.3, labels = paste0("AUC = ", round(auc, 3)),
col = "black", cex = 1.5)
abline(a=0, b= 1)
我怎样才能解决这个问题?
我检查了类,它显示存在数据不平衡。但我不知道如何处理这些知识。