class Recall extends ClassMetric<L> {

    @Override public double score(Iterator<LabelPair<L>> it) {
        if (clsLb != null) {
            long tp = 0;
            long fn = 0;

            while (it.hasNext()) {
                LabelPair<L> e = it.next();

                L prediction = e.getPrediction();
                L truth = e.getTruth();

                if (clsLb.equals(truth)) {
                    if (prediction.equals(truth))
                        tp++;
                    else
                        fn++;
                }
            }
            long denominator = tp + fn;

            if (denominator == 0)
                return 1; // according to https://github.com/dice-group/gerbil/wiki/Precision,-Recall-and-F1-measure

            return (double)tp / denominator;
        }
        else
            return Double.NaN;
    }

    public  Recall(L clsLb);

}