示例#1
0
        public static void RunACORNN()
        {
            foreach (string dataset in GetDatasetFolds("datasets.txt"))
            {
                //----------------------------------------
                Console.WriteLine("Data Table:" + dataset);
                //----------------------------------------

                double avgQuality = 0;
                double avgSize    = 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];

                    double quality = 0.0;
                    double size    = 0.0;

                    AccuracyMeasure     testMeasure        = new AccuracyMeasure();
                    IActivationFunction activationFunction = new SigmoidActivationFunction();

                    //int hiddenUnitCount = trainingSet.Metadata.Attributes.Length * trainingSet.Metadata.Target.Length;
                    int hiddenUnitCount = (trainingSet.Metadata.Attributes.Length + trainingSet.Metadata.Target.Length);

                    try
                    {
                        stopWatch.Reset();
                        stopWatch.Start();
                        NeuralNetwork network = SingleTest.CreateNeuralNet_ACOR(trainingSet, hiddenUnitCount, 0.9, activationFunction);
                        stopWatch.Stop();

                        quality = SingleTest.TestClassifier(network, testingSet, testMeasure);
                        quality = Math.Round(quality * 100, 2);
                        size    = network.Size;

                        avgQuality += quality;
                        avgSize    += size;

                        //----------------------------------------
                        Console.WriteLine("ACOR-NN:" + dataset + "- Fold:" + _currentFold.ToString() + "=>" + testMeasure.ToString() + ":" + quality.ToString());
                        Console.WriteLine("---------------------------------------------------");
                        //----------------------------------------
                    }
                    catch (Exception ex)
                    {
                        LogError(ex);
                        break;
                    }
                }

                avgSize /= _folds;
                SaveResults(dataset, "ACOR-NN", avgQuality.ToString(), avgSize.ToString(), stopWatch.ElapsedMilliseconds.ToString());


                Console.WriteLine("---------------------------------------------------");
                Console.WriteLine("---------------------------------------------------");
                Console.WriteLine("---------------------------------------------------");
            }
        }