Skip to contents

Elastic net cost: MSE + r\*alpha\*L1 + (1-r)/2\*alpha\*L2 (hmenet)

Usage

morie_geron_elastic_net(X, y, theta, alpha, r, fit_intercept = TRUE)

Arguments

X, y

Data.

theta

Parameters (bias first if fit_intercept).

alpha

Overall penalty (>=0).

r

L1 ratio in [0, 1].

fit_intercept

Logical.

Value

List with cost, mse, l1_penalty, l2_penalty, gradient.

Examples

morie_geron_elastic_net(matrix(c(1, 2), 2, 1), c(2, 4), c(0,
    2), alpha = 1, r = 0.5)
#> $cost
#> [1] 2
#> 
#> $mse
#> [1] 0
#> 
#> $l1_penalty
#> [1] 1
#> 
#> $l2_penalty
#> [1] 1
#> 
#> $penalty
#> [1] 2
#> 
#> $gradient
#> [1] 0.0 1.5
#> 
#> $alpha
#> [1] 1
#> 
#> $r
#> [1] 0.5
#> 
#> $estimate
#> [1] 2
#> 
#> $n
#> [1] 2
#> 
#> $method
#> [1] "elastic net J = MSE + r*alpha*L1 + (1-r)/2*alpha*L2"
#>