pypairs.utils.evaluate_prediction

pypairs.utils.evaluate_prediction(prediction, reference)

Calculates F1 Score, Recall and Precision of a cyclone() prediction.

Parameters:
prediction : Iterable[str]

List of predicted classes.

reference : Iterable[str]

List of actual classes

Return type:

DataFrame

Returns:

  • A DataFrame with columns “f1”, “recall”, “precision” and “average”
  • for all categories and a overall average containing the respective score.

Example

To get the prediction quality for the example usecase of cyclone() run:

from pypairs import pairs, datasets, utils, plotting
import numpy as np

adata = datasets.leng15('sorted')
marker_pairs = datasets.default_cc_marker()
scores = pairs.cyclone(adata, marker_pairs)

ref_labels = list(np.repeat("G2M", 76)) + list(np.repeat("S", 80)) + list(np.repeat("G1", 91))

prediction_quality = utils.evaluate_prediction(scores['max_class'], ref_labels)

print(prediction_quality)