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 TestLBMNABC()
        {
            Console.WriteLine("Start");

            string dsname = "car";

            string trainingSetPath = @"C:\0 - Khalid\Academics\Datasets\" + dsname + @"\TR0_" + dsname + ".arff";
            string testingSetPath  = @"C:\0 - Khalid\Academics\Datasets\" + dsname + @"\TS0_" + dsname + ".arff";

            Dataset trainingSet = ArffHelper.LoadDatasetFromArff(trainingSetPath);
            Dataset testingSet  = ArffHelper.LoadDatasetFromArff(testingSetPath);

            DataMining.ClassificationMeasures.AccuracyMeasure qualityEvaluator = new DataMining.ClassificationMeasures.AccuracyMeasure();
            ISolutionQualityEvaluator <Edge> trainingQualityEvaluator          = new likelihoodQualityEvaluator(trainingSet);

            IHeuristicValueCalculator <Edge> calculator = new MICalculator();
            int seed = (int)DateTime.Now.Ticks;
            BayesianMultinetClassifier lmnabclassifier = SingleTest.CreateLMNAntBayesianClassification(seed, 10, 5, 10, 3, trainingSet, trainingQualityEvaluator, calculator, true);
            double quality = SingleTest.TestClassifier(lmnabclassifier, testingSet, qualityEvaluator);

            quality = Math.Round(quality * 100, 2);

            Console.WriteLine("LMNABC Quality: " + quality.ToString());
            Console.WriteLine("End");

            //Console.ReadLine();
        }
Exemple #3
0
        public static void TestNaive()
        {
            Console.WriteLine("Start");

            Dataset trainingSet = ArffHelper.LoadDatasetFromArff(datasetFilePath);
            Dataset testingSet  = ArffHelper.LoadDatasetFromArff(datasetFilePath);

            DataMining.ClassificationMeasures.IClassificationQualityMeasure qualityEvaluator = new DataMining.ClassificationMeasures.AccuracyMeasure();

            BayesianNetworkClassifier naive = SingleTest.CreateNaiveBayesianClassifier(trainingSet);
            double quality = SingleTest.TestClassifier(naive, testingSet, qualityEvaluator);

            quality = Math.Round(quality * 100, 2);
            Console.WriteLine("Naive Quality: " + quality.ToString());
            Console.WriteLine("End");
        }
Exemple #4
0
        public static void TestANTClustBMN_IB()
        {
            int seed = (int)DateTime.Now.Ticks;

            Console.WriteLine("Start");

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

            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.Model.IClassifier cBMNClassifier          = SingleTest.CreateAntClustBMNClassifier_IB(seed, trainingSet, 1, 1, 10, 3, similarityMeasure, accuracy, naive, true);
            double quality = SingleTest.TestClassifier(cBMNClassifier, testingSet, accuracy);

            Console.WriteLine("Quality: " + quality.ToString());
        }
Exemple #5
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");
        }