public void Execute(IExampleInterface app)
        {
            // Create a Bayesian network
            BayesianNetwork network = new BayesianNetwork();
            // Create the Uber driver event
            BayesianEvent UberDriver = network.CreateEvent("uber_driver");
            // create the witness event
            BayesianEvent WitnessSawUberDriver = network.CreateEvent("saw_uber_driver");

            // Attach the two
            network.CreateDependency(UberDriver, WitnessSawUberDriver);
            network.FinalizeStructure();

            // build the truth tables
            UberDriver?.Table?.AddLine(0.85, true);
            WitnessSawUberDriver?.Table?.AddLine(0.80, true, true);
            WitnessSawUberDriver?.Table?.AddLine(0.20, true, false);
            network.Validate();

            Console.WriteLine(network.ToString());
            Console.WriteLine($"Parameter count: {network.CalculateParameterCount()}");

            EnumerationQuery query = new EnumerationQuery(network);

            // The evidence is that someone saw the Uber driver hit the car
            query.DefineEventType(WitnessSawUberDriver, EventType.Evidence);
            // The result was the Uber driver did it
            query.DefineEventType(UberDriver, EventType.Outcome);
            query.SetEventValue(WitnessSawUberDriver, false);
            query.SetEventValue(UberDriver, false);
            query.Execute();
            Console.WriteLine(query.ToString());
        }
コード例 #2
0
ファイル: XORFlat.cs プロジェクト: tonyc2a/encog-dotnet-core
        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="app">Holds arguments and other info.</param>
        public void Execute(IExampleInterface app)
        {
            var network = new FlatNetwork(2, 4, 0, 1, false);
            network.Randomize();

            IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal);


            var train = new TrainFlatNetworkResilient(network, trainingSet);

            int epoch = 1;

            do
            {
                train.Iteration();
                Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
                epoch++;
            } while (train.Error > 0.01);

            var output = new double[1];
            // test the neural network
            Console.WriteLine(@"Neural Network Results:");
            foreach (IMLDataPair pair in trainingSet)
            {
                double[] input = pair.Input.Data;
                network.Compute(input, output);
                Console.WriteLine(input[0] + @"," + input[1] + @":" + output[0]);
            }
        }
コード例 #3
0
        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="app">Holds arguments and other info.</param>
        public void Execute(IExampleInterface app)
        {
            IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal);

            FlatNetwork network = CreateNetwork();

            Console.WriteLine(@"Starting Weights:");
            DisplayWeights(network);
            Evaluate(network, trainingSet);

            var train = new TrainFlatNetworkResilient(
                network, trainingSet);

            for (int iteration = 1; iteration <= ITERATIONS; iteration++)
            {
                train.Iteration();

                Console.WriteLine();
                Console.WriteLine(@"*** Iteration #" + iteration);
                Console.WriteLine(@"Error: " + train.Error);
                Evaluate(network, trainingSet);

                Console.WriteLine(@"LastGrad:"
                                  + FormatArray(train.LastGradient));
                Console.WriteLine(@"Updates :"
                                  + FormatArray(train.UpdateValues));

                DisplayWeights(network);
            }
        }
コード例 #4
0
        public void Execute(IExampleInterface app)
        {
            this.app = app;

            // Create the neural network.
            BasicLayer hopfield;
            var        network = new HopfieldNetwork(4);

            // This pattern will be trained
            bool[] pattern1 = { true, true, false, false };
            // This pattern will be presented
            bool[]  pattern2 = { true, false, false, false };
            IMLData result;

            var data1 = new BiPolarMLData(pattern1);
            var data2 = new BiPolarMLData(pattern2);
            var set   = new BasicMLDataSet();

            set.Add(data1);

            // train the neural network with pattern1
            app.WriteLine("Training Hopfield network with: "
                          + FormatBoolean(data1));

            network.AddPattern(data1);
            // present pattern1 and see it recognized
            result = network.Compute(data1);
            app.WriteLine("Presenting pattern:" + FormatBoolean(data1)
                          + ", and got " + FormatBoolean(result));
            // Present pattern2, which is similar to pattern 1. Pattern 1
            // should be recalled.
            result = network.Compute(data2);
            app.WriteLine("Presenting pattern:" + FormatBoolean(data2)
                          + ", and got " + FormatBoolean(result));
        }
コード例 #5
0
        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="app">Holds arguments and other info.</param>
        public void Execute(IExampleInterface app)
        {
            BasicNetwork network = CreateNetwork();

            IMLTrain train;

            if (app.Args.Length > 0 && String.Compare(app.Args[0], "anneal", true) == 0)
            {
                train = new NeuralSimulatedAnnealing(
                    network, new PilotScore(), 10, 2, 100);
            }
            else
            {
                train = new NeuralGeneticAlgorithm(
                    network, new FanInRandomizer(),
                    new PilotScore(), 500, 0.1, 0.25);
            }

            int epoch = 1;

            for (int i = 0; i < 50; i++)
            {
                train.Iteration();
                Console.WriteLine(@"Epoch #" + epoch + @" Score:" + train.Error);
                epoch++;
            }

            Console.WriteLine(@"\nHow the winning network landed:");
            network = (BasicNetwork) train.Method;
            var pilot = new NeuralPilot(network, true);
            Console.WriteLine(pilot.ScorePilot());
            EncogFramework.Instance.Shutdown();
        }
コード例 #6
0
        public void Execute(IExampleInterface app)
        {
            // create a neural network, without using a factory
            var svm = new SupportVectorMachine(1,true); // 1 input, & true for regression

            // create training data
            IMLDataSet trainingSet = new BasicMLDataSet(RegressionInput, RegressionIdeal);

            // train the SVM
            IMLTrain train = new SVMSearchTrain(svm, trainingSet);

            int epoch = 1;

            do
            {
                train.Iteration();
                Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
                epoch++;
            } while (train.Error > 0.01);

            // test the SVM
            Console.WriteLine(@"SVM Results:");
            foreach (IMLDataPair pair in trainingSet)
            {
                IMLData output = svm.Compute(pair.Input);
                Console.WriteLine(pair.Input[0]
                                  + @", actual=" + output[0] + @",ideal=" + pair.Ideal[0]);
            }
        }
コード例 #7
0
 public void Execute(IExampleInterface app)
 {
     if (app.Args.Length < 3)
     {
         Console.WriteLine(@"MarketPredict [data dir] [generate/train/prune/evaluate] PathToFile");
         Console.WriteLine(@"e.g csvMarketPredict [data dir] [generate/train/prune/evaluate] c:\\EURUSD.csv");
     }
     else
     {
         FileInfo dataDir = new FileInfo(Environment.CurrentDirectory);
         if (String.Compare(app.Args[0], "generate", true) == 0)
         {
             MarketBuildTraining.Generate(app.Args[1]);
         }
         else if (String.Compare(app.Args[0], "train", true) == 0)
         {
             MarketTrain.Train(dataDir);
         }
         else if (String.Compare(app.Args[0], "evaluate", true) == 0)
         {
             MarketEvaluate.Evaluate(dataDir,app.Args[1]);
         }
         else if (String.Compare(app.Args[0], "prune", true) == 0)
         {
             {
                 MarketPrune.Incremental(dataDir);
             }
         }
     }
 }
        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="app">Holds arguments and other info.</param>
        public void Execute(IExampleInterface app)
        {
            Console.WriteLine("Running wizard...");
            var analyst = new EncogAnalyst();

            var wizard = new AnalystWizard(analyst);

            wizard.TargetFieldName = "field:1";
            wizard.Wizard(sourceCSV,
                          false, AnalystFileFormat.DecpntComma);


            // customer id
            analyst.Script.Normalize.NormalizedFields[0].Action = Encog.Util.Arrayutil.NormalizationAction.PassThrough;

            var norm = new AnalystNormalizeCSV();

            norm.Report = new ConsoleStatusReportable();
            Console.WriteLine("Analyze for normalize...");
            norm.Analyze(sourceCSV, false, CSVFormat.English, analyst);
            norm.ProduceOutputHeaders = true;
            Console.WriteLine("Normalize...");
            norm.Normalize(targetCSV);
            analyst.Save(scriptEGA);
        }
コード例 #9
0
        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="app">Holds arguments and other info.</param>
        public void Execute(IExampleInterface app)
        {
            // create a neural network, without using a factory
            var network = new BasicNetwork();
            network.AddLayer(new BasicLayer(null, true, 2));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 3));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
            network.Structure.FinalizeStructure();
            network.Reset();

            // create training data
            IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal);

            // train the neural network
            IMLTrain train = new ResilientPropagation(network, trainingSet);

            int epoch = 1;

            do
            {
                train.Iteration();
                Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
                epoch++;
            } while (train.Error > 0.01);

            // test the neural network
            Console.WriteLine(@"Neural Network Results:");
            foreach (IMLDataPair pair in trainingSet)
            {
                IMLData output = network.Compute(pair.Input);
                Console.WriteLine(pair.Input[0] + @"," + pair.Input[1]
                                  + @", actual=" + output[0] + @",ideal=" + pair.Ideal[0]);
            }
        }
コード例 #10
0
        public void Execute(IExampleInterface app)
        {
            this.app = app;

            if (this.app.Args.Length < 1)
            {
                this.app.WriteLine("Must specify command file.  See source for format.");
            }
            else
            {


                // Read the file and display it line by line.
                StreamReader file =
                   new System.IO.StreamReader(this.app.Args[0]);
                while ((line = file.ReadLine()) != null)
                {
                    ExecuteLine();

                }

                file.Close();


            }
        }
コード例 #11
0
        public void Execute(IExampleInterface app)
        {
            if (app.Args.Length != 2)
            {
                Console.WriteLine("Usage: AnalystExample [iris/forest] [data directory]");
                Console.WriteLine("Data directory can be any empty directory.  Raw files will be downloaded to here.");
                return;
            }
            String command = app.Args[0].Trim().ToLower();
            var dir = new FileInfo(app.Args[1].Trim());

            var example = new AnalystExample();

            if (String.Compare(command, "forest", true) == 0)
            {
                example.ForestExample(dir);
            }
            else if (String.Compare(command, "iris", true) == 0)
            {
                example.IrisExample(dir);
            }
            else
            {
                Console.WriteLine("Unknown command: " + command);
            }
        }
コード例 #12
0
        public void Execute(IExampleInterface app)
        {
            // create a neural network, without using a factory
            var svm = new SupportVectorMachine(1, true); // 1 input, & true for regression

            // create training data
            IMLDataSet trainingSet = new BasicMLDataSet(RegressionInput, RegressionIdeal);

            // train the SVM
            IMLTrain train = new SVMSearchTrain(svm, trainingSet);

            int epoch = 1;

            do
            {
                train.Iteration();
                Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
                epoch++;
            } while (train.Error > 0.01);

            // test the SVM
            Console.WriteLine(@"SVM Results:");
            foreach (IMLDataPair pair in trainingSet)
            {
                IMLData output = svm.Compute(pair.Input);
                Console.WriteLine(pair.Input[0]
                                  + @", actual=" + output[0] + @",ideal=" + pair.Ideal[0]);
            }
        }
コード例 #13
0
        public static void TrainElmhanNetwork(ref IExampleInterface app)
        {
            BasicMLDataSet set = CreateEval.CreateEvaluationSetAndLoad(app.Args[1], CONFIG.STARTING_YEAR,
                                                                       CONFIG.TRAIN_END,
                                                                       CONFIG.INPUT_WINDOW,
                                                                       CONFIG.PREDICT_WINDOW);

            //create our network.
            BasicNetwork network =
                (BasicNetwork)CreateEval.CreateElmanNetwork(CONFIG.INPUT_WINDOW, CONFIG.PREDICT_WINDOW);

            //Train it..

            double LastError = CreateEval.TrainNetworks(network, set);

            Console.WriteLine("NetWork Trained to :" + LastError);
            SuperUtils.SaveTraining(CONFIG.DIRECTORY, CONFIG.TRAINING_FILE, set);
            SuperUtils.SaveNetwork(CONFIG.DIRECTORY, CONFIG.NETWORK_FILE, network);
            Console.WriteLine("Network Saved to :" + CONFIG.DIRECTORY + " File Named :" +
                              CONFIG.NETWORK_FILE);

            Console.WriteLine("Training Saved to :" + CONFIG.DIRECTORY + " File Named :" +
                              CONFIG.TRAINING_FILE);
            MakeAPause();
        }
コード例 #14
0
        public void Execute(IExampleInterface app)
        {
            this.app = app;

            // Create the neural network.
            BasicLayer hopfield;
            var network = new HopfieldNetwork(4);

            // This pattern will be trained
            bool[] pattern1 = {true, true, false, false};
            // This pattern will be presented
            bool[] pattern2 = {true, false, false, false};
            IMLData result;

            var data1 = new BiPolarMLData(pattern1);
            var data2 = new BiPolarMLData(pattern2);
            var set = new BasicMLDataSet();
            set.Add(data1);

            // train the neural network with pattern1
            app.WriteLine("Training Hopfield network with: "
                          + FormatBoolean(data1));

            network.AddPattern(data1);
            // present pattern1 and see it recognized
            result = network.Compute(data1);
            app.WriteLine("Presenting pattern:" + FormatBoolean(data1)
                          + ", and got " + FormatBoolean(result));
            // Present pattern2, which is similar to pattern 1. Pattern 1
            // should be recalled.
            result = network.Compute(data2);
            app.WriteLine("Presenting pattern:" + FormatBoolean(data2)
                          + ", and got " + FormatBoolean(result));
        }
コード例 #15
0
ファイル: marketpredict.cs プロジェクト: jongh0/MTree
        public static void TrainElmhanNetwork(ref IExampleInterface app)
        {
            BasicMLDataSet set = CreateEval.CreateEvaluationSetAndLoad(app.Args[1], CONFIG.STARTING_YEAR,
                                                                                              CONFIG.TRAIN_END,
                                                                                              CONFIG.INPUT_WINDOW,
                                                                                              CONFIG.PREDICT_WINDOW);

            //create our network.
            BasicNetwork network =
                (BasicNetwork)CreateEval.CreateElmanNetwork(CONFIG.INPUT_WINDOW, CONFIG.PREDICT_WINDOW);

            //Train it..

            double LastError = CreateEval.TrainNetworks(network, set);

            Console.WriteLine("NetWork Trained to :" + LastError);
            SuperUtils.SaveTraining(CONFIG.DIRECTORY, CONFIG.TRAINING_FILE, set);
            SuperUtils.SaveNetwork(CONFIG.DIRECTORY, CONFIG.NETWORK_FILE, network);
            Console.WriteLine("Network Saved to :" + CONFIG.DIRECTORY + " File Named :" +
                              CONFIG.NETWORK_FILE);

            Console.WriteLine("Training Saved to :" + CONFIG.DIRECTORY + " File Named :" +
                              CONFIG.TRAINING_FILE);
            MakeAPause();
        }
コード例 #16
0
        public void Execute(IExampleInterface app)
        {
            // build the bayesian network structure
            BayesianNetwork network        = new BayesianNetwork();
            BayesianEvent   BlueTaxi       = network.CreateEvent("blue_taxi");
            BayesianEvent   WitnessSawBlue = network.CreateEvent("saw_blue");

            network.CreateDependency(BlueTaxi, WitnessSawBlue);
            network.FinalizeStructure();
            // build the truth tales
            BlueTaxi.Table.AddLine(0.85, true);
            WitnessSawBlue.Table.AddLine(0.80, true, true);
            WitnessSawBlue.Table.AddLine(0.20, true, false);

            // validate the network
            network.Validate();
            // display basic stats
            Console.WriteLine(network.ToString());
            Console.WriteLine("Parameter count: " + network.CalculateParameterCount());
            EnumerationQuery query = new EnumerationQuery(network);

            //SamplingQuery query = new SamplingQuery(network);
            query.DefineEventType(WitnessSawBlue, EventType.Evidence);
            query.DefineEventType(BlueTaxi, EventType.Outcome);
            query.SetEventValue(WitnessSawBlue, false);
            query.SetEventValue(BlueTaxi, false);
            query.Execute();
            Console.WriteLine(query.ToString());
        }
コード例 #17
0
 public void Execute(IExampleInterface app)
 {
     if (app.Args.Length < 2)
     {
         Console.WriteLine(@"MarketPredict [data dir] [generate/train/prune/evaluate]");
     }
     else
     {
         var dataDir = new FileInfo(app.Args[0]);
         if (String.Compare(app.Args[1], "generate", true) == 0)
         {
             MarketBuildTraining.Generate(dataDir);
         }
         else if (String.Compare(app.Args[1], "train", true) == 0)
         {
             MarketTrain.Train(dataDir);
         }
         else if (String.Compare(app.Args[1], "evaluate", true) == 0)
         {
             MarketEvaluate.Evaluate(dataDir);
         }
         else if (String.Compare(app.Args[1], "prune", true) == 0)
         {
             {
                 MarketPrune.Incremental(dataDir);
             }
         }
     }
 }
コード例 #18
0
 public void Execute(IExampleInterface app)
 {
     for (int i = 1; i < 16; i++)
     {
         Perform(i);
     }
 }
コード例 #19
0
 public void Execute(IExampleInterface app)
 {
     for (int i = 1; i < 16; i++)
     {
         Perform(i);
     }
 }
コード例 #20
0
        public void Execute(IExampleInterface app)
        {
            if (app.Args.Length != 2)
            {
                Console.WriteLine(@"Note: This example assumes that headers are present in the CSV files.");
                Console.WriteLine(@"NormalizeFile [input file] [target file]");
            }
            else
            {
                var sourceFile = new FileInfo(app.Args[0]);
                var targetFile = new FileInfo(app.Args[1]);

                var analyst = new EncogAnalyst();
                var wizard  = new AnalystWizard(analyst);
                wizard.Wizard(sourceFile, true, AnalystFileFormat.DecpntComma);

                DumpFieldInfo(analyst);

                var norm = new AnalystNormalizeCSV();
                norm.Analyze(sourceFile, true, CSVFormat.English, analyst);
                norm.ProduceOutputHeaders = true;
                norm.Normalize(targetFile);
                EncogFramework.Instance.Shutdown();
            }
        }
コード例 #21
0
ファイル: mytests.cs プロジェクト: Romiko/encog-dotnet-core
        public void Execute(IExampleInterface app)
        {
            //placed a try catch in case something bugs.
            try
            {
                //lets check the lenght of the input from the console.
                if (app.Args.Length < 1)
                {
                    Console.WriteLine(@"MarketPredict [generate/train/prune/evaluate] [PathToFile]");
                    Console.WriteLine(@"e.g csvMarketPredict [generate/train/prune/evaluate] c:\\EURUSD.csv");
                }

               //looks like we are fine.
                else
                {

                    //save the files in the directory where the consoleexample.exe is located.
                    FileInfo dataDir = new FileInfo(@"c:\");

                    //we generate the network , by calling the CSVloader.
                    if (String.Compare(app.Args[0], "generate", true) == 0)
                    {
                        Console.WriteLine("Generating your network with file:" + app.Args[1]);
                        MarketBuildTraining.Generate(app.Args[1]);
                    }

                    //train the network here.
                    else if (String.Compare(app.Args[0], "train", true) == 0)
                    {
                        MarketTrain.Train(dataDir);
                    }
                    //Evaluate the network that was built and trained.
                    else if (String.Compare(app.Args[0], "evaluate", true) == 0)
                    {
                        MarketEvaluate.Evaluate(dataDir,app.Args[1]);
                    }
                    //Lets prune the network.
                    else if (String.Compare(app.Args[0], "prune", true) == 0)
                    {

                        MarketPrune.Incremental(dataDir);

                    }
                    else
                    {
                        Console.WriteLine("Didnt understand the command you typed:" + app.Args[0]);

                    }
                }
            }

            catch (Exception ex)
            {

                Console.WriteLine("Error Message:"+ ex.Message);
                Console.WriteLine("Error Innerexception:" + ex.InnerException);
                Console.WriteLine("Error stacktrace:" + ex.StackTrace);
                Console.WriteLine("Error source:" + ex.Source);
            }
        }
コード例 #22
0
        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="app">Holds arguments and other info.</param>
        public void Execute(IExampleInterface app)
        {
            BasicNetwork network = CreateNetwork();

            IMLTrain train;

            if (app.Args.Length > 0 && String.Compare(app.Args[0], "anneal", true) == 0)
            {
                train = new NeuralSimulatedAnnealing(
                    network, new PilotScore(), 10, 2, 100);
            }
            else
            {
                train = new NeuralGeneticAlgorithm(
                    network, new NguyenWidrowRandomizer(),
                    new PilotScore(), 500, 0.1, 0.25);
            }

            int epoch = 1;

            for (int i = 0; i < 50; i++)
            {
                train.Iteration();
                Console.WriteLine(@"Epoch #" + epoch + @" Score:" + train.Error);
                epoch++;
            }

            Console.WriteLine(@"\nHow the winning network landed:");
            network = (BasicNetwork)train.Method;
            var pilot = new NeuralPilot(network, true);

            Console.WriteLine(pilot.ScorePilot());
            EncogFramework.Instance.Shutdown();
        }
コード例 #23
0
        /// <summary>
        /// Program entry point.
        /// </summary>
        /// <param name="app">Holds arguments and other info.</param>
        public void Execute(IExampleInterface app)
        {
            // create a neural network, without using a factory
            var network = new BasicNetwork();

            network.AddLayer(new BasicLayer(null, true, 2));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 3));
            network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 1));
            network.Structure.FinalizeStructure();
            network.Reset();

            // create training data
            IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal);

            // train the neural network
            IMLTrain train = new ResilientPropagation(network, trainingSet);

            int epoch = 1;

            do
            {
                train.Iteration();
                Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error);
                epoch++;
            } while (train.Error > 0.01);

            // test the neural network
            Console.WriteLine(@"Neural Network Results:");
            foreach (IMLDataPair pair in trainingSet)
            {
                IMLData output = network.Compute(pair.Input);
                Console.WriteLine(pair.Input[0] + @"," + pair.Input[1]
                                  + @", actual=" + output[0] + @",ideal=" + pair.Ideal[0]);
            }
        }
コード例 #24
0
        public void Execute(IExampleInterface app)
        {
            // build the bayesian network structure
            BayesianNetwork network = new BayesianNetwork();
            BayesianEvent BlueTaxi = network.CreateEvent("blue_taxi");
            BayesianEvent WitnessSawBlue = network.CreateEvent("saw_blue");
            network.CreateDependency(BlueTaxi, WitnessSawBlue);
            network.FinalizeStructure();
            // build the truth tales
            BlueTaxi.Table.AddLine(0.85, true);
            WitnessSawBlue.Table.AddLine(0.80, true, true);
            WitnessSawBlue.Table.AddLine(0.20, true, false);

            // validate the network
            network.Validate();
            // display basic stats
            Console.WriteLine(network.ToString());
            Console.WriteLine("Parameter count: " + network.CalculateParameterCount());
            EnumerationQuery query = new EnumerationQuery(network);
            //SamplingQuery query = new SamplingQuery(network);
            query.DefineEventType(WitnessSawBlue, EventType.Evidence);
            query.DefineEventType(BlueTaxi, EventType.Outcome);
            query.SetEventValue(WitnessSawBlue, false);
            query.SetEventValue(BlueTaxi, false);
            query.Execute();
            Console.WriteLine(query.ToString());
        }
コード例 #25
0
 public void Execute(IExampleInterface app)
 {
     if (app.Args.Length < 3)
     {
         Console.WriteLine(@"MarketPredict [data dir] [generate/train/prune/evaluate] PathToFile");
         Console.WriteLine(@"e.g csvMarketPredict [data dir] [generate/train/prune/evaluate] c:\\EURUSD.csv");
     }
     else
     {
         var dataDir = new FileInfo(app.Args[0]);
         if (String.Compare(app.Args[1], "generate", true) == 0)
         {
             MarketBuildTraining.Generate(app.Args[2]);
         }
         else if (String.Compare(app.Args[1], "train", true) == 0)
         {
             MarketTrain.Train(dataDir);
         }
         else if (String.Compare(app.Args[1], "evaluate", true) == 0)
         {
             MarketEvaluate.Evaluate(dataDir, app.Args[2]);
         }
         else if (String.Compare(app.Args[1], "prune", true) == 0)
         {
             {
                 MarketPrune.Incremental(dataDir);
             }
         }
     }
 }
コード例 #26
0
        public void Execute(IExampleInterface app)
        {
            if (app.Args.Length != 2)
            {
                Console.WriteLine(@"Note: This example assumes that headers are present in the CSV files.");
                Console.WriteLine(@"NormalizeFile [input file] [target file]");
            }
            else
            {
                var sourceFile = new FileInfo(app.Args[0]);
                var targetFile = new FileInfo(app.Args[1]);

                var analyst = new EncogAnalyst();
                var wizard = new AnalystWizard(analyst);
                wizard.Wizard(sourceFile, true, AnalystFileFormat.DecpntComma);

                DumpFieldInfo(analyst);

                var norm = new AnalystNormalizeCSV();
                norm.Analyze(sourceFile, true, CSVFormat.English, analyst);
                norm.ProduceOutputHeaders = true;
                norm.Normalize(targetFile);
                EncogFramework.Instance.Shutdown();
            }
        }
コード例 #27
0
        public void Execute(IExampleInterface app)
        {
            if (app.Args.Length != 2)
            {
                Console.WriteLine("Usage: AnalystExample [iris/forest] [data directory]");
                Console.WriteLine("Data directory can be any empty directory.  Raw files will be downloaded to here.");
                return;
            }
            String command = app.Args[0].Trim().ToLower();
            var    dir     = new FileInfo(app.Args[1].Trim());

            var example = new AnalystExample();

            if (String.Compare(command, "forest", true) == 0)
            {
                example.ForestExample(dir);
            }
            else if (String.Compare(command, "iris", true) == 0)
            {
                example.IrisExample(dir);
            }
            else
            {
                Console.WriteLine("Unknown command: " + command);
            }
        }
コード例 #28
0
        public void Execute(IExampleInterface app)
        {
            this.app = app;
            SetupInput();
            var pattern = new ART1Pattern();

            pattern.InputNeurons  = INPUT_NEURONS;
            pattern.OutputNeurons = OUTPUT_NEURONS;
            var network = (ART1)pattern.Generate();

            for (int i = 0; i < PATTERN.Length; i++)
            {
                var dataIn  = new BiPolarMLData(input[i]);
                var dataOut = new BiPolarMLData(OUTPUT_NEURONS);
                network.Compute(dataIn, dataOut);
                if (network.HasWinner)
                {
                    app.WriteLine(PATTERN[i] + " - " + network.Winner);
                }
                else
                {
                    app.WriteLine(PATTERN[i] + " - new Input and all Classes exhausted");
                }
            }
        }
コード例 #29
0
        public void Execute(IExampleInterface app)
        {
            NormalizeSunspots(0.1, 0.9);
            BasicNetwork network  = CreateNetwork();
            IMLDataSet   training = GenerateTraining();

            Train(network, training);
            Predict(network);
        }
コード例 #30
0
        public void Execute(IExampleInterface app)
        {
            //placed a try catch in case something bugs.
            try
            {
                //lets check the lenght of the input from the console.
                if (app.Args.Length < 1)
                {
                    Console.WriteLine(@"MarketPredict [generate/train/prune/evaluate] [PathToFile]");
                    Console.WriteLine(@"e.g csvMarketPredict [generate/train/prune/evaluate] c:\\EURUSD.csv");
                }

                //looks like we are fine.
                else
                {
                    //save the files in the directory where the consoleexample.exe is located.
                    FileInfo dataDir = new FileInfo(@"c:\");

                    //we generate the network , by calling the CSVloader.
                    if (String.Compare(app.Args[0], "generate", true) == 0)
                    {
                        Console.WriteLine("Generating your network with file:" + app.Args[1]);
                        MarketBuildTraining.Generate(app.Args[1]);
                    }

                    //train the network here.
                    else if (String.Compare(app.Args[0], "train", true) == 0)
                    {
                        MarketTrain.Train(dataDir);
                    }
                    //Evaluate the network that was built and trained.
                    else if (String.Compare(app.Args[0], "evaluate", true) == 0)
                    {
                        MarketEvaluate.Evaluate(dataDir, app.Args[1]);
                    }
                    //Lets prune the network.
                    else if (String.Compare(app.Args[0], "prune", true) == 0)
                    {
                        MarketPrune.Incremental(dataDir);
                    }
                    else
                    {
                        Console.WriteLine("Didnt understand the command you typed:" + app.Args[0]);
                    }
                }
            }


            catch (Exception ex)
            {
                Console.WriteLine("Error Message:" + ex.Message);
                Console.WriteLine("Error Innerexception:" + ex.InnerException);
                Console.WriteLine("Error stacktrace:" + ex.StackTrace);
                Console.WriteLine("Error source:" + ex.Source);
            }
        }
コード例 #31
0
 public void Execute(IExampleInterface app)
 {
     GetForexPairData();
     EvaluateEnd = EvaluateStart + 100;
     NormalizeForexPair(-1, 1);
     var network = (BasicNetwork)CreateElmanNetwork(WindowSize);
     IMLDataSet training = GenerateTraining();
     Train(network, training);
     Predict(network);
 }
コード例 #32
0
        public void Execute(IExampleInterface app)
        {
            IMLDataSet trainingData = GenerateTraining(InputOutputCount, Compl);
            IMLMethod method = EncogUtility.SimpleFeedForward(InputOutputCount,
                                                              HiddenCount, 0, InputOutputCount, false);
            var train = new LevenbergMarquardtTraining((BasicNetwork) method, trainingData);
            EncogUtility.TrainToError(train, 0.01);

            EncogFramework.Instance.Shutdown();
        }
コード例 #33
0
        public void Execute(IExampleInterface app)
        {
            IMLDataSet trainingData = GenerateTraining(InputOutputCount, Compl);
            IMLMethod  method       = EncogUtility.SimpleFeedForward(InputOutputCount,
                                                                     HiddenCount, 0, InputOutputCount, false);
            var train = new LevenbergMarquardtTraining((BasicNetwork)method, trainingData);

            EncogUtility.TrainToError(train, 0.01);

            EncogFramework.Instance.Shutdown();
        }
コード例 #34
0
        public void Execute(IExampleInterface app)
        {
            PredictSP500 predict = new PredictSP500();
            if (app.Args.Length > 0 && app.Args[0].Equals("full"))
                predict.run(true);
            else
                predict.run(false);


            Console.ReadKey();
        }
コード例 #35
0
        public void Execute(IExampleInterface app)
        {
            GetForexPairData();
            EvaluateEnd = EvaluateStart + 100;
            NormalizeForexPair(-1, 1);
            var        network  = (BasicNetwork)CreateElmanNetwork(WindowSize);
            IMLDataSet training = GenerateTraining();

            Train(network, training);
            Predict(network);
        }
コード例 #36
0
 /// <summary>
 /// Program entry point.
 /// </summary>
 /// <param name="app">Holds arguments and other info.</param>
 public void Execute(IExampleInterface app)
 {
     if (app.Args.Length > 0)
     {
         Run(app.Args[0]);
     }
     else
     {
         Usage();
     }
 }
コード例 #37
0
        public void Execute(IExampleInterface app)
        {
            Console.WriteLine("Average iterations needed (lower is better)");

            IMLDataSet training = EncoderTrainingFactory.GenerateTraining(INPUT_OUTPUT, false, -1, 1);

            evaluateNetwork(createTANH(), training);
            evaluateNetwork(createElliott(), training);

            EncogFramework.Instance.Shutdown();
        }
コード例 #38
0
 public void Execute(IExampleInterface app)
 {
     this.app = app;
     IMLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL);
     BasicNetwork network = EncogUtility.SimpleFeedForward(2, 6, 0, 1, false);
     EncogUtility.TrainToError(network, trainingSet, 0.01);
     double error = network.CalculateError(trainingSet);
     EncogDirectoryPersistence.SaveObject(new FileInfo(FILENAME), network);
     double error2 = network.CalculateError(trainingSet);
     app.WriteLine("Error before save to EG: " + Format.FormatPercent(error));
     app.WriteLine("Error before after to EG: " + Format.FormatPercent(error2));
 }
コード例 #39
0
        public void Execute(IExampleInterface app)
        {
            this.app = app;
            Console.WriteLine("Waiting for connections on port " + PORT);

            IndicatorServer server = new IndicatorServer();
            server.AddListener(this);

            server.AddIndicatorFactory(new MyFactory());

            server.Start();
        }
コード例 #40
0
        public void Execute(IExampleInterface app)
        {
            this.app = app;

            BasicNetwork network = generateNetwork();
            IMLDataSet data = generateTraining();

            double rprop = EvaluateRPROP(network, data);
            double mprop = EvaluateMPROP(network, data);
            double factor = rprop/mprop;
            Console.WriteLine("Factor improvement:" + factor);
        }
コード例 #41
0
        public void Execute(IExampleInterface app)
        {
            // initialize input and output values
            double[][] input  = Generate(ROW_COUNT, INPUT_COUNT);
            double[][] output = Generate(ROW_COUNT, OUTPUT_COUNT);

            for (int i = 0; i < 10; i++)
            {
                long time = BenchmarkEncog(input, output);
                Console.WriteLine("Regular: {0}ms", time);
            }
        }
コード例 #42
0
        public void Execute(IExampleInterface app)
        {
            // initialize input and output values
            double[][] input = Generate(ROW_COUNT, INPUT_COUNT);
            double[][] output = Generate(ROW_COUNT, OUTPUT_COUNT);

            for (int i = 0; i < 10; i++)
            {
                long time = BenchmarkEncog(input, output);
                Console.WriteLine("Regular: {0}ms", time);
            }
        }
コード例 #43
0
        public void Execute(IExampleInterface app)
        {
            if (app.Args.Length < 1)
            {
                Console.WriteLine(@"SVMcsv [generate/train/prune/evaluate] PathToFile");
                Console.WriteLine(@"e.g SVMcsv [generate/train/prune/evaluate] c:\\EURUSD.csv");
            }
            else
            {
                FileInfo dataDir = new FileInfo(Environment.CurrentDirectory);
                if (String.Compare(app.Args[0], "generate", true) == 0)
                {
                    MarketBuildTraining.Generate(app.Args[1]);
                }
                if (String.Compare(app.Args[0], "train", true) == 0)
                {
                    if (app.Args.Length > 0)
                    {
                        //We have enough arguments, lets test them.
                        if (File.Exists(app.Args[1]))
                        {
                            //the file exits lets build the training.
                            //create our basic ml dataset.
                            MarketPredict.TrainElmhanNetwork(ref app);
                        }
                    }
                }
                if (String.Compare(app.Args[0], "trainsvm", true) == 0)
                {
                    if (app.Args.Length > 0)
                    {
                        //We have enough arguments, lets test them.
                        if (File.Exists(app.Args[1]))
                        {
                            //the file exits lets build the training.
                            //create our basic ml dataset.
                            MarketPredict.TrainSVMNetwork(ref app);
                        }
                    }
                }
                else if (String.Compare(app.Args[0], "evaluate", true) == 0)
                {
                    MarketEvaluate.Evaluate(app.Args[1]);
                }
                else if (String.Compare(app.Args[0], "prune", true) == 0)
                {
                    {
                        MarketPrune.Incremental(dataDir);
                    }
                }

            }
        }
コード例 #44
0
        public void Execute(IExampleInterface app)
        {
            this.app = app;
            PrepareInput();
            NormalizeInput();
            CPNNetwork network  = CreateNetwork();
            IMLDataSet training = GenerateTraining(input1, ideal1);

            TrainInstar(network, training);
            TrainOutstar(network, training);
            Test(network, PATTERN1, input1);
        }
コード例 #45
0
ファイル: mytests.cs プロジェクト: westerma/encog-dotnet-core
 public void Execute(IExampleInterface app)
 {
     if (app.Args.Length < 1)
     {
         Console.WriteLine(@"SVMcsv [generate/train/prune/evaluate] PathToFile");
         Console.WriteLine(@"e.g SVMcsv [generate/train/prune/evaluate] c:\\EURUSD.csv");
     }
     else
     {
         FileInfo dataDir = new FileInfo(Environment.CurrentDirectory);
         if (String.Compare(app.Args[0], "generate", true) == 0)
         {
             MarketBuildTraining.Generate(app.Args[1]);
         }
         if (String.Compare(app.Args[0], "train", true) == 0)
         {
             if (app.Args.Length > 0)
             {
                 //We have enough arguments, lets test them.
                 if (File.Exists(app.Args[1]))
                 {
                     //the file exits lets build the training.
                     //create our basic ml dataset.
                     MarketPredict.TrainElmhanNetwork(ref app);
                 }
             }
         }
         if (String.Compare(app.Args[0], "trainsvm", true) == 0)
         {
             if (app.Args.Length > 0)
             {
                 //We have enough arguments, lets test them.
                 if (File.Exists(app.Args[1]))
                 {
                     //the file exits lets build the training.
                     //create our basic ml dataset.
                     MarketPredict.TrainSVMNetwork(ref app);
                 }
             }
         }
         else if (String.Compare(app.Args[0], "evaluate", true) == 0)
         {
             MarketEvaluate.Evaluate(app.Args[1]);
         }
         else if (String.Compare(app.Args[0], "prune", true) == 0)
         {
             {
                 MarketPrune.Incremental(dataDir);
             }
         }
     }
 }
コード例 #46
0
ファイル: RemoteEMA.cs プロジェクト: Romiko/encog-dotnet-core
        public void Execute(IExampleInterface app)
        {
            _app = app;
            Console.WriteLine(@"Waiting for connections on port " + Port);

            var server = new IndicatorServer();
            server.AddListener(this);

            server.AddIndicatorFactory(new MyFactory());

            server.Start();
            server.WaitForShutdown();
        }
        public void Execute(IExampleInterface app)
        {
            this.app = app;

            BasicNetwork network = generateNetwork();
            IMLDataSet   data    = generateTraining();

            double rprop  = EvaluateRPROP(network, data);
            double mprop  = EvaluateMPROP(network, data);
            double factor = rprop / mprop;

            Console.WriteLine("Factor improvement:" + factor);
        }
コード例 #48
0
        /// <summary>
        /// Setup and solve the TSP.
        /// </summary>
        public void Execute(IExampleInterface app)
        {
            this.app = app;

            var builder = new StringBuilder();

            initCities();

            IPopulation pop = initPopulation();

            ICalculateScore score = new TSPScore(cities);

            genetic = new TrainEA(pop, score);

            genetic.AddOperation(0.9, new SpliceNoRepeat(CITIES / 3));
            genetic.AddOperation(0.1, new MutateShuffle());

            int    sameSolutionCount = 0;
            int    iteration         = 1;
            double lastSolution      = Double.MaxValue;

            while (sameSolutionCount < MAX_SAME_SOLUTION)
            {
                genetic.Iteration();

                double thisSolution = genetic.Error;

                builder.Length = 0;
                builder.Append("Iteration: ");
                builder.Append(iteration++);
                builder.Append(", Best Path Length = ");
                builder.Append(thisSolution);

                Console.WriteLine(builder.ToString());

                if (Math.Abs(lastSolution - thisSolution) < 1.0)
                {
                    sameSolutionCount++;
                }
                else
                {
                    sameSolutionCount = 0;
                }

                lastSolution = thisSolution;
            }

            Console.WriteLine("Good solution found:");
            displaySolution();
            genetic.FinishTraining();
        }
コード例 #49
0
        public void Execute(IExampleInterface app)
        {
            _app = app;
            Console.WriteLine(@"Waiting for connections on port " + Port);

            var server = new IndicatorServer();

            server.AddListener(this);

            server.AddIndicatorFactory(new MyFactory());

            server.Start();
            server.WaitForShutdown();
        }
コード例 #50
0
 public void Execute(IExampleInterface app)
 {
     this.app = app;
     this.app = app;
     IMLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL);
     BasicNetwork network = EncogUtility.SimpleFeedForward(2, 6, 0, 1, false);
     EncogUtility.TrainToError(network, trainingSet, 0.01);
     double error = network.CalculateError(trainingSet);
     SerializeObject.Save("encog.ser", network);
     network = (BasicNetwork) SerializeObject.Load("encog.ser");
     double error2 = network.CalculateError(trainingSet);
     app.WriteLine("Error before save to ser: " + Format.FormatPercent(error));
     app.WriteLine("Error before after to ser: " + Format.FormatPercent(error2));
 }
コード例 #51
0
        /// <summary>
        /// Setup and solve the TSP.
        /// </summary>
        public void Execute(IExampleInterface app)
        {
            this.app = app;

            var builder = new StringBuilder();

            initCities();

            genetic = new BasicGeneticAlgorithm();

            initPopulation(genetic);
            genetic.MutationPercent  = MUTATION_PERCENT;
            genetic.PercentToMate    = PERCENT_TO_MATE;
            genetic.MatingPopulation = MATING_POPULATION_PERCENT;
            genetic.Crossover        = new SpliceNoRepeat(CITIES / 3);
            genetic.Mutate           = new MutateShuffle();

            int    sameSolutionCount = 0;
            int    iteration         = 1;
            double lastSolution      = Double.MaxValue;

            while (sameSolutionCount < MAX_SAME_SOLUTION)
            {
                genetic.Iteration();

                double thisSolution = genetic.Population.Best.Score;

                builder.Length = 0;
                builder.Append("Iteration: ");
                builder.Append(iteration++);
                builder.Append(", Best Path Length = ");
                builder.Append(thisSolution);

                Console.WriteLine(builder.ToString());

                if (Math.Abs(lastSolution - thisSolution) < 1.0)
                {
                    sameSolutionCount++;
                }
                else
                {
                    sameSolutionCount = 0;
                }

                lastSolution = thisSolution;
            }

            Console.WriteLine(@"Good solution found:");
            displaySolution();
        }
コード例 #52
0
        public void Execute(IExampleInterface app)
        {
            if (app.Args.Length < 1)
            {
                Console.WriteLine(@"Usage: ForestCover [data directory] [generate/train/traingui/evaluate] [e/o]");
            }
            else
            {
                try
                {
                    var config = new ForestConfig(new FileInfo(app.Args[0]));
                    if (String.Compare(app.Args[1], "generate", true) == 0)
                    {
                        if (app.Args.Length < 3)
                        {
                            Console.WriteLine(
                                @"When using generate, you must specify an 'e' or an 'o' as the second parameter.");
                        }
                        else
                        {
                            bool useOneOf = !app.Args[2].ToLower().Equals("e");

                            Generate(config, useOneOf);
                        }
                    }
                    else if (String.Compare(app.Args[1], "train", true) == 0)
                    {
                        Train(config, false);
                    }
                    else if (String.Compare(app.Args[1], "traingui", true) == 0)
                    {
                        Train(config, true);
                    }
                    else if (String.Compare(app.Args[1], "evaluate", true) == 0)
                    {
                        Evaluate(config);
                    }
                }

                /*catch (Exception e)
                 * {
                 *  Console.WriteLine(e.StackTrace);
                 * }*/
                finally
                {
                    EncogFramework.Instance.Shutdown();
                }
            }
        }
コード例 #53
0
        public void Execute(IExampleInterface app)
        {
            int inputNeurons  = CHAR_WIDTH * CHAR_HEIGHT;
            int outputNeurons = DIGITS.Length;

            var pattern = new ADALINEPattern();

            pattern.InputNeurons  = inputNeurons;
            pattern.OutputNeurons = outputNeurons;
            var network = (BasicNetwork)pattern.Generate();

            (new RangeRandomizer(-0.5, 0.5)).Randomize(network);

            // train it
            IMLDataSet training = GenerateTraining();
            IMLTrain   train    = new TrainAdaline(network, training, 0.01);

            int epoch = 1;

            do
            {
                train.Iteration();
                app.WriteLine("Epoch #" + epoch + " Error:" + train.Error);
                epoch++;
            } while (train.Error > 0.01);

            //
            app.WriteLine("Error:" + network.CalculateError(training));

            // test it
            for (int i = 0; i < DIGITS.Length; i++)
            {
                int output = network.Winner(Image2data(DIGITS[i]));

                for (int j = 0; j < CHAR_HEIGHT; j++)
                {
                    if (j == CHAR_HEIGHT - 1)
                    {
                        app.WriteLine(DIGITS[i][j] + " -> " + output);
                    }
                    else
                    {
                        app.WriteLine(DIGITS[i][j]);
                    }
                }

                app.WriteLine();
            }
        }
コード例 #54
0
 public void Execute(IExampleInterface app)
 {
     if (app.Args.Length < 3)
     {
         Console.WriteLine(@" [prunator ]  [data dir]  [trainingfile] [networkfile]");
     }
     else
     {
         var dataDir = new FileInfo(app.Args[1]);
         if (String.Compare(app.Args[0], "prune", true) == 0)
         {
             PrunerLoader.Incremental(dataDir, app.Args[2], app.Args[3]);
         }
     }
 }
コード例 #55
0
        public void Execute(IExampleInterface app)
        {
            // Normalize values with an actual range of (0 to 100) to (-1 to 1)
            var norm = new NormalizedField(NormalizationAction.Normalize,
                                           null, 100, 0, 1, -1);

            double x = 5;
            double y = norm.Normalize(x);

            Console.WriteLine(x + @" normalized is " + y);

            double z = norm.DeNormalize(y);

            Console.WriteLine(y + @" denormalized is " + z);
        }
コード例 #56
0
        public void Execute(IExampleInterface app)
        {
            // Normalize values with an actual range of (0 to 100) to (-1 to 1)
            var norm = new NormalizedField(NormalizationAction.Normalize,
                                           null, 100, 0, 1, -1);

            double x = 5;
            double y = norm.Normalize(x);

            Console.WriteLine(x + @" normalized is " + y);

            double z = norm.DeNormalize(y);

            Console.WriteLine(y + @" denormalized is " + z);
        }
コード例 #57
0
 public void Execute(IExampleInterface app)
 {
     if (app.Args.Length < 3)
     {
         Console.WriteLine(@" [prunator ]  [data dir]  [trainingfile] [networkfile]");
     }
     else
     {
         var dataDir = new FileInfo(app.Args[1]);
         if (String.Compare(app.Args[0], "prune", true) == 0)
         {
             PrunerLoader.Incremental(dataDir, app.Args[2], app.Args[3]);
         }
     }
 }
コード例 #58
0
ファイル: GeneticSolveTSP.cs プロジェクト: jongh0/MTree
        /// <summary>
        /// Setup and solve the TSP.
        /// </summary>
        public void Execute(IExampleInterface app)
        {
            this.app = app;

            var builder = new StringBuilder();

            initCities();

            IPopulation pop = initPopulation();
		
		ICalculateScore score =  new TSPScore(cities);

		genetic = new TrainEA(pop,score);
		
		genetic.AddOperation(0.9,new SpliceNoRepeat(CITIES/3));
		genetic.AddOperation(0.1,new MutateShuffle());

		int sameSolutionCount = 0;
		int iteration = 1;
		double lastSolution = Double.MaxValue;

		while (sameSolutionCount < MAX_SAME_SOLUTION) {
			genetic.Iteration();

			double thisSolution = genetic.Error;

			builder.Length = 0;
			builder.Append("Iteration: ");
			builder.Append(iteration++);
			builder.Append(", Best Path Length = ");
			builder.Append(thisSolution);

			Console.WriteLine(builder.ToString());

			if (Math.Abs(lastSolution - thisSolution) < 1.0) {
				sameSolutionCount++;
			} else {
				sameSolutionCount = 0;
			}

			lastSolution = thisSolution;
		}

		Console.WriteLine("Good solution found:");
		displaySolution();
		genetic.FinishTraining();
        }
コード例 #59
0
        public void Execute(IExampleInterface app)
        {
            this.app = app;

            var temp = new TemporalXOR();
            IMLDataSet trainingSet = temp.Generate(100);

            var jordanNetwork = (BasicNetwork) CreateJordanNetwork();
            var feedforwardNetwork = (BasicNetwork) CreateFeedforwardNetwork();

            double elmanError = TrainNetwork("Jordan", jordanNetwork, trainingSet);
            double feedforwardError = TrainNetwork("Feedforward", feedforwardNetwork, trainingSet);

            app.WriteLine("Best error rate with Jordan Network: " + elmanError);
            app.WriteLine("Best error rate with Feedforward Network: " + feedforwardError);
            app.WriteLine("Jordan will perform only marginally better than feedforward.\nThe more output neurons, the better performance a Jordan will give.");
        }
        public void Execute(IExampleInterface app)
        {
            this.app = app;
            var pattern = new BAMPattern();
            pattern.F1Neurons = INPUT_NEURONS;
            pattern.F2Neurons = OUTPUT_NEURONS;
            var network = (BAMNetwork) pattern.Generate();

            // train
            for (int i = 0; i < NAMES.Length; i++)
            {
                network.AddPattern(
                    StringToBipolar(NAMES[i]),
                    StringToBipolar(PHONES[i]));
            }

            // test
            for (int i = 0; i < NAMES.Length; i++)
            {
                var data = new NeuralDataMapping(
                    StringToBipolar(NAMES[i]),
                    RandomBiPolar(OUT_CHARS*BITS_PER_CHAR));
                RunBAM(network, data);
            }

            app.WriteLine();

            for (int i = 0; i < PHONES.Length; i++)
            {
                var data = new NeuralDataMapping(
                    StringToBipolar(PHONES[i]),
                    RandomBiPolar(IN_CHARS*BITS_PER_CHAR));
                RunBAM(network, data);
            }

            app.WriteLine();

            for (int i = 0; i < NAMES.Length; i++)
            {
                var data = new NeuralDataMapping(
                    StringToBipolar(NAMES2[i]),
                    RandomBiPolar(OUT_CHARS*BITS_PER_CHAR));
                RunBAM(network, data);
            }
        }