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

    MacroBaseConf conf = new MacroBaseConf()
            .set(MacroBaseConf.RANDOM_SEED, 4)
            .set(MacroBaseConf.TRANSFORM_TYPE, "MEAN_FIELD_GMM")
            .set(GMMConf.NUM_MIXTURES, 4)
            .set(MacroBaseConf.DATA_LOADER_TYPE, "CSV_LOADER")
            .set(MacroBaseConf.CSV_COMPRESSION, CSVIngester.Compression.GZIP)
            .set(MacroBaseConf.CSV_INPUT_FILE, "src/test/resources/data/2gaussians-500points.csv.gz")
            .set(MacroBaseConf.METRICS, "XX, YY")
            .set(MacroBaseConf.ATTRIBUTES, "");
    List<Datum> data = Drainer.drainIngest(conf);
    assertEquals(500, data.size());
    FiniteGMM finiteGMM = new FiniteGMM(conf);
    List<RealVector> calculatedMeans = null;
    double[] calculatedWeights = null;
    int numClustersIdentified = 0;
    // Sometimes there is a weird convergence into one cluster when trying to fit more than 2 clusters.
    while (numClustersIdentified < 2) {
        finiteGMM.train(data);
        calculatedMeans = finiteGMM.getClusterCenters();
        calculatedWeights = finiteGMM.getPriorAdjustedClusterProportions();
        numClustersIdentified = 0;
        for (double weight : calculatedWeights) {
            if (weight > 0.1) {
                numClustersIdentified += 1;
            }
        }
    }
    double[][] clusterMeans = {
            {1, 1},
            {10, 3},
    };
    List<RealVector> vectorClusterMeans = new ArrayList<>(2);
    for (int k = 0; k < 2; k++) {
        vectorClusterMeans.add(new ArrayRealVector(clusterMeans[k]));
    }
    double[] clusterWeights = {
            200,
            300,
    };
    double[] identifiedWeights = {0, 0};
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 2; j++) {
            if (calculatedMeans.get(i).getDistance(vectorClusterMeans.get(j)) < 1) {
                identifiedWeights[j] += calculatedWeights[i];
                log.debug("adding {} to cluster {}", calculatedWeights[i], vectorClusterMeans.get(j));
                break;
            }
        }
    }
    assertEquals(identifiedWeights[0] * 500, clusterWeights[0], 1);
    assertEquals(identifiedWeights[1] * 500, clusterWeights[1], 1);
}