# NOT RUN {
x = matrix(rnorm(100 * 20), 100, 20)
y = rnorm(100)
g2 = sample(1:2, 100, replace = TRUE)
g4 = sample(1:4, 100, replace = TRUE)
fit1 = glmnet(x, y)
assess.glmnet(fit1, newx = x, newy = y)
preds = predict(fit1, newx = x[1:20, ], s = c(0.01, 0.005))
assess.glmnet(preds, newy = y[1:20], family = "gaussian")
fit2 = glmnet(x, g2, family = "binomial")
plot(roc.glmnet(fit2, newx = x, newy = g2)[[20]])
fit2c = cv.glmnet(x, g2, family = "binomial")
plot(roc.glmnet(fit2c, newx = x, newy = g2, s = "lambda.min"))
fit3 = glmnet(x, g4, family = "multinomial")
confusion.glmnet(fit3, newx = x[1:50, ], newy = g4[1:50], s = 0.01)
# }
Run the code above in your browser using DataCamp Workspace