Esempio n. 1
0
        public void ReadCategorizedButDontWriteResults()
        {
            var runDir        = AppDomain.CurrentDomain.BaseDirectory;
            var inputDataFile = Path.Combine(runDir, "Data/N1024_D128_K16.txt");

            Console.WriteLine($"Looking for datafile here: {inputDataFile}");
            // Largest value < 256
            var bitsPerDimension = 10;
            var config           = new SlashConfig()
            {
                AcceptableBCubed = 0.98
            };

            config.Index.BitsPerDimension = bitsPerDimension;
            config.Data = new SlashConfig.DataConfig()
            {
                InputDataFile = inputDataFile,
                IdField       = "id",
                CategoryField = "category",
                ReadHeader    = true
            };
            config.DensityClassifier.SkipDensityClassification = true;
            config.Output.OutputDataFile = null;
            var command = new SlashCommand(SlashCommand.CommandType.Cluster, config)
            {
                OutputFile = null
            };

            // Need to put this here, because the command initializes the logger differently.
            Logger.SetupForTests(null);
            command.Execute();

            Assert.IsTrue(command.IsClassificationAcceptable, $"The BCubed value of {command.MeasuredChange.BCubed} was not good enough.");
        }
Esempio n. 2
0
        public void AssessCommand()
        {
            var runDir        = AppDomain.CurrentDomain.BaseDirectory;
            var inputDataFile = Path.Combine(runDir, "Data/N1024_D128_K16.txt");

            Console.WriteLine($"Looking for datafile here: {inputDataFile}");
            // Largest value < 256
            var bitsPerDimension = 10;
            var config           = new SlashConfig()
            {
                AcceptableBCubed = 0.98
            };

            config.Index.BitsPerDimension = bitsPerDimension;
            config.Data = new SlashConfig.DataConfig()
            {
                InputDataFile = inputDataFile,
                IdField       = "id",
                CategoryField = "category",
                ReadHeader    = true
            };
            config.DensityClassifier.SkipDensityClassification = true;
            config.Output.OutputDataFile = null;
            var command = new SlashCommand(SlashCommand.CommandType.Assess, config)
            {
                OutputFile = null
            };

            // Need to put this here, because the command initializes the logger differently.
            Logger.SetupForTests(null);
            command.Execute();
            var assessment = command.Assessor.HowClustered;

            Assert.AreEqual(ClusteringTendency.ClusteringQuality.HighlyClustered, assessment, $"Expected HighlyClustered, got {command.Assessor}");
        }
Esempio n. 3
0
        public void ClusterWithoutFiles()
        {
            var bitsPerDimension = 10;
            var data             = new GaussianClustering
            {
                ClusterCount   = 20,
                Dimensions     = 50,
                MaxCoordinate  = (1 << bitsPerDimension) - 1,
                MinClusterSize = 200,
                MaxClusterSize = 600
            };
            var expectedClassification = data.MakeClusters();

            var config = new SlashConfig()
            {
                AcceptableBCubed = 0.98
            };

            config.Index.BitsPerDimension = bitsPerDimension;
            config.UseNoFiles();
            var command = new SlashCommand(SlashCommand.CommandType.Cluster, config)
            {
                InputFile  = null,
                OutputFile = null
            };

            command.Configuration.DensityClassifier.SkipDensityClassification = true;
            // Need to put this here, because the command initializes the logger differently.
            Logger.SetupForTests(null);
            command.LoadData(expectedClassification);

            command.Execute();

            Assert.IsTrue(command.IsClassificationAcceptable, $"The BCubed value of {command.MeasuredChange.BCubed} was not good enough.");
        }