Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tdde01-ht24
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mehce338-felra653-sigjo290
tdde01-ht24
Commits
f2931eac
Commit
f2931eac
authored
3 months ago
by
Felix Ramnelöv
Browse files
Options
Downloads
Patches
Plain Diff
Lab 2: Assignment 3 fixes
parent
a7786d6f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lab2/assignment3.R
+13
-14
13 additions, 14 deletions
lab2/assignment3.R
with
13 additions
and
14 deletions
lab2/assignment3.R
+
13
−
14
View file @
f2931eac
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment