예제 #1
0
        private void ClassifyCase(Classification <UnsignedPoint, string> expectedClusters, double acceptableBCubed = 0.99)
        {
            var maxCoordinate    = expectedClusters.Points().Select(p => p.MaxCoordinate).Max();
            var bitsPerDimension = ((int)maxCoordinate).SmallestPowerOfTwo();
            var classifier       = new HilbertClassifier(expectedClusters.Points(), bitsPerDimension);

            classifier.IndexConfig.UseSample = true;

            var actualClusters = classifier.Classify();
            var comparison     = expectedClusters.Compare(actualClusters);

            var message = $"   Comparison of clusters: {comparison}.\n   Clusters expected/actual: {expectedClusters.NumPartitions}/{actualClusters.NumPartitions}.";

            Console.WriteLine(message);
            Console.WriteLine($"   Large clusters: {actualClusters.NumLargePartitions(classifier.OutlierSize)}");
            Assert.GreaterOrEqual(comparison.BCubed, acceptableBCubed, $"Clustering was not good enough. BCubed = {comparison.BCubed}");
        }