Ejemplo n.º 1
0
        public void Initialize_Clusters()
        {
            var x = new double[10][];

            for (int i = 0; i < x.Length; i++)
            {
                x[i] = new double[5];
            }
            ClusterData             d       = new ClusterData(x, new string[] { "a1", "a2", "a3", "a4", "a5" });
            ClusterAlgorithmOptions options = new ClusterAlgorithmOptions(3, 123, true, 10);
            //should provide initialized mean values and assignment

            ClusterResult r = KmeansClusterAlgorithm.InitializeClusters(d, options);

            int[] count = new int[3];
            for (int i = 0; i < d.RawData.Length; i++)
            {
                int idx = r.ClusterAssignment[i];
                count[idx] += 1;
            }
            for (int i = 0; i < options.NumberOfClusters; i++)
            {
                //check if every cluster received at least one data point
                Assert.IsTrue(count[i] > 0);
                //check if the column mean values are initialized
                Assert.IsTrue(r.ClusterMeanValues[i].Length == d.RawData[0].Length);
            }
        }