@Test
/**
 * Tests Gaussian Mixture Model on a three not so well separated clusters.
 */
public void bivariateOkSeparatedNormalTest() throws Exception {

    MacroBaseConf conf = new MacroBaseConf()
            .set(MacroBaseConf.RANDOM_SEED, 4)
            .set(MacroBaseConf.TRANSFORM_TYPE, "VARIATIONAL_DPMM")
            .set(GMMConf.MAX_ITERATIONS_TO_CONVERGE, 15)
            .set(GMMConf.DPM_TRUNCATING_PARAMETER, 20)
            .set(GMMConf.DPM_CONCENTRATION_PARAMETER, 0.1)
            .set(GMMConf.NUM_MIXTURES, 3)
            .set(MacroBaseConf.DATA_LOADER_TYPE, "CSV_LOADER")
            .set(MacroBaseConf.CSV_COMPRESSION, CSVIngester.Compression.GZIP)
            .set(MacroBaseConf.CSV_INPUT_FILE, "src/test/resources/data/3gaussians-7000points.csv.gz")
            .set(MacroBaseConf.METRICS, "XX, YY")
            .set(MacroBaseConf.ATTRIBUTES, "");
    List<Datum> data = conf.constructIngester().getStream().drain();
    assertEquals(7000, data.size());
    double[][] clusterMeans = {
            {1.5, 2},
            {2, 0},
            {4.5, 1},
    };
    List<RealVector> vectorClusterMeans = new ArrayList<>(3);
    for (int k = 0; k < 3; k++) {
        vectorClusterMeans.add(new ArrayRealVector(clusterMeans[k]));
    }
    double[][][] clusterCovariances = {
            {{0.5, 0.4}, {0.4, 0.5}},
            {{0.3, 0}, {0, 0.6}},
            {{0.9, 0.2}, {0.2, 0.3}},
    };
    double[][] boundaries = {
            {0, 6.01},
            {-2, 4.01},
    };
    DPGMM variationalDPGM = new DPGMM(conf);
    variationalDPGM.train(data);
    JsonUtils.dumpAsJson(variationalDPGM.getClusterCovariances(), "DPGMMTest-bivariateOkSeparatedNormalTest-covariances.json");
    JsonUtils.dumpAsJson(variationalDPGM.getClusterCenters(), "DPGMMTest-bivariateOkSeparatedNormalTest-means.json");
    JsonUtils.dumpAsJson(variationalDPGM.getClusterProportions(), "DPGMMTest-bivariateOkSeparatedNormalTest-weights.json");
    conf.set(GMMConf.SCORE_DUMP_FILE_CONFIG_PARAM, "3gaussians-7k-grid.json");
    ScoreDumper dumper = new ScoreDumper(conf);
    dumper.dumpScores(variationalDPGM, boundaries, 0.05);
    conf.set(GMMConf.SCORE_DUMP_FILE_CONFIG_PARAM, "3gaussians-7k-data.json");
    dumper = new ScoreDumper(conf);
    dumper.dumpScores(variationalDPGM, data);
}