package io.sigpipe.sing.dataset;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.sigpipe.sing.dataset.feature.Feature;
import io.sigpipe.sing.stat.RunningStatistics;

public class TickEvaluator {

    private Quantizer quantizer;
    private Map<Feature, RunningStatistics> statMap = new HashMap<>();

    public TickEvaluator(Quantizer quantizer) {
        this.quantizer = quantizer;
    }

    public void train(List<Feature> features) {
        for (Feature feature : features) {
            Feature q = quantizer.quantize(feature);
            RunningStatistics rs = statMap.get(q);
            if (rs == null) {
                rs = new RunningStatistics();
                statMap.put(q, rs);
            }
            rs.put(feature.getDouble());
        }
    }

    public void evaluate(List<Feature> features) {

    }
}

@@ -27,16 +27,65 @@
 taset;%0A%0A
+import java.io.File;%0Aimport java.util.ArrayList;%0A
 import j
@@ -148,16 +148,62 @@
 l.Map;%0A%0A
+import io.sigpipe.sing.adapters.ReadMetadata;%0A
 import i
@@ -288,16 +288,105 @@
 tistics;
+%0Aimport io.sigpipe.sing.stat.SquaredError;%0Aimport io.sigpipe.sing.util.TestConfiguration;
 %0A%0Apublic
@@ -1035,16 +1035,1010 @@
 ures) %7B%0A
+        RunningStatistics allStats = new RunningStatistics();%0A%0A        Map%3CFeature, SquaredError%3E errors = new HashMap%3C%3E();%0A        for (Feature feature : features) %7B%0A            allStats.put(feature.getDouble());%0A%0A            Feature q = quantizer.quantize(feature);%0A            RunningStatistics rs = statMap.get(q);%0A            double mean = rs.mean();%0A            double actual = feature.getDouble();%0A            SquaredError se = errors.get(q);%0A            if (se == null) %7B%0A                se = new SquaredError();%0A                errors.put(q, se);%0A            %7D%0A            se.put(actual, mean);%0A        %7D%0A%0A        for (Feature q : errors.keySet()) %7B%0A            SquaredError se = errors.get(q);%0A            double nrmse = se.RMSE() / (allStats.max() - allStats.min());%0A            double cvrmse = se.RMSE() / allStats.mean();%0A            System.out.println(q + %22%5Ct%22 + se.RMSE() + %22%5Ct%22 + nrmse%0A                    + %22%5Ct%22 + cvrmse);%0A        %7D%0A%0A        System.out.println(allStats);%0A    %7D
 %0A    %7D%0A%7D

Implement evaluation routine