ChoquisticRelevanceLoss extends AMultiLabelClassificationMeasure { @Override public double loss(final List<? extends int[]> expected, final List<? extends IMultiLabelClassification> predicted) { this.checkConsistency(expected, predicted); DescriptiveStatistics stats = new DescriptiveStatistics(); for (int i = 0; i < expected.size(); i++) { stats.addValue(this.instanceLoss(expected.get(i), predicted.get(i).getPrediction())); } return stats.getMean(); } ChoquisticRelevanceLoss(final IMassFunction measure);  ChoquisticRelevanceLoss(final double threshold, final IMassFunction measure); @Override double loss(final List<? extends int[]> expected, final List<? extends IMultiLabelClassification> predicted); @Override double score(final List<? extends int[]> expected, final List<? extends IMultiLabelClassification> predicted);  }
@Test public void testHammingOWALoss() { ChoquisticRelevanceLoss loss = new ChoquisticRelevanceLoss(new HammingMassFunction()); double owaLoss = loss.loss(Arrays.stream(EXPECTEDS).collect(Collectors.toList()), this.toClassifications(ACTUALS)); assertEquals("Hamming loss differs", EXPECTED_HAM, owaLoss, DELTA); }
@Test public void testSubsetZeroOneOWALoss() { ChoquisticRelevanceLoss loss = new ChoquisticRelevanceLoss(new SubsetZeroOneMassFunction()); double owaLoss = loss.loss(Arrays.stream(EXPECTEDS).collect(Collectors.toList()), this.toClassifications(ACTUALS)); assertEquals("Subset 0/1 loss differs", EXPECTED_S01, owaLoss, DELTA); }