R/transformers.R
penalty_l2.Rd
Creates a penalty function that computes the L2 norm squared (sum of squares). Used for parameter shrinkage.
penalty_l2(weights = NULL)
Optional parameter weights (default: all 1)
Penalty function
penalty <- penalty_l2() penalty(c(1, -2, 3)) # Returns 14 #> [1] 14 # Weighted L2 penalty <- penalty_l2(weights = c(1, 2, 1)) penalty(c(1, -2, 3)) # Returns 1^2 + (2*2)^2 + 3^2 = 26 #> [1] 26