matchzoo.metrics.cross_entropy

CrossEntropy metric for Classification.

Module Contents

class matchzoo.metrics.cross_entropy.CrossEntropy

Bases: matchzoo.engine.base_metric.ClassificationMetric

Cross entropy metric.

ALIAS = ['cross_entropy', 'ce']
__repr__(self)
Returns:Formated string representation of the metric.
__call__(self, y_true:np.array, y_pred:np.array, eps:float=1e-12)

Calculate cross entropy.

Example

>>> y_true = [0, 1]
>>> y_pred = [[0.25, 0.25], [0.01, 0.90]]
>>> CrossEntropy()(y_true, y_pred)
0.7458274358333028
Parameters:
  • y_true – The ground true label of each document.
  • y_pred – The predicted scores of each document.
  • eps – The Log loss is undefined for p=0 or p=1, so probabilities are clipped to max(eps, min(1 - eps, p)).
Returns:

Average precision.