R package that fits lasso and elastic-net regularized generalized linear models
open sourceGPL-2.0-onlyfree
glmnet is an R package that fits the whole lasso or elastic-net regularization path for linear, multi-task Gaussian, logistic and multinomial, Poisson and Cox regression, using cyclical coordinate descent. It also takes any GLM family object, refits each active set unpenalized with the relax option, cross-validates with cv.glmnet, assesses models on test data (confusion matrices, ROC plots), builds model matrices with one-hot encoding and missing-value handling, and accepts sparse matrices. Version 5 rewrote its kernels in C++. Its authors include Jerome Friedman, Trevor Hastie and Rob Tibshirani, and a companion book covers it with worked examples.
Problems it solves
- fit a lasso regression in R
- pick predictors automatically from hundreds of variables
- regularized logistic regression with cross-validation in R
Features
- Fits the entire lasso or elastic-net path for linear, logistic, multinomial, Poisson and Cox models
- Any GLM family object as the family argument
- Relaxed fits that refit each active set without the penalty
- Cross-validation with cv.glmnet and assessment on test data
- Sparse matrix input and model-matrix helpers with one-hot encoding
Alternatives
The same job
These do what glmnet does.
- ranger (R) Fast random forests for R and C++, suited to high-dimensional data
