loss_type

The different loss types. Such as thought based on parametric distributions.

class pygom.loss.loss_type.Square(y, weights=None)

Square loss object

Parameters:
y: array like

observations

diff2Loss(yhat)

Twice derivative of the square loss. Which is simply 2.

Parameters:
yhat: array like

observations

Returns:
array with values of 2:

either a scalar, vector or matrix depending on the shape of of the input yhat

diff_loss(yhat)

Derivative under square loss. Assuming that we are solving the minimization problem i.e. our objective function is the negative of the log-likelihood

Parameters:
yhat: array like

observation

Returns:
\(-2(y_{i} - \hat{y}_{i})\)
loss(yhat)

Loss under square loss. Not really saying much here

Parameters:
yhat: array like

observation

Returns:
\(\sum_{i=1}^{n} (\hat{y} - y)^{2}\)
residual(yhat)

Raw residuals if no weights was initialized, else the weighted residuals

Parameters:
yhat: array like

observation

Returns:
\(y_{i} - \hat{y}_{i}\)
class pygom.loss.loss_type.Normal(y, sigma=1.0)

Normal distribution loss object

Parameters:
y: array like

observation

sigma: float

standard deviation

diff2Loss(yhat)

Twice derivative of the normal loss.

Parameters:
yhat: array like

observations

Returns:
s: array like

inverse of the variance with shape = yhat.shape

diff_loss(yhat)

Derivative of the loss function which is \(\sigma^{-1}(y - \hat{y})\)

Parameters:
yhat: array like

observation

Returns:
r: array like

\(\nabla \mathcal{L}(\hat{y}, y)\)

loss(yhat)

The loss under a normal distribution. Defined as the negative log-likelihood here.

Parameters:
yhat: array like

observation

Returns:
negative log-likelihood, \(\mathcal{L}(\hat{y},y)\)
residual(yhat)

Residuals under a normal loss

Parameters:
yhat: array like

observation

Returns:
r: array like

residuals

class pygom.loss.loss_type.Poisson(y)

Poisson distribution loss object

Parameters:
y: array like

observation

diff2Loss(yhat)

Twice derivative of the Poisson loss.

Parameters:
yhat: array like

observations

Returns:
s: array like

\(\frac{y}{\hat{y}^{2}}\) with shape = yhat.shape

diff_loss(yhat)

Derivative of the loss function, \(1 - y\hat{y}^{-1}\)

Parameters:
yhat: array like

observation

Returns:
\(\nabla \mathcal{L}(\hat{y},y)\)
loss(yhat)

The loss under a Poisson distribution. Defined as the negative log-likelihood here.

Parameters:
yhat: array like

observation

Returns:
negative log-likelihood, \(\mathcal{L}(\hat{y}, y)\)
residual(yhat)

Raw residuals

Parameters:
yhat: array like

observation

Returns:
r: array like

residuals