autointent.metrics.scoring.scoring_hit_rate#

autointent.metrics.scoring.scoring_hit_rate(labels, scores)#

Calculate the hit rate for multilabel classification.

The hit rate measures the fraction of cases where the top-ranked label is in the set of true labels for the instance.

\[\text{Hit Rate} = \frac{1}{N} \sum_{i=1}^N \mathbb{1}(y_{\text{top},i} \in y_{\text{true},i})\]

where: - \(N\) is the total number of instances, - \(y_{\text{top},i}\) is the top-ranked predicted label for instance \(i\), - \(y_{\text{true},i}\) is the set of ground truth labels for instance \(i\).

Parameters:
  • labels (autointent.metrics.custom_types.LABELS_VALUE_TYPE) – Ground truth labels for each sample

  • scores (autointent.metrics.custom_types.SCORES_VALUE_TYPE) – For each sample, this list contains scores for each of n_classes classes

Returns:

Hit rate score

Return type:

float