R/loss_and_reg_functions.R

Defines functions ls_loss zero_reg L1_reg L2_reg

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 20, 2019, 8:15 a.m.