class Accuracy implements Metric<L> {

    @Override public double score(Iterator<LabelPair<L>> iter) {
        long totalCnt = 0;
        long correctCnt = 0;

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

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

            if (prediction.equals(truth))
                correctCnt++;

            totalCnt++;
        }

        return 1.0 * correctCnt / totalCnt;
    }

}