Skip to content

Instantly share code, notes, and snippets.

@GabrielHoffman
Created July 24, 2020 22:11
Show Gist options
  • Save GabrielHoffman/5c9b678c28c49b3676ece9f189ab9b7f to your computer and use it in GitHub Desktop.
Save GabrielHoffman/5c9b678c28c49b3676ece9f189ab9b7f to your computer and use it in GitHub Desktop.
library(glmnet)
# You must have glmnet v4 from CRAN
# See documentation: https://glmnet.stanford.edu
# multinomial elastic-net
# you can change alpha
fit = glmnet( X_PRS, metadata$Catogory_factor, family="multinomial", alpha = .8, type.multinomial = "grouped")
# see regularization path
plot(fit)
# cross-validation with cv.glmnet
# get the predicted cagority, or the scores with predict(fit,...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment