recall function
Recall metric for binary classification (positive = 1).
Implementation
double recall(List<int> yTrue, List<int> yPred, {int positiveLabel = 1}) {
if (yTrue.length != yPred.length) {
throw ArgumentError('Lengths of true and predicted labels must match.');
}
int tp = 0, fn = 0;
for (int i = 0; i < yTrue.length; i++) {
if (yTrue[i] == positiveLabel) {
if (yPred[i] == positiveLabel) tp++;
else fn++;
}
}
final denominator = tp + fn;
return denominator == 0 ? 0.0 : tp / denominator;
}