API reference

andrey.metrics.direction_accuracy#

andrey.metrics.direction_accuracy(pred, truth, *, weights=None)[source]#

Fraction of decided pairs whose predicted cause -> effect direction matches the truth.

pred and truth are per-pair signed labels (+1 = X -> Y, -1 = Y -> X); a pred of 0 is an abstention, dropped before scoring. weights gives optional per-pair weights (the Tuebingen-pairs standard). Returns 0.0 when nothing is decided; pair it with decision_rate() so a high accuracy from few decisions is visible.

Return type:

float

Examples

>>> direction_accuracy([1, 1, -1], [1, -1, -1])
0.6666666666666666