exact_match_score#

scikitplot.corpus.exact_match_score(y_true, y_pred, *, normalize='squad', sample_weight=None, average='mean')[source]#

Fraction of predicted answers equal to a reference after normalisation.

Parameters:
y_truesequence or mapping

Reference answers per item: a str or a sequence of str.

y_predsequence or mapping

Predicted answer per item (str), aligned with y_true.

normalize{“squad”, “basic”, None}, default=”squad”

Normalisation of both sides.

sample_weightarray-like of shape (n_items,), default=None

Per-item weights of the mean.

average{“mean”, None}, default=”mean”

None returns per-item values.

Returns:
float or numpy.ndarray
Raises:
TypeError, ValueError

For malformed inputs; the message names the item.

Parameters:
  • y_true (Any)

  • y_pred (Any)

  • normalize (str | None)

  • sample_weight (Any)

  • average (str | None)

Return type:

Any

Examples

>>> exact_match_score(
...     ["The Eiffel Tower", ["Paris", "City of Paris"]], ["eiffel tower.", "Lyon"]
... )
0.5