public static void RunPSOIBL() { AccuracyMeasure accuracyMeasure = new AccuracyMeasure(); IEnsembleClassificationStrategy majorityVote = new MajorityVoteStrategy(); IEnsembleClassificationStrategy weightedVote = new WeightedVoteStrategy(); foreach (string dataset in GetDatasetFolds(DatasetNamesFile)) { //---------------------------------------- Console.WriteLine("Data Table:" + dataset); //---------------------------------------- #region PSO-KNN-CB try { double quality1 = 0; //double quality2 = 0; double quality3 = 0; 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]; EnsembleClassifier ensemble = SingleTest.CreateKNNPSOIBMinerClassifier_ClassBasedWeights_Ensemble(trainingSet, false); quality1 += SingleTest.TestClassifier(ensemble[0], testingSet, accuracyMeasure); ensemble.Stratgy = majorityVote; //quality2 += SingleTest.TestClassifier(ensemble, testingSet, accuracyMeasure); ensemble.Stratgy = weightedVote; quality3 += SingleTest.TestClassifier(ensemble, testingSet, accuracyMeasure); } quality1 = Math.Round((quality1 / _folds) * 100, 2); // quality2 = Math.Round((quality2 / _folds) * 100, 2); quality3 = Math.Round((quality3 / _folds) * 100, 2); //------------------------------------------------------------------ Console.WriteLine("PSO-KNN-CB: " + dataset + " - Accuracy=" + quality1); SaveResults(dataset, "PSO-KNN-CB", quality1.ToString()); //Console.WriteLine("PSO-KNN-CB-ens-MV: " + dataset + " - Accuracy=" + quality2); //SaveResults(dataset, "PSO-KNN-CB-ens-MV",quality2.ToString()); Console.WriteLine("PSO-KNN-CB-ens-WV: " + dataset + " - Accuracy=" + quality3); SaveResults(dataset, "PSO-KNN-CB-ens-WV", quality3.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } catch (Exception ex) { // LogError(ex); // Console.WriteLine(ex.Message); } #endregion #region PSO-KNN-CB-WV //try //{ // double quality1 = 0; // double quality2 = 0; // double quality3 = 0; // 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]; // EnsembleClassifier ensemble = SingleTest.CreateKNNPSOIBMinerClassifier_ClassBasedWeights_Ensemble(trainingSet, true); // quality1 += SingleTest.TestClassifier(ensemble[0], testingSet, accuracyMeasure); // ensemble.Stratgy = majorityVote; // quality2 += SingleTest.TestClassifier(ensemble, testingSet, accuracyMeasure); // ensemble.Stratgy = weightedVote; // quality3 += SingleTest.TestClassifier(ensemble, testingSet, accuracyMeasure); // } // quality1 = Math.Round((quality1 / _folds) * 100, 2); // quality2 = Math.Round((quality2 / _folds) * 100, 2); // quality3 = Math.Round((quality3 / _folds) * 100, 2); // //------------------------------------------------------------------ // Console.WriteLine("PSO-KNN-CB-WV: " + dataset + " - Accuracy=" + quality1); // SaveResults(dataset, "PSO-KNN-CB-WV", k.ToString(), quality1.ToString()); // Console.WriteLine("PSO-KNN-CB-WV-ens-MV: " + dataset + " - Accuracy=" + quality2); // SaveResults(dataset, "PSO-KNN-CB-WV-ens-MV", k.ToString(), quality2.ToString()); // Console.WriteLine("PSO-KNN-CB-WV-ens-WV: " + dataset + " - Accuracy=" + quality3); // SaveResults(dataset, "PSO-KNN-CB-WV-ens-WV", k.ToString(), quality3.ToString()); // Console.WriteLine("-------------------------------------------"); // Console.WriteLine("-------------------------------------------"); // Console.WriteLine("-------------------------------------------"); //} //catch (Exception ex) //{ // LogError(ex); // // Console.WriteLine(ex.Message); //} #endregion #region PSO-NCC-CB try { double quality1 = 0; //double quality2 = 0; double quality3 = 0; 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]; EnsembleClassifier ensemble = SingleTest.CreateNCCPSOIBMinerClassifier_ClassBasedWeights_Ensemble(trainingSet); quality1 += SingleTest.TestClassifier(ensemble[0], testingSet, accuracyMeasure); //ensemble.Stratgy = majorityVote; //quality2 += SingleTest.TestClassifier(ensemble, testingSet, accuracyMeasure); ensemble.Stratgy = weightedVote; quality3 += SingleTest.TestClassifier(ensemble, testingSet, accuracyMeasure); } quality1 = Math.Round((quality1 / _folds) * 100, 2); //quality2 = Math.Round((quality2 / _folds) * 100, 2); quality3 = Math.Round((quality3 / _folds) * 100, 2); //------------------------------------------------------------------ Console.WriteLine("PSO-NCC-CB: " + dataset + " - Accuracy=" + quality1); SaveResults(dataset, "PSO-NNC-CB", quality1.ToString()); //Console.WriteLine("PSO-NNC-CB-ens-MV: " + dataset + " - Accuracy=" + quality2); //SaveResults(dataset, "PSO-NNC-CB-ens-MV", quality2.ToString()); Console.WriteLine("PSO-NNC-CB-ens-WV: " + dataset + " - Accuracy=" + quality3); SaveResults(dataset, "PSO-NNC-CB-ens-WV", quality3.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } catch (Exception ex) { LogError(ex); // Console.WriteLine(ex.Message); } #endregion #region PSO-GKC-CB try { double quality1 = 0; //double quality2 = 0; double quality3 = 0; 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]; EnsembleClassifier ensemble = SingleTest.CreateGKPSOIBMinerClassifier_ClassBaseWeights_Ensemble(trainingSet); quality1 += SingleTest.TestClassifier(ensemble[0], testingSet, accuracyMeasure); //ensemble.Stratgy = majorityVote; //quality2 += SingleTest.TestClassifier(ensemble, testingSet, accuracyMeasure); ensemble.Stratgy = weightedVote; quality3 += SingleTest.TestClassifier(ensemble, testingSet, accuracyMeasure); } quality1 = Math.Round((quality1 / _folds) * 100, 2); //quality2 = Math.Round((quality2 / _folds) * 100, 2); quality3 = Math.Round((quality3 / _folds) * 100, 2); //------------------------------------------------------------------ Console.WriteLine("PSO-GKC-CB-CB: " + dataset + " - Accuracy=" + quality1); SaveResults(dataset, "PSO-GKC-CB", quality1.ToString()); //Console.WriteLine("PSO-GKC-CB-ens-MV: " + dataset + " - Accuracy=" + quality2); //SaveResults(dataset, "PSO-GKC-CB-ens-MV", quality2.ToString()); Console.WriteLine("PSO-GKC-CB-ens-WV: " + dataset + " - Accuracy=" + quality3); SaveResults(dataset, "PSO-GKC-CB-ens-WV", quality3.ToString()); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); Console.WriteLine("-------------------------------------------"); } catch (Exception ex) { LogError(ex); // Console.WriteLine(ex.Message); } #endregion } }