public static void RunACOIBL_WeightOutputs() { AccuracyMeasure accuracyMeasure = new AccuracyMeasure(); foreach (string dataset in GetDatasetFolds("datasets.txt")) { //---------------------------------------- Console.WriteLine("Data Table:" + dataset); //---------------------------------------- #region ACO-KNN-CB //try { for (_currentFold = 0; _currentFold < _folds; _currentFold++) { //---------------------------------------- Console.WriteLine("Fold:" + _currentFold.ToString()); //---------------------------------------- DataMining.Data.Dataset[] tables = LoadTrainingAndTestingData(dataset, _currentFold); DataMining.Data.Dataset trainingSet = tables[0]; DataMining.Data.Dataset testingSet = tables[1]; KNearestNeighbours knnclassifier = SingleTest.CreateKNNAntIBMinerClassifier_ClassBasedWeights(trainingSet, false); //------------------------------------------------------------------ Console.WriteLine("ACO-KNN-CB: " + dataset); SaveWeights(trainingSet, knnclassifier); } Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } //catch (Exception ex) { //LogError(ex); // Console.WriteLine(ex.Message); } #endregion } }
public static void RunACOIBL() { int k = 9; AccuracyMeasure accuracyMeasure = new AccuracyMeasure(); foreach (string dataset in GetDatasetFolds("datasets.txt")) { //---------------------------------------- Console.WriteLine("Data Table:" + dataset); //---------------------------------------- for (_currentFold = 0; _currentFold < _folds; _currentFold++) { //---------------------------------------- //Console.WriteLine("Fold:" + _currentFold.ToString()); //---------------------------------------- DataMining.Data.Dataset[] tables = LoadTrainingAndTestingData(dataset, _currentFold); DataMining.Data.Dataset trainingSet = tables[0]; DataMining.Data.Dataset testingSet = tables[1]; Dataset datasetFull = Dataset.Merge(trainingSet, testingSet); double quality = 0; try { { KNearestNeighbours knn = SingleTest.CreateKNNClassifier(k, datasetFull, false); quality = SingleTest.TestClassifier(knn, datasetFull, accuracyMeasure); quality = Math.Round(quality * 100, 2); //------------------------------------------------------------------ Console.WriteLine("KNN: " + dataset + " - Accuracy=" + quality); SaveResults(dataset, "KNN", k.ToString(), quality.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } { KNearestNeighbours knnWV = SingleTest.CreateKNNClassifier(k, datasetFull, true); quality = SingleTest.TestClassifier(knnWV, datasetFull, accuracyMeasure); quality = Math.Round(quality * 100, 2); //------------------------------------------------------------------ Console.WriteLine("KNN-WV: " + dataset + " - Accuracy=" + quality); SaveResults(dataset, "KNN-WV", k.ToString(), quality.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } { NearestClassClassifier ncc = SingleTest.CreateNCClassifier(datasetFull); quality = SingleTest.TestClassifier(ncc, datasetFull, accuracyMeasure); quality = Math.Round(quality * 100, 2); //------------------------------------------------------------------ Console.WriteLine("NNC: " + dataset + " - Accuracy=" + quality); SaveResults(dataset, "NNC", quality.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } { KNearestNeighbours knn = SingleTest.CreateKNNAntIBMinerClassifier(k, datasetFull, false); quality = SingleTest.TestClassifier(knn, datasetFull, accuracyMeasure); quality = Math.Round(quality * 100, 2); //------------------------------------------------------------------ Console.WriteLine("ACO-KNN: " + dataset + " - Accuracy=" + quality); SaveResults(dataset, "ACO-KNN", k.ToString(), quality.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } { KNearestNeighbours knn = SingleTest.CreateKNNAntIBMinerClassifier(k, datasetFull, true); quality = SingleTest.TestClassifier(knn, datasetFull, accuracyMeasure); quality = Math.Round(quality * 100, 2); //------------------------------------------------------------------ Console.WriteLine("ACO-KNN-WV: " + dataset + " - Accuracy=" + quality); SaveResults(dataset, "ACO-KNN-WV", k.ToString(), quality.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } { KNearestNeighbours knn = SingleTest.CreateKNNAntIBMinerClassifier_ClassBasedWeights(k, datasetFull, false); quality = SingleTest.TestClassifier(knn, datasetFull, accuracyMeasure); quality = Math.Round(quality * 100, 2); //------------------------------------------------------------------ Console.WriteLine("ACO-KNN-CB: " + dataset + " - Accuracy=" + quality); SaveResults(dataset, "ACO-KNN-CB", k.ToString(), quality.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } { KNearestNeighbours knn = SingleTest.CreateKNNAntIBMinerClassifier_ClassBasedWeights(k, datasetFull, true); quality = SingleTest.TestClassifier(knn, datasetFull, accuracyMeasure); quality = Math.Round(quality * 100, 2); //------------------------------------------------------------------ Console.WriteLine("ACO-KNN-CB-WV: " + dataset + " - Accuracy=" + quality); SaveResults(dataset, "ACO-KNN-CB-WV", k.ToString(), quality.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } { NearestClassClassifier ncc = SingleTest.CreateNCCAntIBMinerClassifier(datasetFull); quality = SingleTest.TestClassifier(ncc, datasetFull, accuracyMeasure); quality = Math.Round(quality * 100, 2); //------------------------------------------------------------------ Console.WriteLine("ACO-NCC: " + dataset + " - Accuracy=" + quality); SaveResults(dataset, "ACO-NCC", quality.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } { NearestClassClassifier ncc = SingleTest.CreateNCCAntIBMinerClassifier_ClassBasedWeights(datasetFull); quality = SingleTest.TestClassifier(ncc, datasetFull, accuracyMeasure); quality = Math.Round(quality * 100, 2); //------------------------------------------------------------------ Console.WriteLine("ACO-NCC-CB: " + dataset + " - Accuracy=" + quality); SaveResults(dataset, "ACO-NCC-CB", quality.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } { GaussianKernelEstimator GKC = SingleTest.CreateGKAntIBMinerClassifier(datasetFull); quality = SingleTest.TestClassifier(GKC, datasetFull, accuracyMeasure); quality = Math.Round(quality * 100, 2); //------------------------------------------------------------------ Console.WriteLine("ACO-GKC: " + dataset + " - Accuracy=" + quality); SaveResults(dataset, "ACO-GKC", quality.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } { GaussianKernelEstimator GKC = SingleTest.CreateGKAntIBMinerClassifier_ClassBaseWeights(datasetFull); quality = SingleTest.TestClassifier(GKC, datasetFull, accuracyMeasure); quality = Math.Round(quality * 100, 2); //------------------------------------------------------------------ Console.WriteLine("ACO-GKC-CB: " + dataset + " - Accuracy=" + quality); SaveResults(dataset, "ACO-GKC-CB", quality.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } } catch (Exception ex) { LogError(ex); // Console.WriteLine(ex.Message); } } } }