Inheritance: Encog.ML.BasicML, IMLMethod, IMLRegression, IMLInputOutput, IMLInput, IMLOutput, IMLClassification, IMLError
コード例 #1
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]);
            }
        }
コード例 #2
0
ファイル: SVMSearchTrain.cs プロジェクト: neismit/emds
 public SVMSearchTrain(SupportVectorMachine method, IMLDataSet training)
     : base(TrainingImplementationType.Iterative)
 {
     this._x9425fdc2df7bcafc = 0;
     this._x2350dfd8c7639ed6 = -5.0;
     this._x38c942a9bdfcbac4 = 2.0;
     while (true)
     {
         if (3 != 0)
         {
             this._xdee5cbd981b6d49e = 15.0;
             if (0 == 0)
             {
                 this._xec9380575da42aee = -10.0;
             }
         }
         this._xd522fee165affb59 = 10.0;
         this._x441f2c3a7d69c688 = 1.0;
         this._x87a7fc6a72741c2e = method;
         this.Training = training;
         this._x9eeb587621db687c = false;
         if (0 == 0)
         {
             if (0 == 0)
             {
                 this._xab248fa87e95a7df = false;
                 this._x1e074b5762f8595b = new SVMTrain(this._x87a7fc6a72741c2e, training);
                 return;
             }
             return;
         }
     }
 }
コード例 #3
0
ファイル: TestPersistSVM.cs プロジェクト: jongh0/MTree
 private SupportVectorMachine Create()
 {
     IMLDataSet training = new BasicMLDataSet(XOR.XORInput, XOR.XORIdeal);
     SupportVectorMachine result = new SupportVectorMachine(2, SVMType.EpsilonSupportVectorRegression, KernelType.RadialBasisFunction);
     SVMTrain train = new SVMTrain(result, training);
     train.Iteration();
     return result;
 }
コード例 #4
0
 private static SupportVectorMachine Create(IMLDataSet theset, int inputs)
 {
     IMLDataSet training = new BasicMLDataSet(theset);
     SupportVectorMachine result = new SupportVectorMachine(inputs, SVMType.EpsilonSupportVectorRegression, KernelType.Sigmoid);
     SVMTrain train = new SVMTrain(result, training);
     train.Iteration();
     return result;
 }
コード例 #5
0
ファイル: SVMTrain.cs プロジェクト: neismit/emds
 public SVMTrain(SupportVectorMachine method, IMLDataSet dataSet)
     : base(TrainingImplementationType.OnePass)
 {
     this._x9425fdc2df7bcafc = 0;
     this._x87a7fc6a72741c2e = method;
     this.Training = dataSet;
     this._xab248fa87e95a7df = false;
     this._x77eae494203cfff5 = EncodeSVMProblem.Encode(dataSet, 0);
     this._xc7c4e9c099884228 = 1.0 / ((double) this._x87a7fc6a72741c2e.InputCount);
     this._x3c4da2980d043c95 = 1.0;
     if (0 == 0)
     {
     }
 }
コード例 #6
0
        public static void Generate(string fileName)
        {

          
            FileInfo dataDir = new FileInfo(@Environment.CurrentDirectory);
            IMarketLoader loader = new CSVFinal();
            var market = new MarketMLDataSet(loader,CONFIG.INPUT_WINDOW, CONFIG.PREDICT_WINDOW);
          //  var desc = new MarketDataDescription(Config.TICKER, MarketDataType.Close, true, true);

            var desc = new MarketDataDescription(CONFIG.TICKER, MarketDataType.Close, true, true);
            market.AddDescription(desc);
            string currentDirectory =@"c:\";
            loader.GetFile(fileName);

            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(-600);
            end = begin.AddDays(200);
           
            Console.WriteLine("You are loading date from:" + begin.ToShortDateString() + " To :" + end.ToShortDateString());

            market.Load(begin, end);
            market.Generate();
            EncogUtility.SaveEGB(FileUtil.CombinePath(dataDir, CONFIG.SVMTRAINING_FILE), market);

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


            SupportVectorMachine network = new SupportVectorMachine(CONFIG.INPUT_WINDOW, true);
            TrainNetworks(network, market);
            // save the network and the training
            EncogDirectoryPersistence.SaveObject(FileUtil.CombinePath(dataDir,CONFIG.SVMTRAINING_FILE), network);
        }
コード例 #7
0
 public static void train(SupportVectorMachine network,IMLDataSet training)
 {
     SVMTrain train = new SVMTrain(network, training);
     train.Iteration();
 }
コード例 #8
0
            public static SupportVectorMachine SVMSearch(SupportVectorMachine anetwork, IMLDataSet training)
            {
                SVMSearchTrain bestsearch = new SVMSearchTrain(anetwork, training);
                StopTrainingStrategy stop = new StopTrainingStrategy(0.00000000001, 1);
                bestsearch.AddStrategy(stop);
                while (bestsearch.IterationNumber < 30 && !stop.ShouldStop())
                {
                bestsearch.Iteration();
                Console.WriteLine("Iteration #" + bestsearch.IterationNumber + " Error :" + bestsearch.Error);
                }

                bestsearch.FinishTraining();

                   return anetwork;
            }
コード例 #9
0
            public static void predict(SupportVectorMachine network, SupportVectorMachine network2)
            {
                Console.WriteLine(@"Year\tActual\tPredict\tClosed Loops");

                for (int year = EVALUATE_START; year < EVALUATE_END; year++)
                {
                // calculate based on actual data
                IMLData input = new BasicMLData(WINDOW_SIZE);
                for (int i = 0; i < input.Count; i++)
                {
                input.Data[i] = normalizedSunspots[(year - WINDOW_SIZE) + i];
                //input.setData(i,this.normalizedSunspots[(year-WINDOW_SIZE)+i]);
                }
                IMLData output = network.Compute(input);
                IMLData output2 = network2.Compute(input);

                double prediction = output.Data[0];
                double prediction2 = output2.Data[0];
                closedLoopSunspots[year] = prediction;

                // calculate "closed loop", based on predicted data
                for (int i = 0; i < input.Count; i++)
                {
                input.Data[i] = closedLoopSunspots[(year - WINDOW_SIZE) + i];
                //input.setData(i,this.closedLoopSunspots[(year-WINDOW_SIZE)+i]);
                }
                output = network.Compute(input);
                double closedLoopPrediction = output[0];

                IMLData output3 = network2.Compute(input);
                double closedLoopPrediction2 = output[0];

                // display
                //System.out.println((STARTING_YEAR+year)
                //        +"\t"+f.format(this.normalizedSunspots[year])
                //        +"\t"+f.format(prediction)
                //        +"\t"+f.format(closedLoopPrediction)

                Console.WriteLine(((STARTING_YEAR + year)
                           + @"\t " + Format.FormatDouble(SUNSPOTS[year], 4)
                           + @"\t " + Format.FormatDouble(normalizedSunspots[year], 4)
                           + @"\t " + Format.FormatDouble(prediction, 4)
                            + @"\t " + Format.FormatDouble(prediction2, 4)
                           + @"\t " + Format.FormatDouble(closedLoopPrediction, 4)
                             + @"\t " + Format.FormatDouble(closedLoopPrediction2, 4)
                          ));

                }
            }
コード例 #10
0
        /// <inheritdoc/>
        public Object Read(Stream mask0)
        {
            var result = new SupportVectorMachine();
            var ins0 = new EncogReadHelper(mask0);
            EncogFileSection section;

            while ((section = ins0.ReadNextSection()) != null)
            {
                if (section.SectionName.Equals("SVM")
                    && section.SubSectionName.Equals("PARAMS"))
                {
                    IDictionary<String, String> paras = section.ParseParams();
                    EngineArray.PutAll(paras, result.Properties);
                }
                if (section.SectionName.Equals("SVM")
                    && section.SubSectionName.Equals("SVM-PARAM"))
                {
                    IDictionary<String, String> p = section.ParseParams();
                    result.InputCount = EncogFileSection.ParseInt(p,
                                                                  PersistConst.InputCount);
                    result.Params.C = EncogFileSection.ParseDouble(p,
                                                                   ParamC);
                    result.Params.cache_size = EncogFileSection.ParseDouble(
                        p, ParamCacheSize);
                    result.Params.coef0 = EncogFileSection.ParseDouble(p,
                                                                       ParamCoef0);
                    result.Params.degree = EncogFileSection.ParseDouble(p,
                                                                     ParamDegree);
                    result.Params.eps = EncogFileSection.ParseDouble(p,
                                                                     ParamEps);
                    result.Params.gamma = EncogFileSection.ParseDouble(p,
                                                                       ParamGamma);
                    result.Params.kernel_type = EncogFileSection.ParseInt(
                        p, ParamKernelType);
                    result.Params.nr_weight = EncogFileSection.ParseInt(
                        p, ParamNumWeight);
                    result.Params.nu = EncogFileSection.ParseDouble(p,
                                                                    ParamNu);
                    result.Params.p = EncogFileSection.ParseDouble(p,
                                                                   ParamP);
                    result.Params.probability = EncogFileSection.ParseInt(
                        p, ParamProbability);
                    result.Params.shrinking = EncogFileSection.ParseInt(
                        p, ParamShrinking);
                    /*result.Params.statIterations = Encog.Persist.EncogFileSection.ParseInt(
                            params_0, PersistSVM.PARAM_START_ITERATIONS);*/
                    result.Params.svm_type = EncogFileSection.ParseInt(p,
                                                                       ParamSVMType);
                    result.Params.weight = section.ParseDoubleArray(p, ParamWeight);
                    result.Params.weight_label = EncogFileSection
                        .ParseIntArray(p, ParamWeightLabel);
                }
                else if (section.SectionName.Equals("SVM")
                         && section.SubSectionName.Equals("SVM-MODEL"))
                {
                    try
                    {
                        var rdr = new StringReader(
                            section.LinesAsString);
                        TextReader br = rdr;
                        svm_model model = svm.svm_load_model(rdr);
                        result.Model = model;
                        br.Close();
                        rdr.Close();
                    }
                    catch (IOException ex)
                    {
                        throw new PersistError(ex);
                    }
                }
            }

            return result;
        }
コード例 #11
0
ファイル: NetworkUtility.cs プロジェクト: jongh0/MTree
 /// <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;
 }
コード例 #12
0
        /// <inheritdoc/>
        public Object Read(Stream mask0)
        {
            var result = new SupportVectorMachine();
            var ins0   = new EncogReadHelper(mask0);
            EncogFileSection section;

            while ((section = ins0.ReadNextSection()) != null)
            {
                if (section.SectionName.Equals("SVM") &&
                    section.SubSectionName.Equals("PARAMS"))
                {
                    IDictionary <String, String> paras = section.ParseParams();
                    EngineArray.PutAll(paras, result.Properties);
                }
                if (section.SectionName.Equals("SVM") &&
                    section.SubSectionName.Equals("SVM-PARAM"))
                {
                    IDictionary <String, String> p = section.ParseParams();
                    result.InputCount = EncogFileSection.ParseInt(p,
                                                                  PersistConst.InputCount);
                    result.Params.C = EncogFileSection.ParseDouble(p,
                                                                   ParamC);
                    result.Params.cache_size = EncogFileSection.ParseDouble(
                        p, ParamCacheSize);
                    result.Params.coef0 = EncogFileSection.ParseDouble(p,
                                                                       ParamCoef0);
                    result.Params.degree = EncogFileSection.ParseDouble(p,
                                                                        ParamDegree);
                    result.Params.eps = EncogFileSection.ParseDouble(p,
                                                                     ParamEps);
                    result.Params.gamma = EncogFileSection.ParseDouble(p,
                                                                       ParamGamma);
                    result.Params.kernel_type = EncogFileSection.ParseInt(
                        p, ParamKernelType);
                    result.Params.nr_weight = EncogFileSection.ParseInt(
                        p, ParamNumWeight);
                    result.Params.nu = EncogFileSection.ParseDouble(p,
                                                                    ParamNu);
                    result.Params.p = EncogFileSection.ParseDouble(p,
                                                                   ParamP);
                    result.Params.probability = EncogFileSection.ParseInt(
                        p, ParamProbability);
                    result.Params.shrinking = EncogFileSection.ParseInt(
                        p, ParamShrinking);

                    /*result.Params.statIterations = Encog.Persist.EncogFileSection.ParseInt(
                     *                                  params_0, PersistSVM.PARAM_START_ITERATIONS);*/
                    result.Params.svm_type = EncogFileSection.ParseInt(p,
                                                                       ParamSVMType);
                    result.Params.weight = EncogFileSection.ParseDoubleArray(
                        p, ParamWeight);
                    result.Params.weight_label = EncogFileSection
                                                 .ParseIntArray(p, ParamWeightLabel);
                }
                else if (section.SectionName.Equals("SVM") &&
                         section.SubSectionName.Equals("SVM-MODEL"))
                {
                    try
                    {
#if !SILVERLIGHT
                        var rdr = new StringReader(
                            section.LinesAsString);
                        TextReader br    = rdr;
                        svm_model  model = svm.svm_load_model(rdr);
                        result.Model = model;
                        br.Close();
                        rdr.Close();
#endif
                    }
                    catch (IOException ex)
                    {
                        throw new PersistError(ex);
                    }
                }
            }

            return(result);
        }
コード例 #13
0
 public static double TrainSVM(SVMTrain train, SupportVectorMachine machine)
 {
    
     StopTrainingStrategy stop = new StopTrainingStrategy(0.0001, 200);
     train.AddStrategy(stop);
     var sw = new Stopwatch();
     sw.Start();
     while (!stop.ShouldStop())
     {
         train.PreIteration();
         
         train.Iteration();
         train.PostIteration();
         Console.WriteLine(@"Iteration #:" + train.IterationNumber + @" Error:" + train.Error +" Gamma:"+train.Gamma);
     }
     sw.Stop();
     Console.WriteLine(@"SVM Trained in :" + sw.ElapsedMilliseconds);
     return train.Error;
 }
コード例 #14
0
ファイル: PersistSVM.cs プロジェクト: neismit/emds
 public object Read(Stream mask0)
 {
     EncogReadHelper helper;
     EncogFileSection section;
     IDictionary<string, string> dictionary2;
     SupportVectorMachine machine = new SupportVectorMachine();
     goto Label_0306;
     Label_000B:
     if (section.SubSectionName.Equals("SVM-MODEL"))
     {
         try
         {
             svm_model _model;
             StringReader fp = new StringReader(section.LinesAsString);
             TextReader reader2 = fp;
             if (0 == 0)
             {
                 _model = svm.svm_load_model(fp);
             }
             machine.Model = _model;
             reader2.Close();
             fp.Close();
         }
         catch (IOException exception)
         {
             throw new PersistError(exception);
         }
     }
     Label_001D:
     if ((section = helper.ReadNextSection()) != null)
     {
         goto Label_028D;
     }
     return machine;
     Label_002F:
     if (!section.SectionName.Equals("SVM"))
     {
         goto Label_001D;
     }
     if (-2 == 0)
     {
         goto Label_023F;
     }
     if (3 != 0)
     {
         goto Label_000B;
     }
     return machine;
     Label_0237:
     dictionary2 = section.ParseParams();
     Label_023F:
     machine.InputCount = EncogFileSection.ParseInt(dictionary2, "inputCount");
     machine.Params.C = EncogFileSection.ParseDouble(dictionary2, "C");
     machine.Params.cache_size = EncogFileSection.ParseDouble(dictionary2, "cacheSize");
     if (0 == 0)
     {
         if (0 == 0)
         {
             while (true)
             {
                 machine.Params.coef0 = EncogFileSection.ParseDouble(dictionary2, "coef0");
                 machine.Params.degree = EncogFileSection.ParseDouble(dictionary2, "degree");
                 machine.Params.eps = EncogFileSection.ParseDouble(dictionary2, "eps");
                 machine.Params.gamma = EncogFileSection.ParseDouble(dictionary2, "gamma");
                 machine.Params.kernel_type = EncogFileSection.ParseInt(dictionary2, "kernelType");
                 machine.Params.nr_weight = EncogFileSection.ParseInt(dictionary2, "nrWeight");
                 machine.Params.nu = EncogFileSection.ParseDouble(dictionary2, "nu");
                 machine.Params.p = EncogFileSection.ParseDouble(dictionary2, "p");
                 if (0 == 0)
                 {
                     machine.Params.probability = EncogFileSection.ParseInt(dictionary2, "probability");
                     if (-2147483648 == 0)
                     {
                         goto Label_001D;
                     }
                     machine.Params.shrinking = EncogFileSection.ParseInt(dictionary2, "shrinking");
                     machine.Params.svm_type = EncogFileSection.ParseInt(dictionary2, "svmType");
                     machine.Params.weight = EncogFileSection.ParseDoubleArray(dictionary2, "weight");
                     machine.Params.weight_label = EncogFileSection.ParseIntArray(dictionary2, "weightLabel");
                     if (0xff != 0)
                     {
                         goto Label_001D;
                     }
                     goto Label_002F;
                 }
             }
         }
         goto Label_000B;
     }
     if (0 == 0)
     {
         goto Label_0306;
     }
     Label_028D:
     if (section.SectionName.Equals("SVM") && section.SubSectionName.Equals("PARAMS"))
     {
         IDictionary<string, string> source = section.ParseParams();
         if (0x7fffffff == 0)
         {
             goto Label_0237;
         }
         EngineArray.PutAll<string, string>(source, machine.Properties);
     }
     if (section.SectionName.Equals("SVM") && section.SubSectionName.Equals("SVM-PARAM"))
     {
         if (8 != 0)
         {
             if (3 == 0)
             {
                 goto Label_001D;
             }
             goto Label_0237;
         }
     }
     else
     {
         goto Label_002F;
     }
     Label_0306:
     helper = new EncogReadHelper(mask0);
     goto Label_001D;
 }
コード例 #15
0
ファイル: SVM.cs プロジェクト: dobrybajer/NeuralNetworks
        public override void CreateNetwork(int size)
        {
            Network.UpdateSizeInfo(size, 3);

            Svm = new SupportVectorMachine(size, false);
        }
コード例 #16
0
        public static double TrainNetworks(SupportVectorMachine network, MarketMLDataSet training)
        {
            // train the neural network
            SVMTrain trainMain = new SVMTrain(network, training);

            StopTrainingStrategy stop = new StopTrainingStrategy(0.0001, 200);
            trainMain.AddStrategy(stop);


            var sw = new Stopwatch();
            sw.Start();
            while (!stop.ShouldStop())
            {
                trainMain.PreIteration();


                trainMain.Iteration();
                trainMain.PostIteration();

                Console.WriteLine(@"Iteration #:" + trainMain.IterationNumber + @" Error:" + trainMain.Error);
            }
            sw.Stop();
            Console.WriteLine("SVM Trained in :" + sw.ElapsedMilliseconds + "For error:" + trainMain.Error + " Iterated:" + trainMain.IterationNumber);
            return trainMain.Error;
        }
コード例 #17
0
ファイル: marketpredict.cs プロジェクト: jongh0/MTree
 public static double  train(SupportVectorMachine network, IMLDataSet training)
 {
     SVMTrain train = new SVMTrain(network, training);
     train.Iteration();
     return train.Error;
 }
コード例 #18
0
ファイル: TestPersistSVM.cs プロジェクト: jongh0/MTree
 private void Validate(SupportVectorMachine svm)
 {
     Assert.AreEqual(KernelType.RadialBasisFunction, svm.KernelType);
     Assert.AreEqual(SVMType.EpsilonSupportVectorRegression, svm.SVMType);
     Assert.AreEqual(4, svm.Model.SV.Length);
 }
コード例 #19
0
ファイル: marketpredict.cs プロジェクト: jongh0/MTree
 public static SupportVectorMachine createNetwork()
 {
     SupportVectorMachine network = new SupportVectorMachine(CONFIG.INPUT_WINDOW, true);
     return network;
 }
コード例 #20
0
ファイル: NetworkUtility.cs プロジェクト: jongh0/MTree
 /// <summary>
 ///     Saves the network to the specified directory with the specified parameter name.
 ///     This version saves super machine to file.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <param name="anetwork">The network to save..</param>
 public static SupportVectorMachine SaveNetwork(string file, SupportVectorMachine anetwork)
 {
     var networkFile = new FileInfo(@file);
     EncogDirectoryPersistence.SaveObject(networkFile, anetwork);
     return anetwork;
 }
コード例 #21
0
        /// <summary>
        /// Create the SVM.
        /// </summary>
        ///
        /// <param name="architecture">The architecture string.</param>
        /// <param name="input">The input count.</param>
        /// <param name="output">The output count.</param>
        /// <returns>The newly created SVM.</returns>
        public IMLMethod Create(String architecture, int input,
                               int output)
        {
            IList<String> layers = ArchitectureParse.ParseLayers(architecture);
            if (layers.Count != MAX_LAYERS)
            {
                throw new EncogError(
                    "SVM's must have exactly three elements, separated by ->.");
            }

            ArchitectureLayer inputLayer = ArchitectureParse.ParseLayer(
                layers[0], input);
            ArchitectureLayer paramsLayer = ArchitectureParse.ParseLayer(
                layers[1], input);
            ArchitectureLayer outputLayer = ArchitectureParse.ParseLayer(
                layers[2], output);

            String name = paramsLayer.Name;
            String kernelStr = paramsLayer.Params["KERNEL"];
            String svmTypeStr = paramsLayer.Params["TYPE"];

            SVMType svmType = SVMType.NewSupportVectorClassification;
            KernelType kernelType = KernelType.RadialBasisFunction;

            bool useNew = true;

            if (svmTypeStr == null)
            {
                useNew = true;
            }
            else if (svmTypeStr.Equals("NEW", StringComparison.InvariantCultureIgnoreCase))
            {
                useNew = true;
            }
            else if (svmTypeStr.Equals("OLD", StringComparison.InvariantCultureIgnoreCase))
            {
                useNew = false;
            }
            else
            {
                throw new EncogError("Unsupported type: " + svmTypeStr
                                     + ", must be NEW or OLD.");
            }

            if (name.Equals("C", StringComparison.InvariantCultureIgnoreCase))
            {
                if (useNew)
                {
                    svmType = SVMType.NewSupportVectorClassification;
                }
                else
                {
                    svmType = SVMType.SupportVectorClassification;
                }
            }
            else if (name.Equals("R", StringComparison.InvariantCultureIgnoreCase))
            {
                if (useNew)
                {
                    svmType = SVMType.NewSupportVectorRegression;
                }
                else
                {
                    svmType = SVMType.EpsilonSupportVectorRegression;
                }
            }
            else
            {
                throw new EncogError("Unsupported mode: " + name
                                     + ", must be C for classify or R for regression.");
            }

            if (kernelStr == null)
            {
                kernelType = KernelType.RadialBasisFunction;
            }
            else if ("linear".Equals(kernelStr, StringComparison.InvariantCultureIgnoreCase))
            {
                kernelType = KernelType.Linear;
            }
            else if ("poly".Equals(kernelStr, StringComparison.InvariantCultureIgnoreCase))
            {
                kernelType = KernelType.Poly;
            }
            else if ("precomputed".Equals(kernelStr, StringComparison.InvariantCultureIgnoreCase))
            {
                kernelType = KernelType.Precomputed;
            }
            else if ("rbf".Equals(kernelStr, StringComparison.InvariantCultureIgnoreCase))
            {
                kernelType = KernelType.RadialBasisFunction;
            }
            else if ("sigmoid".Equals(kernelStr, StringComparison.InvariantCultureIgnoreCase))
            {
                kernelType = KernelType.Sigmoid;
            }
            else
            {
                throw new EncogError("Unsupported kernel: " + kernelStr
                                     + ", must be linear,poly,precomputed,rbf or sigmoid.");
            }

            int inputCount = inputLayer.Count;
            int outputCount = outputLayer.Count;

            if (outputCount != 1)
            {
                throw new EncogError("SVM can only have an output size of 1.");
            }

            var result = new SupportVectorMachine(inputCount, svmType, kernelType);

            return result;
        }
コード例 #22
0
ファイル: SVMPattern.cs プロジェクト: neismit/emds
 /// <returns>The generated network.</returns>
 public IMLMethod Generate()
 {
     if (_outputNeurons != 1)
     {
         throw new PatternError("A SVM may only have one output.");
     }
     var network = new SupportVectorMachine(_inputNeurons, _svmType,
                                            _kernelType);
     return network;
 }
コード例 #23
0
 public static SupportVectorMachine createNetwork()
 {
     SupportVectorMachine network = new SupportVectorMachine(WINDOW_SIZE,true);
     return network;
 }