genestboost.loss_functions package

genestboost.loss_functions module.

class genestboost.loss_functions.AbsoluteLoss[source]

Bases: genestboost.loss_functions.base_class.BaseLoss

Absolute loss function class.

d2ldyp2(yt, yp)[source]

Calculate the second derivative of the loss with respect to yp.

Overrides BaseLoss.d2ldyp2.

dldyp(yt, yp)[source]

Calculate the first derivative of the loss with respect to yp.

Overrides BaseLoss.dldyp.

class genestboost.loss_functions.BaseLoss[source]

Bases: abc.ABC

Base class for loss functions.

abstract d2ldyp2(yt, yp)[source]

Calculate the second derivative of the loss with respect to yp.

abstract dldyp(yt, yp)[source]

Calculate the first derivative of the loss with respect to yp.

class genestboost.loss_functions.BetaLoss(alpha, beta, eps=1e-10)[source]

Bases: genestboost.loss_functions.base_class.BaseLoss

BetaLoss class implementation.

__init__(alpha, beta, eps=1e-10)[source]

Class initializer.

Extends BaseLoss.__init__.

Parameters
  • alpha (float) – Value of alpha in beta loss denominator, mu ** (1 - alpha)

  • beta (float) – Value of beta in beta loss denominator, (1 - mu) ** (1 - beta)

  • eps (float) – Small value to use in log calculations to avoid numerical error

static beta_callback(alpha, beta, eps=1e-10)[source]

Compute the beta callback function for quasi-deviance.

Parameters
  • alpha (float) – Value of alpha in beta loss denominator, mu ** (1 - alpha)

  • beta (float) – Value of beta in beta loss denominator, (1 - mu) ** (1 - beta)

  • eps (float) – Small value to use in log calculations to avoid numerical error

Returns

A callable that takes an np.ndarray and returns an np.ndarray after calculating the beta quasi-deviance denominator

Return type

callable

d2ldyp2(yt, yp)[source]

Calculate the second derivative of the loss with respect to yp.

Overrides BaseLoss.d2ldyp2.

dldyp(yt, yp)[source]

Calculate the first derivative of the loss with respect to yp.

Overrides BaseLoss.dldyp.

class genestboost.loss_functions.LeakyBetaLoss(alpha, beta, gamma=1.0, eps=1e-10, xtol=1e-08)[source]

Bases: genestboost.loss_functions.beta_loss.BetaLoss

Class implementation of LeakyBetaLoss loss function.

__init__(alpha, beta, gamma=1.0, eps=1e-10, xtol=1e-08)[source]

Class initializer.

Extends BetaLoss.__init__.

Parameters
  • alpha (float) – Passed as the alpha argument to the BetaLoss initializer

  • beta (float) – Passed as the beta argument to the BetaLoss initializer

  • eps (float, optional) – Passed as the eps argument to the BetaLoss initializer (the default value is 1e-10)

  • gamma (float, optional) – A float in the range (0.0, 1.0] specifying … (the default value is 1.0)

  • xtol (float, optional) – Passed as the xtol argument to scipy.optimize.bisect (the default value is 1e-8)

d2ldyp2(yt, yp)[source]

Calculate the second derivative of the loss with respect to yp.

Overrides BaseLoss.d2ldyp2.

dldyp(yt, yp)[source]

Calculate the first derivative of the loss with respect to yp.

Overrides BaseLoss.dldyp.

class genestboost.loss_functions.LeastSquaresLoss[source]

Bases: genestboost.loss_functions.base_class.BaseLoss

Least squares loss function class.

d2ldyp2(yt, yp)[source]

Calculate the second derivative of the loss with respect to yp.

Overrides BaseLoss.d2ldyp2.

dldyp(yt, yp)[source]

Calculate the first derivative of the loss with respect to yp.

Overrides BaseLoss.dldyp.

class genestboost.loss_functions.LogCoshLoss[source]

Bases: genestboost.loss_functions.base_class.BaseLoss

Log cosh loss function class.

d2ldyp2(yt, yp)[source]

Calculate the second derivative of the loss with respect to yp.

Overrides BaseLoss.d2ldyp2.

dldyp(yt, yp)[source]

Calculate the first derivative of the loss with respect to yp.

Overrides BaseLoss.dldyp.

class genestboost.loss_functions.LogLoss(eps=1e-12)[source]

Bases: genestboost.loss_functions.base_class.BaseLoss

Log loss function class.

__init__(eps=1e-12)[source]

Class initializer.

Extends the BaseLoss class intializer.

eps: float (default = 1e-10)

A small constant float to prevent log from returning negative infinity.

d2ldyp2(yt, yp)[source]

Calculate the second derivative of the loss with respect to yp.

Overrides BaseLoss.d2ldyp2.

dldyp(yt, yp)[source]

Calculate the first derivative of the loss with respect to yp.

Overrides BaseLoss.dldyp.

class genestboost.loss_functions.PoissonLoss[source]

Bases: genestboost.loss_functions.base_class.BaseLoss

Poisson loss function class.

d2ldyp2(yt, yp)[source]

Calculate the second derivative of the loss with respect to yp.

Overrides BaseLoss.d2ldyp2.

dldyp(yt, yp)[source]

Calculate the first derivative of the loss with respect to yp.

Overrides BaseLoss.dldyp.

class genestboost.loss_functions.QuantileLoss(p)[source]

Bases: genestboost.loss_functions.base_class.BaseLoss

Quantile regression loss function class.

__init__(p)[source]

Class initializer.

Extends BaseLoss.__init__.

Parameters

p (float) – Value in the interval (0, 1) representing the quantile to regress on.

d2ldyp2(yt, yp)[source]

Calculate the second derivative of the loss with respect to yp.

Overrides BaseLoss.d2ldyp2.

dldyp(yt, yp)[source]

Calculate the first derivative of the loss with respect to yp.

Overrides BaseLoss.dldyp.

class genestboost.loss_functions.QuasiLogLoss(vt_callback, d0_n=100, d2_eps=1e-12)[source]

Bases: genestboost.loss_functions.base_class.BaseLoss

QuasiLogLoss loss function class.

__init__(vt_callback, d0_n=100, d2_eps=1e-12)[source]

Class initializer.

Extends BaseLoss.__init__.

Parameters
  • vt_callback (callable(yp) -> np.ndarray) – Callable that takes the predicted value and calculates the denominator of the quasilog loss integral for each observation.

  • d0_n (int) – The number of points to use for integration.

  • d2_eps (float) – A small float used to calculate the second derivative via the central difference formula - 2*d2_eps the interval used to calculate the derivative from first derivative values.

d2ldyp2(yt, yp)[source]

Calculate the second derivative of the loss with respect to yp.

Overrides BaseLoss.d2ldyp2.

dldyp(yt, yp)[source]

Calculate the first derivative of the loss with respect to yp.

Overrides BaseLoss.dldyp.

class genestboost.loss_functions.StudentTLoss(scale=None, dof=2)[source]

Bases: genestboost.loss_functions.base_class.BaseLoss

Student’s t loss function class.

__init__(scale=None, dof=2)[source]

Class initializer.

Extends BaseLoss.__init__.

Parameters
  • scale (float, optional (default=None)) – The scale of the Student’s t distribution to use. If set to None, the default, then taken as (dof + 1.0) / 2.0.

  • dof (int) – The number of degrees of freedom for the Student’s t distribution to use.

d2ldyp2(yt, yp)[source]

Calculate the second derivative of the loss with respect to yp.

Overrides BaseLoss.d2ldyp2.

dldyp(yt, yp)[source]

Calculate the first derivative of the loss with respect to yp.

Overrides BaseLoss.dldyp.