R/loss_and_reg_functions.R

Defines functions L2_reg L1_reg zero_reg ls_loss

Documented in L1_reg L2_reg ls_loss zero_reg

#' Least-squared loss function
#' @param x numeric vector.
#' @param y numeric vector.
#' @export
ls_loss <- function(x, y) mean((x - y) ^ 2)


#' Zero regularisation function
#' @export
zero_reg <- function(x) 0


#' L1 regularisation function
#' @export
L1_reg <- function(param) sum(abs(param))


#' L2 regularisation function
#' @export
L2_reg <- function(param) sum(param ^ 2)
kcf-jackson/wandeRer documentation built on May 18, 2017, 5:43 p.m.