public static ClusteringSolution CreateACOClusters_MB(int seed, Dataset dataset, int clustersNumber, ISimilarityMeasure similarityMeasure, int maxIterations, int colonySize, int convergenceIterations, bool fireEvents, bool performLocalSearch) { DataMining.Utilities.RandomUtility.Initialize(seed); DefaultHeuristicCalculator <int> calculator = new DefaultHeuristicCalculator <int>(); ClusteringMBInvalidator invalidator = new ClusteringMBInvalidator(); DataMining.ProximityMeasures.IClusteringQualityMeasure measure = new CohesionClusteringMeasure(); ClusteringQualityEvaluator cohesionEvaluator = new ClusteringQualityEvaluator(measure); KMeansLocalSearch localSearch = new KMeansLocalSearch(dataset, 1, similarityMeasure, cohesionEvaluator); ACO.ProblemSpecifics.ISolutionQualityEvaluator <int> evaluator = new ClusteringQualityEvaluator(measure); Problem <int> problem = new Problem <int>(invalidator, calculator, evaluator, localSearch); ACOClustering_MB antClustering = new ACOClustering_MB(maxIterations, colonySize, convergenceIterations, problem, clustersNumber, similarityMeasure, dataset, performLocalSearch); antClustering.OnPostColonyIteration += new EventHandler(antClustering_OnPostColonyIteration); return(antClustering.CreateClusters()); }
public static void TestACOCluster_MBThenBMN() { 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.ClassificationMeasures.IClassificationQualityMeasure accuracy = new DataMining.ClassificationMeasures.AccuracyMeasure(); DataMining.Algorithms.IClassificationAlgorithm naive = new NaiveBayesAlgorithm(); DefaultHeuristicCalculator <int> calculator = new DefaultHeuristicCalculator <int>(); ClusteringMBInvalidator invalidator = new ClusteringMBInvalidator(); DataMining.ProximityMeasures.IClusteringQualityMeasure measure = new CohesionClusteringMeasure(); ClusteringQualityEvaluator cohesionEvaluator = new ClusteringQualityEvaluator(measure); KMeansLocalSearch localSearch = new KMeansLocalSearch(trainingSet, 1, similarityMeasure, cohesionEvaluator); ACO.ProblemSpecifics.ISolutionQualityEvaluator <int> evaluator = new ClusteringQualityEvaluator(measure); Problem <int> problem = new Problem <int>(invalidator, calculator, evaluator, localSearch); DataMining.Algorithms.IClusteringAlgorithm AntClustering = new ACOClustering_MB(1000, 10, 10, problem, 6, similarityMeasure, true); DataMining.Model.IClassifier cBMNClassifier = SingleTest.CreateClusteringBMNClassifier(seed, 6, 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"); }