View source: R/glmnet_measure.R
glmnet_measure | R Documentation |
Extracts measures of model fitness from a glmnet
object.
glmnet_measure(
cv.model,
x = NULL,
y = NULL,
lambda.criteria = "lambda.min",
type.measure = c("default", "mse", "deviance", "class", "auc", "mae", "C"),
family = "gaussian",
alpha = 1
)
cv.model |
A model fit by |
x |
input matrix, of dimension nobs x nvars; each row is an observation
vector. Can be in sparse matrix format (inherit from class
|
y |
response variable. Quantitative for |
lambda.criteria |
Determines the model selection criteria. When
|
type.measure |
loss to use for cross-validation. Currently five
options, not all available for all models. The default is
|
family |
Either a character string representing
one of the built-in families, or else a |
alpha |
The elasticnet mixing parameter, with
|
A data frame containing measures of model fitness.
This function is primarily used within
compare_ssnet
, but perhaps could be useful elsewhere.
## generate data (no intercept)
set.seed(4799623)
cn <- c()
for (i in 1:100) cn[i] <- paste0("x", i)
tb <- rbinom(100, 1, 0.05)
tx <- matrix(rnorm(10000), nrow = 100, ncol = 100,
dimnames = list(1:100, cn))
ty <- tx %*% tb + rnorm(100)
## fit model and export model fit stats
cv1 <- cv.glmnet(x = tx, y = ty, family = "gaussian", alpha = 1)
glmnet_measure(cv1, x = tx, y = ty)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.