if (FALSE) {
glmnet_formula <- matrix_to_formula(
fit_func = glmnet::glmnet,
predict_func = function(model, newX, ...) {
glmnet::predict.glmnet(model, newx = newX, s = 0.01, ...)
}
)
model <- glmnet_formula$fit(mpg ~ wt + hp + factor(cyl), data = mtcars)
glmnet_formula$predict(model, newdata = mtcars[1:5, ])
}
Run the code above in your browser using DataLab