Beispiel #1
0
        public static void Run_ACODR_WekaClassifier_Mulit()
        {
            foreach (string dataset in GetDatasetFolds(DatasetNamesFile))
            {
                //----------------------------------------
                Console.WriteLine("Data Table:" + dataset);
                //----------------------------------------

                foreach (string algorithm in GetAlgorithms())
                {
                    string[]            algos        = WekaNETBridge.WekaClassification.GetWekaAlgorithmNames();
                    List <ResultObject> finalResults = new List <ResultObject>();

                    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];

                        string trFile = DatasetFolderPath + @"\" + dataset + @"\TR" + _currentFold.ToString() + "_" + dataset + ".arff";
                        string tsFile = DatasetFolderPath + @"\" + dataset + @"\TS" + _currentFold.ToString() + "_" + dataset + ".arff";


                        try
                        {
                            List <ResultObject> currentResults = SingleTest.EvaluateACOMinerDR_WekaClassifier_Multi(algorithm, trFile, tsFile, trainingSet, false, true);

                            for (int i = 0; i < currentResults.Count; i++)
                            {
                                //------------------------------------------------------------------
                                Console.WriteLine(algorithm + "-" + algos[i] + ": " + dataset + " - Accuracy = " + Math.Round(currentResults[i].Quality * 100, 2).ToString());
                                if (finalResults.Count < i + 1)
                                {
                                    finalResults.Add(currentResults[i]);
                                }
                                else
                                {
                                    finalResults[i].Quality            += currentResults[i].Quality;
                                    finalResults[i].AttributeReduction += currentResults[i].AttributeReduction;
                                    finalResults[i].InstanceReduciton  += currentResults[i].InstanceReduciton;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            LogError(ex);
                            //  Console.WriteLine(ex.Message);
                        }
                    }
                    //end folds loop

                    for (int i = 0; i < finalResults.Count; i++)
                    {
                        finalResults[i].Quality            /= _folds;
                        finalResults[i].AttributeReduction /= _folds;
                        finalResults[i].InstanceReduciton  /= _folds;

                        SaveResults(dataset, "ACO_DR-" + algorithm + "-" + algos[i], Math.Round(finalResults[i].Quality * 100, 2).ToString(), Math.Round(finalResults[i].AttributeReduction * 100, 2).ToString(), Math.Round(finalResults[i].InstanceReduciton * 100, 2).ToString());
                    }
                    Console.WriteLine("-------------------------------------------");
                    Console.WriteLine("-------------------------------------------");
                    Console.WriteLine("-------------------------------------------");
                }
                //end algorithms loop
            }
            //end datasets loop
        }