Skip to contents

Lasso cost, 2*alpha convention (Geron Eq 4-11, morie.fn grn011)

Usage

morie_geron_ch4_lasso_regression_cost_function(
  X,
  y,
  theta,
  alpha,
  penalize_intercept = FALSE
)

Arguments

X, y, theta

Design, targets and parameters.

alpha

Non-negative weight; the penalty uses 2 * alpha.

penalize_intercept

Include theta[1] in the penalty.

Value

List with cost, mse, l1_penalty, l1_norm, effective_alpha.

Examples

morie_geron_ch4_lasso_regression_cost_function(X = c(1, 2, 3, 4, 5, 6, 7, 8), y = 5L,
  theta = c(1, 2, 3, 4, 5, 6, 7, 8), alpha = 0.5)
#> $cost
#> [1] 39636
#> 
#> $mse
#> [1] 39601
#> 
#> $l1_penalty
#> [1] 35
#> 
#> $l1_norm
#> [1] 35
#> 
#> $alpha
#> [1] 0.5
#> 
#> $effective_alpha
#> [1] 1
#> 
#> $estimate
#> [1] 39636
#> 
#> $n
#> [1] 1
#>