小编Luc*_*o91的帖子

如何在R中绘制Logistic回归(LASSO)的ROC曲线?

我将逻辑回归模型拟合到R中的训练数据集,更具体地说是具有L1惩罚的LASSO回归.我用了这个glmnet包.模型的代码如下所示.

t1 <- Sys.time()
glmnet_classifier <- cv.glmnet(x = dtm_train_tfidf,
                           y = tweets_train[['sentiment']], 
                           family = 'binomial', 
                           # L1 penalty
                           alpha = 1,
                           # interested in the area under ROC curve
                           type.measure = "auc",
                           # 5-fold cross-validation
                           nfolds = 5,
                           # high value is less accurate, but has faster training
                           thresh = 1e-3,
                           # again lower number of iterations for faster training
                           maxit = 1e3)
print(difftime(Sys.time(), t1, units = 'mins'))

preds <- predict(glmnet_classifier, dtm_test_tfidf, type = 'response')[ ,1]
Run Code Online (Sandbox Code Playgroud)

现在我想绘制ROC曲线.但是,我无法弄清楚如何准确地绘制它.

当我 …

r glmnet roc logistic-regression

0
推荐指数
1
解决办法
3761
查看次数

标签 统计

glmnet ×1

logistic-regression ×1

r ×1

roc ×1