示例#1
0
        private static void RunExample2()
        {
            int     numExpctedClusters = 7;
            int     numFeatures        = 100;
            int     samples            = 200;
            DataSet dataSet            = new DataSet(numExpctedClusters, numFeatures, samples, 2);
            popc    pop = new popc(dataSet);

            if (pop.clusters.Count != numExpctedClusters)
            {
                throw new Exception("theory not confirmed");
            }

            DisplayClusters(pop.clusters);
        }
示例#2
0
        private static void RunExample3()
        {
            // scenario 3
            int     numExpctedClusters = 7;
            int     numFeatures        = 20;
            int     samplesPerCluser   = 30;
            DataSet dataSet            = new DataSet(numExpctedClusters, numFeatures, samplesPerCluser, 3);
            popc    pop = new popc(dataSet);

            DisplayClusters(pop.clusters);

            //creates 7 clusters as expected
            if (pop.clusters.Count != numExpctedClusters)
            {
                throw new Exception("theory not confirmed");
            }

            // results close expected 7
            double vPOPC = popc.ComputeEval(pop.clusters, pop.countsAll);

            if (Math.Abs(vPOPC - numExpctedClusters) > 0.1)
            {
                throw new Exception("theory not confirmed");
            }

            // pretend we know correct number of clusters
            kmeans km = new kmeans(dataSet, pop.clusters.Count);

            DisplayClusters(km.clusters);
            // even with knowledge of amount of correct clusters
            // we get score close to 0 due to k-means clusters
            // concentrates on noisy features and does not find
            // ideal clusters, hence score close to 0
            double vKMEANS = popc.ComputeEval(km.clusters, pop.countsAll);

            if (Math.Abs(vKMEANS - 0.0) > 0.1)
            {
                throw new Exception("theory not confirmed");
            }
        }