Loss functions

statinf.ml.losses.binary_accuracy(y_true, y_pred)[source]

Accuracy for binary data

Parameters
  • y_true (numpy.array) – Real values on which to compare.

  • y_pred (numpy.array) – Predicted values

Returns

Binary accuracy (in percent)

Return type

float

statinf.ml.losses.binary_cross_entropy(y_true, y_pred, tensor=False)[source]

Binary cross-entropy

Parameters
  • y_true (numpy.array) – Real values on which to compare.

  • y_pred (numpy.array) – Predicted values.

  • tensor (bool, optional) – Perform computation as tensor (theano type), defaults to False

Formula

\(loss = y_{i} \log \left[ \hat{y}_{i} \right] + (1 - y_{i}) \log \left[1 - \hat{y}_{i} \right]\)

References
Returns

Binary cross-entropy

Return type

float

statinf.ml.losses.log_stability(x)[source]

Log-stability for computing loss

Parameters

x (float) – Input value

Returns

Scaled value where \(\hat{x} \in (0, 1)\)

Return type

float

statinf.ml.losses.mean_squared_error(y_true, y_pred, root=False)[source]

Mean Squared Error

Parameters
  • y_true (numpy.array) – Real values on which to compare.

  • y_pred (numpy.array) – Predicted values.

  • root (bool, optional) – Return Root Mean Squared Error (RMSE), defaults to False.

Formula

\(loss = \dfrac{1}{m} \times \sum_{i=1}^{m} (y_i - \hat{y}_i)^2\)

References
Returns

Mean Squared Error or its root.

Return type

float