Skip to content
Snippets Groups Projects
Commit da3d2dcc authored by Felix Ramnelöv's avatar Felix Ramnelöv
Browse files

Lab 2: Updated and added figures

parent 40e10eee
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ lambda_with_k_features = function(x_train, y_train, alpha, k = 3) {
fit_train <- glmnet(as.matrix(X_train), y_train, alpha = alpha)
plot(fit_train, xvar = "lambda", label = TRUE)
grid()
coef_matrix <- as.matrix(coef(fit_train))[-1, ] # Ignore intercept
......@@ -65,6 +66,7 @@ print(lambda_with_3_features)
fit <- cv.glmnet(as.matrix(X_train), y_train, alpha = 1) # Cross-validation
plot(fit, xvar = "lambda", label = TRUE)
grid()
fit$lambda.min
......@@ -77,6 +79,7 @@ plot(
y_hat,
xlab = "Observed test values",
ylab = "Predicted test values",
main = "Original versus predicted test values ",
main = "Original vs. predicted test values ",
col = "blue"
)
grid()
This diff is collapsed.
lab2/figures/assignment1-3.png

7.19 KiB

This diff is collapsed.
lab2/figures/assignment1-4.png

18.1 KiB

This diff is collapsed.
lab2/figures/assignment1-5-1.png

5.06 KiB

This diff is collapsed.
lab2/figures/assignment1-5-2.png

5.97 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment