
Elastic net cost (Geron Eq 4-12, morie.fn grelas)
Source:R/geron_train_native.R
morie_geron_elastic_net_cost.RdJ = MSE + r alpha L1 + ((1-r)/2) alpha L2, stacked on
morie_geron_lasso_cost() at r * alpha.
Examples
X <- matrix(c(1, 2, 1, 3, 1, 5, 1, 7), 4, byrow = TRUE)
y <- c(2, 3, 6, 9)
th <- c(0.5, 1.1)
morie_geron_elastic_net_cost(X, y, th, 0.4, 0.6)
#> $cost
#> [1] 0.8033
#>
#> $mse
#> [1] 0.4425
#>
#> $l1_penalty
#> [1] 0.264
#>
#> $l2_penalty
#> [1] 0.0968
#>
#> $l1_norm
#> [1] 1.1
#>
#> $l2_norm_sq
#> [1] 1.21
#>
#> $alpha
#> [1] 0.4
#>
#> $r
#> [1] 0.6
#>
#> $estimate
#> [1] 0.8033
#>
#> $n
#> [1] 4
#>