public static <T extends Classifiable<T>> double accuracy(MetricTarget<T> target, ConfusionMatrix<T> cm) {
        if (target.getOutputTarget().isPresent()) {
            return accuracy(target.getOutputTarget().get(), cm);
        } else {
            return accuracy(target.getAverageTarget().get(), cm);
        }
    }
@Test
    public void testAccuracy() {
        List<Prediction<Label>> predictions = Arrays.asList(
                mkPrediction("a", "a"),
                mkPrediction("c", "b"),
                mkPrediction("b", "b"),
                mkPrediction("b", "c")
        );
        ImmutableOutputInfo<Label> domain = mkDomain(predictions);
        LabelConfusionMatrix cm = new LabelConfusionMatrix(domain, predictions);

        assertEquals(1d, ConfusionMetrics.accuracy(label("a"), cm));
        assertEquals(0.5, ConfusionMetrics.accuracy(label("b"), cm));

        assertEquals(0d, cm.tp(label("c")));
        assertEquals(0d, ConfusionMetrics.accuracy(label("c"), cm));

        assertEquals(0.5, ConfusionMetrics.accuracy(Average.MICRO, cm));
        assertEquals(0.5, ConfusionMetrics.accuracy(Average.MACRO, cm));
    }