Exemple #1
0
        public static void TestKmeanClusteringBMN()
        {
            int seed = (int)DateTime.Now.Ticks;

            Console.WriteLine("Start");

            string  datasetFile = folderPath + "\\" + datasetName + ".arff";
            Dataset trainingSet = ArffHelper.LoadDatasetFromArff(datasetFile);
            Dataset testingSet  = ArffHelper.LoadDatasetFromArff(datasetFile);

            double avgQualiy = 0;

            int k = 8;

            for (int i = 0; i < 10; i++)
            {
                DataMining.ProximityMeasures.ISimilarityMeasure similarityMeasure = new DataMining.ProximityMeasures.ClassBasedSimilarityMeasure(trainingSet);
                //DataMining.ProximityMeasures.ISimilarityMeasure similarityMeasure = new DataMining.ProximityMeasures.BinaryMatchingSimilarityMeasure();
                DataMining.ClassificationMeasures.IClassificationQualityMeasure accuracy = new DataMining.ClassificationMeasures.AccuracyMeasure();
                DataMining.Algorithms.IClassificationAlgorithm naive  = new NaiveBayesAlgorithm();
                DataMining.Algorithms.IClusteringAlgorithm     kmeans = new DataMining.Algorithms.KMeans(trainingSet, k, similarityMeasure, 100, true);
                DataMining.Model.IClassifier cBMNClassifier           = SingleTest.CreateClusteringBMNClassifier(seed, k, trainingSet, similarityMeasure, accuracy, kmeans, naive, false);
                double quality = SingleTest.TestClassifier(cBMNClassifier, testingSet, accuracy);
                Console.WriteLine("Quality: " + quality.ToString());
                avgQualiy += quality;
            }

            Console.WriteLine(avgQualiy / 10);
            Console.WriteLine("End");
        }
Exemple #2
0
        public static void TestACOCluster_IBThenBMN()
        {
            int seed = (int)DateTime.Now.Ticks;

            Console.WriteLine("Start");

            string  datasetFile = folderPath + "\\" + datasetName + ".arff";
            Dataset trainingSet = ArffHelper.LoadDatasetFromArff(datasetFile);
            Dataset testingSet  = ArffHelper.LoadDatasetFromArff(datasetFile);

            double avgQualiy = 0;

            for (int i = 0; i < 1; i++)
            {
                DataMining.ProximityMeasures.ISimilarityMeasure similarityMeasure = new DataMining.ProximityMeasures.ClassBasedSimilarityMeasure(trainingSet);
                //DataMining.ProximityMeasures.ISimilarityMeasure similarityMeasure = new DataMining.ProximityMeasures.BinaryMatchingSimilarityMeasure();
                DataMining.ClassificationMeasures.IClassificationQualityMeasure accuracy = new DataMining.ClassificationMeasures.AccuracyMeasure();
                DataMining.Algorithms.IClassificationAlgorithm naive = new NaiveBayesAlgorithm();

                DefaultHeuristicCalculator <ClusterExampleAssignment> calculator = new DefaultHeuristicCalculator <ClusterExampleAssignment>();
                ClusteringIBInvalidator invalidator = new ClusteringIBInvalidator();
                DataMining.ProximityMeasures.IClusteringQualityMeasure measure = new CohesionClusteringMeasure();
                ClusteringQualityEvaluator cohesionEvaluator = new ClusteringQualityEvaluator(measure);
                KMeansLocalSearch          localSearch       = new KMeansLocalSearch(trainingSet, 1, similarityMeasure, cohesionEvaluator);
                ACO.ProblemSpecifics.ISolutionQualityEvaluator <DataMining.Model.ClusterExampleAssignment> evaluator = new ClusteringQualityEvaluator(measure);
                Problem <DataMining.Model.ClusterExampleAssignment> problem = new Problem <DataMining.Model.ClusterExampleAssignment>(invalidator, calculator, evaluator, localSearch);

                DataMining.Algorithms.IClusteringAlgorithm AntClustering = new ACOClustering_IB(1000, 10, 10, problem, 10, similarityMeasure, true);
                DataMining.Model.IClassifier cBMNClassifier = SingleTest.CreateClusteringBMNClassifier(seed, 10, trainingSet, similarityMeasure, accuracy, AntClustering, naive, true);
                double quality = SingleTest.TestClassifier(cBMNClassifier, testingSet, accuracy);
                Console.WriteLine("Quality: " + quality.ToString());
                avgQualiy += quality;
            }

            Console.WriteLine(avgQualiy / 10);
            Console.WriteLine("End");
        }