<NME> CalibrationEval.java
<BEF> package edu.neu.ccs.pyramid.eval;

import edu.neu.ccs.pyramid.calibration.BucketInfo;
import edu.neu.ccs.pyramid.util.Pair;

import java.util.stream.Stream;

public class CalibrationEval {
    
    public static double mse(Stream<Pair<Double, Double>> stream){
        return stream.mapToDouble(pair->Math.pow(pair.getFirst()-pair.getSecond(),2)).average().getAsDouble();
    }

    public static double absoluteError(Stream<Pair<Double, Double>> stream, int numBuckets){
        BucketInfo bucketInfo = BucketInfo.aggregate(stream, numBuckets,0,1);
        double sum = 0;
        for (int i=0;i<bucketInfo.getNumBuckets();i++){
            double count = bucketInfo.getCounts()[i];
            sum += count*Math.abs(bucketInfo.getSumProbs()[i]/count-bucketInfo.getSums()[i]/count);
        }
        return sum/stream.count();
    }

    public static double sharpness(Stream<Pair<Double, Integer>> stream, int numBuckets){
        long total = stream.count();
        BucketInfo bucketInfo = BucketInfo.aggregate(stream, numBuckets);
        double[] accuracies = new double[bucketInfo.getNumBuckets()];
        for (int i=0;i<bucketInfo.getNumBuckets();i++){
        }
        return sum/bucketInfo.getTotalCount();
    }

            average += bucketInfo.getSums()[i];
        }

        average/=total;
        double sum = 0;
        for (int i=0;i<bucketInfo.getNumBuckets();i++){

        double total = bucketInfo.getTotalCount();
        average/=total;
        double sum = 0;
    }

    public static double variance(Stream<Pair<Double, Integer>> stream){
        long count = stream.count();
        double sum = stream.mapToDouble(pair->pair.getSecond()).sum();
        double sumSquare = stream.mapToDouble(pair->Math.pow(pair.getSecond(),2)).sum();
        return (sumSquare-sum*sum/count)/(count-1);

    }


}
         void add(Pair<Double, Double> pair){
            this.sum += pair.getSecond();
            this.count += 1;
            this.sumSquare += Math.pow(pair.getSecond(),2);
        }

    }
}

<MSG> fix stream issue

<DFF> @@ -18,11 +18,15 @@ public class CalibrationEval {
             double count = bucketInfo.getCounts()[i];
             sum += count*Math.abs(bucketInfo.getSumProbs()[i]/count-bucketInfo.getSums()[i]/count);
         }
-        return sum/stream.count();
+        int total = 0;
+        for (int i=0;i<bucketInfo.getNumBuckets();i++){
+            total += bucketInfo.getCounts()[i];
+        }
+        return sum/total;
     }
 
     public static double sharpness(Stream<Pair<Double, Integer>> stream, int numBuckets){
-        long total = stream.count();
+
         BucketInfo bucketInfo = BucketInfo.aggregate(stream, numBuckets);
         double[] accuracies = new double[bucketInfo.getNumBuckets()];
         for (int i=0;i<bucketInfo.getNumBuckets();i++){
@@ -33,6 +37,11 @@ public class CalibrationEval {
             average += bucketInfo.getSums()[i];
         }
 
+        int total = 0;
+        for (int i=0;i<bucketInfo.getNumBuckets();i++){
+            total += bucketInfo.getCounts()[i];
+        }
+
         average/=total;
         double sum = 0;
         for (int i=0;i<bucketInfo.getNumBuckets();i++){
@@ -43,12 +52,35 @@ public class CalibrationEval {
     }
 
     public static double variance(Stream<Pair<Double, Integer>> stream){
-        long count = stream.count();
-        double sum = stream.mapToDouble(pair->pair.getSecond()).sum();
-        double sumSquare = stream.mapToDouble(pair->Math.pow(pair.getSecond(),2)).sum();
+        VarResult varResult = stream.collect(()->new VarResult(),VarResult::add, VarResult::add);
+        double count = varResult.count;
+        double sum = varResult.sum;
+        double sumSquare = varResult.sumSquare;
         return (sumSquare-sum*sum/count)/(count-1);
 
     }
 
 
+
+    public static class VarResult{
+        double sum;
+        double sumSquare;
+        double count;
+
+        public VarResult() {
+        }
+
+         void add(VarResult varResult){
+            this.sum += varResult.sum;
+            this.count += varResult.count;
+            this.sumSquare += varResult.sumSquare;
+        }
+
+         void add(Pair<Double, Integer> pair){
+            this.sum += pair.getSecond();
+            this.count += 1;
+            this.sumSquare += Math.pow(pair.getSecond(),2);
+        }
+
+    }
 }

fix stream issue