@@ -0,0 +1,1369 @@
+package edu.neu.ccs.pyramid.eval;%0A%0Aimport edu.neu.ccs.pyramid.dataset.MultiLabel;%0Aimport edu.neu.ccs.pyramid.dataset.MultiLabelClfDataSet;%0Aimport edu.neu.ccs.pyramid.multilabel_classification.MultiLabelClassifier;%0A%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Set;%0Aimport java.util.stream.IntStream;%0A%0A/**%0A * (A and B)/(A or B)%0A * Created by chengli on 10/12/14.%0A */%0Apublic class Overlap %7B%0A%0A    public static double overlap(MultiLabelClassifier classifier, MultiLabelClfDataSet dataSet)%7B%0A        return overlap(dataSet.getMultiLabels(),classifier.predict(dataSet));%0A    %7D%0A%0A    public static double overlap(MultiLabel%5B%5D multiLabels, List%3CMultiLabel%3E predictions)%7B%0A        return IntStream.range(0,multiLabels.length).parallel()%0A                .mapToDouble(i -%3E overlap(multiLabels%5Bi%5D,predictions.get(i)))%0A                .average().getAsDouble();%0A    %7D%0A%0A%0A    private static double overlap(MultiLabel multiLabel1, MultiLabel multiLabel2)%7B%0A        Set%3CInteger%3E set1 = multiLabel1.getMatchedLabels();%0A        Set%3CInteger%3E set2 = multiLabel2.getMatchedLabels();%0A        Set%3CInteger%3E union = new HashSet%3C%3E();%0A        union.addAll(set1);%0A        union.addAll(set2);%0A        Set%3CInteger%3E itersection = new HashSet%3C%3E();%0A        itersection.addAll(set1);%0A        itersection.retainAll(set2);%0A        return ((double)itersection.size())/union.size();%0A    %7D%0A%7D%0A

add class Overlap