crested.tl.losses.GiniLoss#

class crested.tl.losses.GiniLoss(starting_power=1.0, increase_scale=1.0, name='GiniLoss', reduction='sum_over_batch_size')#

Custom loss that varies between MAE and MSE depending on the gini score of the ground truth.

Parameters:
  • starting_power (float (default: 1.0)) – The lowest power the error is scaled with, in case of gini=0. Gini=1 adds 1*increase_scale to this. If 1 (default) and increase_scale=1, will scale between MAE (power of 1) and MSE (power of 2), depending on Gini coefficient.

  • increase_scale (float (default: 1.0)) – How much to increase the power per gini increase. Default of 1 will add between 0 and 1 to the starting power, setting to 2 will add between 0 and 2 (making power scale from 1 to 3 with default starting_power), etc.

  • name (str | None (default: 'GiniLoss')) – Name of the loss function.

  • reduction (str (default: 'sum_over_batch_size')) – Type of reduction to apply to loss.

Attributes table#

Methods table#

call(y_true, y_pred)

Calculate the loss value.

gini_scores(array[, eps])

Calculate gini scores for the provided array.

Attributes#

Methods#

GiniLoss.call(y_true, y_pred)#

Calculate the loss value.

GiniLoss.gini_scores(array, eps=1e-07)#

Calculate gini scores for the provided array.