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

Lab 2: Assignment 3 fixes

parent a7786d6f
No related branches found
No related tags found
No related merge requests found
......@@ -36,10 +36,13 @@ U <- principle_components$rotation
principle_components$x[, 1]
plot(U[, 1],
main = "PC1",
col = "blue",
ylab = "Magnitude", pch = 19)
plot(
U[, 1],
main = "PC1",
col = "blue",
ylab = "Magnitude",
pch = 19
)
ordered_abs <- order(abs(U[, 1]), decreasing = TRUE)
......@@ -136,19 +139,15 @@ legend(
pch = c(NA, NA, 19),
)
early_stopping <- which.min(test_errors)
early_stopping
optimal_iteration <- which.min(test_errors)
optimal_iteration
test_errors[early_stopping]
train_errors[optimal_iteration]
test_errors[optimal_iteration]
points(early_stopping,
test_errors[early_stopping],
points(optimal_iteration,
test_errors[optimal_iteration],
col = "green",
pch = 19)
optimal_theta <- res$par
optimal_train_mse <- res$value
optimal_train_mse
optimal_test_mse <- MSE(y_test, as.matrix(X_test) %*% optimal_theta)
optimal_test_mse
\ No newline at end of file
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