Example #1
0
        public static void Run_Random_WekaClassifier(bool useAttributes, bool useInstances)
        {
            foreach (string dataset in GetDatasetFolds(DatasetNamesFile))
            {
                //----------------------------------------
                Console.WriteLine("Data Table:" + dataset);
                //----------------------------------------

                foreach (string algorithm in GetAlgorithms())
                {
                    ResultObject finalResult = new 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
                        {
                            ResultObject currentResult = SingleTest.EvaluateRandDR_WekaClassifier(algorithm, trFile, tsFile, trainingSet, useAttributes, useInstances);


                            //------------------------------------------------------------------
                            Console.WriteLine(algorithm + ": " + dataset + " - Accuracy = " + Math.Round(currentResult.Quality * 100, 2).ToString());

                            finalResult.Quality            += currentResult.Quality;
                            finalResult.AttributeReduction += currentResult.AttributeReduction;
                            finalResult.InstanceReduciton  += currentResult.InstanceReduciton;
                        }
                        catch (Exception ex)
                        {
                            LogError(ex);
                            //  Console.WriteLine(ex.Message);
                        }
                    }
                    //end folds loop

                    finalResult.Quality            /= _folds;
                    finalResult.AttributeReduction /= _folds;
                    finalResult.InstanceReduciton  /= _folds;

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