I used cv.glmnet to create a model using one dataset ("Dataset 1"), but now I would like to look at performance (e.g., AUC) when predicting outcomes for new data ("Dataset 2"). I know that I can use predict.glmnet to predict new data, but the output is just a list of predicted outcomes for each observation in Dataset 2. How do I actually summarize the predictive performance (e.g., AUC) of a cv.glmnet model on on Dataset 2?

For example, it would be nice to be able to save the predictions for Dataset 2 as a new column. From there I can just calculate performance myself manually, but ideally I'd like to know if there is a way to have these indices calculated for me.


Here is one way using the pROC library in R:

labels = c(1,1,1,0,0,1,0,1,0)
pred = c(.1,.1,.3,0,0.1,.6,0.2,.8,0)

auc(roc(labels, pred))


Area under the curve: 0.85

source: https://blog.revolutionanalytics.com/2016/11/calculating-auc.html

  • $\begingroup$ Thank you! Sometimes I have a harder time finding answers to the simplest problems than more complex ones. $\endgroup$ – Jdclark Apr 2 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.