Beispiel #1
0
        public static void Run()
        {
            var training = EncogUtility.LoadEGB2Memory(Config.TrainingFile);


            var pattern = new FeedForwardPattern
            {
                InputNeurons       = training.InputSize,
                OutputNeurons      = training.IdealSize,
                ActivationFunction = new ActivationTANH()
            };

            var prune = new PruneIncremental(training, pattern, 100, 1, 10,
                                             new ConsoleStatusReportable());

            prune.AddHiddenLayer(5, 50);
            prune.AddHiddenLayer(0, 50);

            Console.WriteLine("Starting prune process");

            prune.Process();

            EncogDirectoryPersistence.SaveObject(Config.NetworkFile, prune.BestNetwork);
            EncogUtility.SaveEGB(Config.TrainingFile, prune.Training);
        }
        public static void Incremental(FileInfo dataDir)
        {
            FileInfo file = FileUtil.CombinePath(dataDir, Config.TRAINING_FILE);

            if (!file.Exists)
            {
                Console.WriteLine(@"Can't read file: " + file);
                return;
            }

            IMLDataSet training = EncogUtility.LoadEGB2Memory(file);


            var pattern = new FeedForwardPattern
            {
                InputNeurons       = training.InputSize,
                OutputNeurons      = training.IdealSize,
                ActivationFunction = new ActivationTANH()
            };

            var prune = new PruneIncremental(training, pattern, 100, 1, 10,
                                             new ConsoleStatusReportable());

            prune.AddHiddenLayer(5, 50);
            prune.AddHiddenLayer(0, 50);

            prune.Process();

            EncogDirectoryPersistence.SaveObject(file, prune.BestNetwork);
        }
Beispiel #3
0
        /// <summary>
        /// Saves the network to the specified directory with the specified parameter name.
        /// This version saves super machine to file.
        /// </summary>
        /// <param name="directory">The directory.</param>
        /// <param name="file">The file.</param>
        /// <param name="anetwork">The network to save..</param>
        public static SupportVectorMachine SaveNetwork(string file, SupportVectorMachine anetwork)
        {
            FileInfo networkFile = new FileInfo(@file);

            EncogDirectoryPersistence.SaveObject(networkFile, anetwork);
            return(anetwork);
        }
Beispiel #4
0
        /// <see cref="INetwork.BuildElmanNetwork"/>
        public INetwork BuildElmanNetwork()
        {
            if (TrainedNetworkFile.Exists)
            {
                return(this);
            }

            var pattern = new ElmanPattern {
                ActivationFunction = new ActivationSigmoid(),
                InputNeurons       = InputCount,
                OutputNeurons      = OutputCount
            };

            pattern.AddHiddenLayer(1);

            try {
                var network = (BasicNetwork)pattern.Generate();
                EncogDirectoryPersistence.SaveObject(TrainedNetworkFile, network);
                TrainedNetworkFile = new FileInfo(TrainedNetworkFile.FullName);
            } catch (Exception e) {
                var a = e;
            }

            return(this);
        }
Beispiel #5
0
        private void BtnEntrenar_Click(object sender, EventArgs e)
        {
            this.con.Open();

            var redN = new BasicNetwork();

            redN.AddLayer(new BasicLayer(null, false, imagen0.Height * imagen0.Width));
            redN.AddLayer(new BasicLayer(new ActivationLinear(), false, 2));
            redN.AddLayer(new BasicLayer(new ActivationLinear(), true, 1));
            redN.Structure.FinalizeStructure();
            redN.Reset();

            IMLDataSet Set = new BasicMLDataSet(E, IDEAL);


            IMLTrain train = new ResilientPropagation(redN, Set);


            do
            {
                CicloE++;
                train.Iteration();
                cadena.Add(train.Error);
                cadena2.Add(CicloE);
            }while (train.Error > 0.01);

            timer1.Enabled = true;
            timer1.Start();
            char i1;
            char i2;

            i1 = txtNombre.Text.ToUpper()[0];
            i2 = txtApellido.Text.ToUpper()[0];
            EncogDirectoryPersistence.SaveObject(new FileInfo(i1.ToString() + i2.ToString() + ".txt"), redN);
        }
Beispiel #6
0
        public void TrainNetwork(FileInfo ann, FileInfo trainingFile)
        {
            try
            {
                var network     = (BasicNetwork)EncogDirectoryPersistence.LoadObject(ann);
                var trainingSet = EncogUtility.LoadCSV2Memory(trainingFile.ToString(),
                                                              network.InputCount, network.OutputCount, true, CSVFormat.English, false);
                var trainerAlgorithm = new ResilientPropagation(network, trainingSet);                  // 16617 ==> e 0.1
                //var trainerAlgorithm = new QuickPropagation(network, trainingSet, 2.0);
                //var trainerAlgorithm = new ManhattanPropagation(network, trainingSet, 0.001);           //
                //var trainerAlgorithm = new ScaledConjugateGradient(network, trainingSet);                   // 73799  ==> e 0.1
                //var trainerAlgorithm = new LevenbergMarquardtTraining(network, trainingSet);          // 32750 ==> e 0.1
                var iteration = 1;
                do
                {
                    trainerAlgorithm.Iteration();
                    Console.WriteLine("Epoch : {0} Error : {1}", iteration, trainerAlgorithm.Error);
                    iteration++;
                } while (trainerAlgorithm.Error > 0.1);

                EncogDirectoryPersistence.SaveObject(ann, (BasicNetwork)network);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Beispiel #7
0
        public static void MyTrainConsole(IMLTrain train, BasicNetwork network, IMLDataSet trainingSet, int minutes, FileInfo networkFile, FileInfo trainFile)
        {
            int  epoch = 1;
            long remaining;

            Console.WriteLine(@"Beginning training...");
            long start = Environment.TickCount;

            do
            {
                train.Iteration();
                long current = Environment.TickCount;
                long elapsed = (current - start) / 1000;
                remaining = minutes - elapsed / 60;
                Console.WriteLine($@"Iteration #{Format.FormatInteger(epoch)} Error:{Format.FormatPercent(train.Error)} elapsed time = {Format.FormatTimeSpan((int)elapsed)} time left = {Format.FormatTimeSpan((int)remaining * 60)}");
                epoch++;
                EncogDirectoryPersistence.SaveObject(networkFile, network);
                TrainingContinuation cont = train.Pause();
                EncogDirectoryPersistence.SaveObject(trainFile, cont);
                train.Resume(cont);
                foreach (var x in cont.Contents)
                {
                    Console.WriteLine($"{x.Key}: {((double[])x.Value).Average()}");
                }
            }while (remaining > 0 && !train.TrainingDone && !Console.KeyAvailable);
            Console.WriteLine("Finishing.");
            train.FinishTraining();
        }
Beispiel #8
0
        /// <summary>
        /// Saves the network to the specified directory with the specified parameter name.
        /// </summary>
        /// <param name="directory">The directory.</param>
        /// <param name="file">The file.</param>
        /// <param name="anetwork">The network to save..</param>
        public static BasicNetwork SaveNetwork(string directory, string file, BasicNetwork anetwork)
        {
            FileInfo networkFile = FileUtil.CombinePath(new FileInfo(directory), @file);

            EncogDirectoryPersistence.SaveObject(networkFile, anetwork);
            return(anetwork);
        }
Beispiel #9
0
        /// <summary>
        /// Saves the network to the specified directory with the specified parameter name.
        /// This version saves super machine to file.
        /// </summary>
        /// <param name="directory">The directory.</param>
        /// <param name="file">The file.</param>
        /// <param name="anetwork">The network to save..</param>
        public static SupportVectorMachine SaveNetwork(string directory, string file, SupportVectorMachine anetwork)
        {
            FileInfo networkFile = FileUtil.CombinePath(new FileInfo(directory), @file);

            EncogDirectoryPersistence.SaveObject(networkFile, anetwork);
            return(anetwork);
        }
        public static void Train(FileInfo dataDir)
        {
            FileInfo networkFile  = FileUtil.CombinePath(dataDir, Config.NETWORK_FILE);
            FileInfo trainingFile = FileUtil.CombinePath(dataDir, Config.TRAINING_FILE);

            // network file
            if (!networkFile.Exists)
            {
                Console.WriteLine(@"Can't read file: " + networkFile);
                return;
            }

            var network = (BasicNetwork)EncogDirectoryPersistence.LoadObject(networkFile);

            // training file
            if (!trainingFile.Exists)
            {
                Console.WriteLine(@"Can't read file: " + trainingFile);
                return;
            }

            IMLDataSet trainingSet = EncogUtility.LoadEGB2Memory(trainingFile);

            // train the neural network
            EncogUtility.TrainConsole(network, trainingSet, Config.TRAINING_MINUTES);

            Console.WriteLine(@"Final Error: " + network.CalculateError(trainingSet));
            Console.WriteLine(@"Training complete, saving network.");
            EncogDirectoryPersistence.SaveObject(networkFile, network);
            Console.WriteLine(@"Network saved.");

            EncogFramework.Instance.Shutdown();
        }
 void pruneWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     txtStatus.Text = "Pruning Completed";
     network        = (BasicNetwork)prune.BestNetwork;
     EncogDirectoryPersistence.SaveObject(Config.TrainedNetworkFile, (BasicNetwork)network);
     Step5(); //Train Step
 }
Beispiel #12
0
        public static void Generate(FileInfo dataDir)
        {
            IMarketLoader loader = new YahooFinanceLoader();
            var           market = new MarketMLDataSet(loader,
                                                       Config.INPUT_WINDOW, Config.PREDICT_WINDOW);
            var desc = new MarketDataDescription(
                Config.TICKER, MarketDataType.AdjustedClose, true, true);

            market.AddDescription(desc);

            var end   = DateTime.Now;            // end today
            var begin = new DateTime(end.Ticks); // begin 30 days ago

            // Gather training data for the last 2 years, stopping 60 days short of today.
            // The 60 days will be used to evaluate prediction.
            begin = begin.AddDays(-60);
            end   = end.AddDays(-60);
            begin = begin.AddYears(-2);

            market.Load(begin, end);
            market.Generate();
            EncogUtility.SaveEGB(FileUtil.CombinePath(dataDir, Config.TRAINING_FILE), market);

            // create a network
            BasicNetwork network = EncogUtility.SimpleFeedForward(
                market.InputSize,
                Config.HIDDEN1_COUNT,
                Config.HIDDEN2_COUNT,
                market.IdealSize,
                true);

            // save the network and the training
            EncogDirectoryPersistence.SaveObject(FileUtil.CombinePath(dataDir, Config.NETWORK_FILE), network);
        }
        /// <summary>
        /// Perform the training option.
        /// </summary>
        public void Train()
        {
            // first, create the machine learning method
            var       methodFactory = new MLMethodFactory();
            IMLMethod method        = methodFactory.Create(Config.MethodType, Config.MethodArchitecture, Config.InputWindow, 1);

            // second, create the data set
            string     filename = FileUtil.CombinePath(new FileInfo(_path), Config.FilenameTrain).ToString();
            IMLDataSet dataSet  = EncogUtility.LoadEGB2Memory(new FileInfo(filename));

            // third, create the trainer
            var      trainFactory = new MLTrainFactory();
            IMLTrain train        = trainFactory.Create(method, dataSet, Config.TrainType, Config.TrainParams);

            // reset if improve is less than 1% over 5 cycles
            if (method is IMLResettable && !(train is ManhattanPropagation))
            {
                train.AddStrategy(new RequiredImprovementStrategy(500));
            }

            // fourth, train and evaluate.
            EncogUtility.TrainToError(train, Config.TargetError);
            method = train.Method;
            EncogDirectoryPersistence.SaveObject(FileUtil.CombinePath(new FileInfo(_path), Config.MethodName), method);

            // finally, write out what we did
            Console.WriteLine(@"Machine Learning Type: " + Config.MethodType);
            Console.WriteLine(@"Machine Learning Architecture: " + Config.MethodArchitecture);

            Console.WriteLine(@"Training Method: " + Config.TrainType);
            Console.WriteLine(@"Training Args: " + Config.TrainParams);
        }
Beispiel #14
0
        /// <summary>
        /// Saves the network to the specified directory with the specified parameter name.
        /// </summary>
        /// <param name="directory">The directory.</param>
        /// <param name="file">The file.</param>
        /// <param name="anetwork">The network to save..</param>
        public static BasicNetwork SaveNetwork(string file, BasicNetwork anetwork)
        {
            FileInfo networkFile = new FileInfo(@file);

            EncogDirectoryPersistence.SaveObject(networkFile, anetwork);
            return(anetwork);
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            using (var p = Process.GetCurrentProcess())
                p.PriorityClass = ProcessPriorityClass.Idle;

            FileInfo dataSetFile = new FileInfo("dataset.egb");
            FileInfo networkFile = new FileInfo($"network{networkID}.nn");
            FileInfo trainFile   = new FileInfo($"train{networkID}.tr");

            Console.WriteLine("Loading dataset.");
            if (!dataSetFile.Exists)
            {
                ExtractTrainData(dataSetFile);
                Console.WriteLine(@"Extracting dataset from database: " + dataSetFile);
                return;
            }
            var trainingSet = EncogUtility.LoadEGB2Memory(dataSetFile);

            Console.WriteLine($"Loaded {trainingSet.Count} samples. Input size: {trainingSet.InputSize}, Output size: {trainingSet.IdealSize}");

            BasicNetwork network;

            if (networkFile.Exists)
            {
                Console.WriteLine($"Loading network {networkFile.FullName}");
                network = (BasicNetwork)EncogDirectoryPersistence.LoadObject(networkFile);
            }
            else
            {
                Console.WriteLine("Creating NN.");
                network = EncogUtility.SimpleFeedForward(trainingSet.InputSize, 1000, 200, trainingSet.IdealSize, true);
                network.Reset();
            }

            using (var p = Process.GetCurrentProcess())
                Console.WriteLine($"RAM usage: {p.WorkingSet64 / 1024 / 1024} MB.");

            ResilientPropagation train = new ResilientPropagation(network, trainingSet)
            {
                ThreadCount = 0
            };

            if (trainFile.Exists)
            {
                TrainingContinuation cont = (TrainingContinuation)EncogDirectoryPersistence.LoadObject(trainFile);
                train.Resume(cont);
            }
            MyTrainConsole(train, network, trainingSet, minutes, networkFile, trainFile);
            Console.WriteLine(@"Final Error: " + train.Error);
            Console.WriteLine(@"Training complete, saving network.");
            EncogDirectoryPersistence.SaveObject(networkFile, network);
            Console.WriteLine(@"Network saved. Press s to stop.");
            ConsoleKeyInfo key;

            do
            {
                key = Console.ReadKey();
            }while (key.KeyChar != 's');
        }
Beispiel #16
0
        public static NeuralBrain CreateANN(string name)
        {
            NeuralBrain brain = new NeuralBrain();

            brain.Name = name;
            FileInfo file = new FileInfo(Path.ChangeExtension(name, EXT));

            EncogDirectoryPersistence.SaveObject(file, brain.network);
            return(brain);
        }
Beispiel #17
0
        private static void CreateNetwork(FileInfo networkFile)
        {
            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();
            EncogDirectoryPersistence.SaveObject(networkFile, network);
        }
Beispiel #18
0
        /// <summary>
        /// Metodo responsavel por criar a rede neural
        /// </summary>
        /// <param name="source">FileInfo com o path do network</param>
        private static void CreateNetwork(FileInfo source)
        {
            var network = new BasicNetwork();

            network.AddLayer(new BasicLayer(new ActivationLinear(), true, 4));
            network.AddLayer(new BasicLayer(new ActivationTANH(), true, 6));
            network.AddLayer(new BasicLayer(new ActivationTANH(), false, 2));
            network.Structure.FinalizeStructure();
            network.Reset();
            EncogDirectoryPersistence.SaveObject(source, (BasicNetwork)network);
        }
 public static void SaveNetworkToFS(ref NetworkContainer container, string fileName)
 {
     try
     {
         EncogDirectoryPersistence.SaveObject(new FileInfo(fileName), container.network);
     }
     catch
     {
         throw new EncogException("Failed to save network to file system.");
     }
 }
 void trainWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Cancelled == true)
     {
         txtStatus.Text = "Cancelled";
     }
     else
     {
         txtStatus.Text = "Finished";
         EncogDirectoryPersistence.SaveObject(Config.TrainedNetworkFile, (BasicNetwork)network);
     }
 }
Beispiel #21
0
        /// <summary>
        /// Perform a deep copy.
        /// Silverlight version.
        /// </summary>
        /// <param name="oldObj">The old object.</param>
        /// <returns>The new object.</returns>
        static public Object DeepCopy(Object oldObj)
        {
            // now make the copy
            MemoryStream mstream = new MemoryStream();

            EncogDirectoryPersistence.SaveObject(mstream, oldObj);
            // now read it back
            mstream.Position = 0;
            Object result = EncogDirectoryPersistence.LoadObject(mstream);

            mstream.Close();
            return(result);
        }
        public void Create(FileInfo networkFile)
        {
            var network = new BasicNetwork();

            network.AddLayer(new BasicLayer(new ActivationLinear(), true, 4));
            network.AddLayer(new BasicLayer(new ActivationTANH(), true, 6));
            network.AddLayer(new BasicLayer(new ActivationTANH(), true, 2));

            network.Structure.FinalizeStructure();
            network.Reset();

            EncogDirectoryPersistence.SaveObject(networkFile, network);
        }
Beispiel #23
0
        static void Main(string[] args)
        {
            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);

            Console.WriteLine($"Error before save to EG: {error}");
            EncogDirectoryPersistence.SaveObject(new FileInfo(FILENAME), network);
            network = (BasicNetwork)EncogDirectoryPersistence.LoadObject(new FileInfo(FILENAME));
            error   = network.CalculateError(trainingSet);
            Console.WriteLine($"Error after load from EG: {error}");
        }
        public int saveNetwork(string name)
        {
            try
            {
                System.IO.FileInfo info = new System.IO.FileInfo(name);

                EncogDirectoryPersistence.SaveObject(info, bestMethod);
                return(1);
            }
            catch
            {
                return(0);
            }
        }
Beispiel #25
0
        static void Main(string[] args)
        {
            var inputs  = new List <double[]>();
            var outputs = new List <double[]>();

            var lines = File.ReadLines(@"../../states.txt");

            foreach (var line in lines)
            {
                var lineInput  = new List <double>();
                var lineOutput = new List <double>();

                var weights = line.Split(new char[] { ',' });
                lineInput.AddRange(weights.Take(8).Select(value => double.Parse(value)));
                lineOutput.Add(double.Parse(weights[8]));
                lineInput.AddRange(weights.Skip(9).Select(value => double.Parse(value)));

                inputs.Add(lineInput.ToArray());
                outputs.Add(lineOutput.ToArray());
            }//foreach

            var nnInput = inputs.ToArray();
            var nnIdeal = outputs.ToArray();

            var network = new BasicNetwork();

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

            IMLDataSet trainingSet = new BasicMLDataSet(nnInput, nnIdeal);

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

            EncogDirectoryPersistence.SaveObject(new FileInfo("network.eg"), network);

            Console.ReadKey();
        } //Main
Beispiel #26
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));
        }
Beispiel #27
0
        private static void TrainNetwork()
        {
            var network     = (BasicNetwork)EncogDirectoryPersistence.LoadObject(Config.TrainedNetworkFile);
            var trainingSet = EncogUtility.LoadCSV2Memory(Config.NormalizedTrainingFile.ToString(), network.InputCount,
                                                          network.OutputCount, true, CSVFormat.English, false);

            var train = new ResilientPropagation(network, trainingSet);
            var epoch = 1;

            do
            {
                train.Iteration();
                Console.WriteLine("Epoch : {0} Error : {1}", epoch, train.Error);
                epoch++;
            } while (train.Error > 0.01);
            EncogDirectoryPersistence.SaveObject(Config.TrainedNetworkFile, network);
        }
Beispiel #28
0
        private void Learn_Click(object sender, RoutedEventArgs e)
        {
            var downsample = new Downsampler();
            var training   = new ImageMLDataSet(downsample, true, 1, -1);

            for (var i = 0; i < Images.Count; ++i)
            {
                var ideal = new BasicMLData(DIGITS_COUNT);
                for (int j = 0; j < DIGITS_COUNT; ++j)
                {
                    if (j == i)
                    {
                        ideal[j] = 1;
                    }
                    else
                    {
                        ideal[j] = -1;
                    }
                }
                foreach (var img in Images[i])
                {
                    MemoryStream  stream  = new MemoryStream();
                    BitmapEncoder encoder = new BmpBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create(img));
                    encoder.Save(stream);

                    var bitmap = new Drawing.Bitmap(stream);
                    var data   = new ImageMLData(bitmap);
                    training.Add(data, ideal);
                }
            }

            training.Downsample(DIGIT_HEIGHT, DIGIT_WIDTH);

            network = EncogUtility.SimpleFeedForward(training.InputSize, 35, 0, training.IdealSize, true);

            double strategyError  = 0.01;
            int    strategyCycles = 2000;

            var train = new ResilientPropagation(network, training);

            //train.AddStrategy(new ResetStrategy(strategyError, strategyCycles));
            EncogUtility.TrainDialog(train, network, training);

            EncogDirectoryPersistence.SaveObject(new FileInfo("network.eg"), network);
        }
Beispiel #29
0
        /// <inheritdoc />
        public override sealed bool ExecuteCommand(String args)
        {
            // get filenames
            String trainingID = Prop.GetPropertyString(
                ScriptProperties.MlConfigTrainingFile);
            String resourceID = Prop.GetPropertyString(
                ScriptProperties.MlConfigMachineLearningFile);

            FileInfo trainingFile = Script.ResolveFilename(trainingID);
            FileInfo resourceFile = Script.ResolveFilename(resourceID);

            String type = Prop.GetPropertyString(
                ScriptProperties.MlConfigType);
            String arch = Prop.GetPropertyString(
                ScriptProperties.MlConfigArchitecture);

            EncogLogging.Log(EncogLogging.LevelDebug, "Beginning create");
            EncogLogging.Log(EncogLogging.LevelDebug, "training file:"
                             + trainingID);
            EncogLogging.Log(EncogLogging.LevelDebug, "resource file:"
                             + resourceID);
            EncogLogging.Log(EncogLogging.LevelDebug, "type:" + type);
            EncogLogging.Log(EncogLogging.LevelDebug, "arch:" + arch);

            var egb = new EncogEGBFile(trainingFile.ToString());

            egb.Open();
            int input = egb.InputCount;
            int ideal = egb.IdealCount;

            egb.Close();

            var       factory = new MLMethodFactory();
            IMLMethod obj     = factory.Create(type, arch, input, ideal);

            if (obj is BayesianNetwork)
            {
                string query = Prop.GetPropertyString(ScriptProperties.MLConfigQuery);
                ((BayesianNetwork)obj).DefineClassificationStructure(query);
            }

            EncogDirectoryPersistence.SaveObject(resourceFile, obj);

            return(false);
        }
Beispiel #30
0
        private void CreateCommand()
        {
            if (_cmd.Args.Count != 3)
            {
                Console.WriteLine(@"Must specify method filename, type and args.");
                return;
            }

            String methodFile = _cmd.Args[0];
            String type       = _cmd.Args[1];
            String args       = _cmd.Args[2];

            _sw.Start();
            var       factory = new MLMethodFactory();
            IMLMethod method  = factory.Create(type, args, 0, 0);

            EncogDirectoryPersistence.SaveObject(new FileInfo(methodFile), method);
        }