anls_score#
- scikitplot.corpus.anls_score(y_true, y_pred, *, threshold=0.5, normalize='basic', backend='auto', sample_weight=None, average='mean')[source]#
Average normalised Levenshtein similarity (ANLS).
Per item,
s = 1 - NLwhen the normalised Levenshtein distanceNLto a reference is belowthresholdand 0 otherwise; the best reference counts.- Parameters:
- y_truesequence or mapping
Reference answers per item: a
stror a sequence ofstr.- y_predsequence or mapping
Predicted answer per item (
str), aligned withy_true.- thresholdfloat, default=0.5
In (0, 1]. Distances at or above it score 0, so an answer that is mostly wrong earns no partial credit.
- normalize{“basic”, “squad”, None}, default=”basic”
Normalisation of both sides.
- backend{“auto”, “python”}, default=”auto”
Edit-distance implementation (both exact).
- sample_weightarray-like of shape (n_items,), default=None
Per-item weights of the mean.
- average{“mean”, None}, default=”mean”
Nonereturns per-item values.
- Returns:
- float or numpy.ndarray
- Raises:
- TypeError, ValueError
For malformed inputs or a threshold outside (0, 1].
- Parameters:
- Return type:
Examples
>>> anls_score(["kitten", "kitten"], ["kitten", "dog"]) 0.5