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()); }
/// <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]); } }
/// <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); } }
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)); }
/// <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(); }
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]); } }
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); }
/// <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]); } }
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(); } }
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); } }
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]); } }
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(); }
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)); }
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()); }
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); } } } }
public void Execute(IExampleInterface app) { for (int i = 1; i < 16; i++) { Perform(i); } }
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(); } }
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); } }
/// <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(); }
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); } } } }
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"); } } }
public void Execute(IExampleInterface app) { NormalizeSunspots(0.1, 0.9); BasicNetwork network = CreateNetwork(); IMLDataSet training = GenerateTraining(); Train(network, training); Predict(network); }
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); } }
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); }
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(); }
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(); }
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(); }
/// <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(); } }
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(); }
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)); }
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(); }
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); }
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); } }
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); } } } }
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); }
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); }
/// <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(); }
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)); }
/// <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(); }
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(); } } }
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(); } }
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]); } } }
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); }
/// <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(); }
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); } }