
Elastic net cost, Eq 4-13 convention (morie.fn grn013)
Source:R/geron_train_native.R
morie_geron_ch4_elastic_net_cost_function.RdJ = MSE + 2 r alpha L1 + (1-r)(alpha/m) L2.
Usage
morie_geron_ch4_elastic_net_cost_function(
X,
y,
theta,
alpha,
r,
penalize_intercept = FALSE
)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_ch4_elastic_net_cost_function(X, y, th, 0.4, 0.6)
#> $cost
#> [1] 1.0189
#>
#> $mse
#> [1] 0.4425
#>
#> $l1_penalty
#> [1] 0.528
#>
#> $l2_penalty
#> [1] 0.0484
#>
#> $l1_norm
#> [1] 1.1
#>
#> $l2_norm_sq
#> [1] 1.21
#>
#> $alpha
#> [1] 0.4
#>
#> $r
#> [1] 0.6
#>
#> $estimate
#> [1] 1.0189
#>
#> $n
#> [1] 4
#>