Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Scikit-Learn · Function

recall_score

Computes recall, the proportion of actual positive cases identified by the predictions. It supports binary, multiclass, and multilabel targets through configurable label selection and averaging.

How it works

The function compares true and predicted target labels and computes the fraction of actual positive cases that were detected. For multiclass or multilabel data, the average option controls whether it returns per-label values or combines them using a selected averaging strategy.

Syntax

sklearn.metrics.recall_score(y_true, y_pred, *, labels=None, pos_label=1, average='binary', sample_weight=None, zero_division='warn')

Parameters

NameTypeDescription
y_true1d array-like, or label indicator array / sparse matrixGround-truth target values; sparse matrices are supported only for multilabel targets.
y_pred1d array-like, or label indicator array / sparse matrixEstimated targets produced by a classifier.
labelsarray-like, default=NoneLabels used to calculate recall.
pos_labelint, float, bool or str, default=1Positive class used in binary classification.
average{'micro', 'macro', 'samples', 'weighted', 'binary'} or None, default='binary'Averaging strategy: binary, micro, macro, samples, weighted, or None.
sample_weightarray-like of shape (n_samples,), default=NonePer-sample weights.
zero_division{'warn', 0.0, 1.0, np.nan}, default='warn'Value returned when division by zero occurs.

Returns

float when average is not None, or an array of float with shape (n_unique_labels,) when average=None.

Key points

  • recall_score evaluates predicted targets against ground-truth targets.
  • Recall divides true positives by all actual positives, which are true positives plus false negatives.
  • The metric is bounded from 0 to 1, with 1 representing the best result.
  • The labels argument restricts which classes participate in the calculation.
  • In binary mode, the scalar represents recall for the selected positive class.
  • With average=None, the function returns one recall value for each included label.

Common mistakes

  • Do not expect pos_label to affect the result when using a non-binary averaging mode.
  • Sparse target matrices are valid only for multilabel targets.

Example: Compute binary recall

from sklearn.metrics import recall_score

y_true = [0, 1, 1, 0, 1]
y_pred = [0, 1, 0, 0, 1]

score = recall_score(y_true, y_pred)
print(score)  # 0.6666666666666666

This computes binary recall for the default positive label, 1.

When to use it

Measure detection of the positive class

Binary classification

Compare class-wise sensitivity with macro or weighted averaging

Multiclass evaluation

Aggregate or inspect recall across labels

Multilabel evaluation

Score predictions with per-sample weights

Model validation

Interview questions

QWhat does recall_score measure?

Recall is the ratio of true positives to true positives plus false negatives. It measures how effectively a classifier finds positive samples.

Follow-up: How can recall be computed for multiclass data? Use a non-binary average such as macro, weighted, micro, or return one value per label with average=None.

QWhat are the defaults for binary classification?

The default binary mode returns recall for the positive class, whose label is controlled by pos_label. Its default value is 1.

Follow-up: What happens if average is macro? Recall is calculated for each label and then averaged without weighting by class support.

QWhat does recall_score return?

The return value is a float when average is not None and an array when average=None. The array contains recall values for the relevant unique labels.

Follow-up: How can selected labels be evaluated? Pass labels to specify the label set used for the calculation.

  • precision_score
  • f1_score
  • precision_recall_fscore_support
  • classification_report

Source: recall_score — scikit-learn 1.9.1 documentation. Checked 2026-10-15.