当前位置: 首页>>代码示例>>C#>>正文


C# BasicMLDataSet.Add方法代码示例

本文整理汇总了C#中BasicMLDataSet.Add方法的典型用法代码示例。如果您正苦于以下问题:C# BasicMLDataSet.Add方法的具体用法?C# BasicMLDataSet.Add怎么用?C# BasicMLDataSet.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BasicMLDataSet的用法示例。


在下文中一共展示了BasicMLDataSet.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RandomTrainerMethod

        /// <summary>
        /// Trains a random trainer.
        /// </summary>
        /// <param name="inputs">The inputs.</param>
        /// <param name="predictWindow">The predict window.</param>
        public static void RandomTrainerMethod(int inputs, int predictWindow)
        {
            double[] firstinput = MakeInputs(inputs);
            double[] SecondInput = MakeInputs(inputs);
            double[] ThirdInputs = MakeInputs(inputs);
            double[] FourthInputs = MakeInputs(inputs);
            var pair = SuperUtilsTrainer.ProcessPairs(firstinput, FourthInputs, inputs, predictWindow);
            var pair2 = SuperUtilsTrainer.ProcessPairs(SecondInput, FourthInputs, inputs, predictWindow);
            var pair3 = SuperUtilsTrainer.ProcessPairs(ThirdInputs, FourthInputs, inputs, predictWindow);
            var pair4 = SuperUtilsTrainer.ProcessPairs(FourthInputs, FourthInputs, inputs, predictWindow);
            BasicMLDataSet SuperSet = new BasicMLDataSet();
            SuperSet.Add(pair);
            SuperSet.Add(pair2);
            SuperSet.Add(pair3);
            SuperSet.Add(pair4);

            SupportVectorMachine machine = Create(SuperSet, inputs);
            SVMTrain train = new SVMTrain(machine, SuperSet);

            ///  var network = (BasicNetwork)CreateEval.CreateElmanNetwork(SuperSet.InputSize, SuperSet.IdealSize);
            //double error = CreateEval.TrainNetworks(machine, SuperSet);

            TrainSVM(train, machine);

            //Lets create an evaluation.
            // Console.WriteLine(@"Last error rate on random trainer:" + error);
        }
开发者ID:JDFagan,项目名称:encog-dotnet-core,代码行数:32,代码来源:CreateSVMNetWork.cs

示例2: LoadCSVTOMemory

        /// <summary>
        /// Load a CSV file into a memory dataset.  
        /// </summary>
        ///
        /// <param name="format">The CSV format to use.</param>
        /// <param name="filename">The filename to load.</param>
        /// <param name="headers">True if there is a header line.</param>
        /// <param name="inputSize">The input size.  Input always comes first in a file.</param>
        /// <param name="idealSize">The ideal size, 0 for unsupervised.</param>
        /// <returns>A NeuralDataSet that holds the contents of the CSV file.</returns>
        public static IMLDataSet LoadCSVTOMemory(CSVFormat format, String filename,
                                                bool headers, int inputSize, int idealSize)
        {
            var result = new BasicMLDataSet();
            var csv = new ReadCSV(filename, headers, format);
            while (csv.Next())
            {
                BasicMLData ideal = null;
                int index = 0;

                var input = new BasicMLData(inputSize);
                for (int i = 0; i < inputSize; i++)
                {
                    double d = csv.GetDouble(index++);
                    input[i] = d;
                }

                if (idealSize > 0)
                {
                    ideal = new BasicMLData(idealSize);
                    for (int i = 0; i < idealSize; i++)
                    {
                        double d = csv.GetDouble(index++);
                        ideal[i] = d;
                    }
                }

                IMLDataPair pair = new BasicMLDataPair(input, ideal);
                result.Add(pair);
            }

            return result;
        }
开发者ID:jongh0,项目名称:MTree,代码行数:43,代码来源:TrainingSetUtil.cs

示例3: Execute

        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));
        }
开发者ID:JDFagan,项目名称:encog-dotnet-core,代码行数:34,代码来源:HopfieldSimple.cs

示例4: Generate

        /// <summary>
        /// Generate a random training set. 
        /// </summary>
        /// <param name="seed">The seed value to use, the same seed value will always produce
        /// the same results.</param>
        /// <param name="count">How many training items to generate.</param>
        /// <param name="inputCount">How many input numbers.</param>
        /// <param name="idealCount">How many ideal numbers.</param>
        /// <param name="min">The minimum random number.</param>
        /// <param name="max">The maximum random number.</param>
        /// <returns>The random training set.</returns>
        public static BasicMLDataSet Generate(long seed,
                                              int count, int inputCount,
                                              int idealCount, double min, double max)
        {
            var rand =
                new LinearCongruentialGenerator(seed);

            var result = new BasicMLDataSet();
            for (int i = 0; i < count; i++)
            {
                IMLData inputData = new BasicMLData(inputCount);

                for (int j = 0; j < inputCount; j++)
                {
                    inputData.Data[j] = rand.Range(min, max);
                }

                IMLData idealData = new BasicMLData(idealCount);

                for (int j = 0; j < idealCount; j++)
                {
                    idealData[j] = rand.Range(min, max);
                }

                var pair = new BasicMLDataPair(inputData,
                                               idealData);
                result.Add(pair);
            }
            return result;
        }
开发者ID:encog,项目名称:encog-silverlight-core,代码行数:41,代码来源:RandomTrainingFactory.cs

示例5: LoadCSVToDataSet

        public static IMLDataSet LoadCSVToDataSet(FileInfo fileInfo, int inputCount, int outputCount, bool randomize = true, bool headers = true)
        {
            BasicMLDataSet result = new BasicMLDataSet();
            CultureInfo CSVformat = new CultureInfo("en");

            using (TextFieldParser parser = new TextFieldParser(fileInfo.FullName))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");
                if (headers)
                    parser.ReadFields();
                while (!parser.EndOfData)
                {
                    //Processing row
                    string[] fields = parser.ReadFields();
                    var input = new BasicMLData(inputCount);
                    for (int i = 0; i < inputCount; i++)
                        input[i] = double.Parse(fields[i], CSVformat);
                    var ideal = new BasicMLData(outputCount);
                    for (int i = 0; i < outputCount; i++)
                        ideal[i] = double.Parse(fields[i + inputCount], CSVformat);
                    result.Add(input, ideal);
                }
            }
            var rand = new Random(DateTime.Now.Millisecond);

            return (randomize ? new BasicMLDataSet(result.OrderBy(r => rand.Next()).ToList()) : new BasicMLDataSet(result));
        }
开发者ID:JGrzybowski,项目名称:NeuralNetworksSmallProject,代码行数:28,代码来源:CSVHelper.cs

示例6: CreateDataSet

        /// <summary>
        /// Create a dataset from the clustered data. 
        /// </summary>
        /// <returns>The dataset.</returns>
        public IMLDataSet CreateDataSet()
        {
            var result = new BasicMLDataSet();

            foreach (IMLData dataItem in _data)
            {
                result.Add(dataItem);
            }

            return result;
        }
开发者ID:johannsutherland,项目名称:encog-dotnet-core,代码行数:15,代码来源:BasicCluster.cs

示例7: RandomTrainerMethod

        /// <summary>
        /// Trains a random trainer.
        /// </summary>
        /// <param name="inputs">The inputs.</param>
        /// <param name="predictWindow">The predict window.</param>
        public static double RandomTrainerMethod(int inputs, int predictWindow)
        {
            double[] firstinput = MakeInputs(inputs);
            double[] SecondInput = MakeInputs(inputs);
            double[] ThirdInputs = MakeInputs(inputs);
            double[] FourthInputs = MakeInputs(inputs);
            double[] inp5 = MakeInputs(inputs);
            double[] inp6 = MakeInputs(inputs);

            var pair = TrainerHelper.ProcessPairs(firstinput, firstinput, inputs, predictWindow);
            var pair2 = TrainerHelper.ProcessPairs(SecondInput, firstinput, inputs, predictWindow);
            var pair3 = TrainerHelper.ProcessPairs(ThirdInputs, firstinput, inputs, predictWindow);
            var pair4 = TrainerHelper.ProcessPairs(FourthInputs, firstinput, inputs, predictWindow);
            var pair5 = TrainerHelper.ProcessPairs(inp5, firstinput, inputs, predictWindow);
            var pair6 = TrainerHelper.ProcessPairs(inp6, firstinput, inputs, predictWindow);
            BasicMLDataSet SuperSet = new BasicMLDataSet();
            SuperSet.Add(pair);
            SuperSet.Add(pair2);

            SuperSet.Add(pair3);
            SuperSet.Add(pair4);
            var network = new BasicNetwork();
            network.AddLayer(new BasicLayer(new ActivationTANH(), true, SuperSet.InputSize));
            network.AddLayer(new BasicLayer(new ActivationTANH(), false, 20));
            network.AddLayer(new BasicLayer(new ActivationTANH(), true, 0));
            network.AddLayer(new BasicLayer(new ActivationLinear(), true, predictWindow));

            //var layer = new BasicLayer(new ActivationTANH(), true, SuperSet.InputSize);
            //layer.Network = network;


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


            // var network = (BasicNetwork)CreateEval.CreateElmanNetwork(SuperSet.InputSize, SuperSet.IdealSize);
            return CreateEval.TrainNetworks(network, SuperSet);
            //Lets create an evaluation.
            //Console.WriteLine(@"Last error rate on random trainer:" + error);

        }
开发者ID:jongh0,项目名称:MTree,代码行数:46,代码来源:RandomTrainer.cs

示例8: PSO

        public PSO()
        {
            network = new BasicNetwork();
            network.AddLayer(new BasicLayer(5));
            network.AddLayer(new BasicLayer(1));
            network.AddLayer(new BasicLayer(1));
            network.Structure.FinalizeStructure();
            network.Reset();

            IMLDataSet dataSet = new BasicMLDataSet();
            dataSet.Add(new BasicMLData(new double[] { 1.0, 4.0, 3.0, 4.0, 5.0}) , new BasicMLData(new double[] { 2.0, 4.0, 6.0 , 8.0, 10} ));
            
            train = new NeuralPSO(network, new RangeRandomizer(0, 10), new TrainingSetScore(dataSet),5);
            
        }
开发者ID:ifzz,项目名称:QuantSys,代码行数:15,代码来源:PSO.cs

示例9: GenerateSingleDataRange

        public static IMLDataSet GenerateSingleDataRange(EncogFunction task, double start, double stop, double step)
        {
            BasicMLDataSet result = new BasicMLDataSet();
            double current = start;

            while (current <= stop)
            {
                BasicMLData input = new BasicMLData(1);
                input[0] = current;
                BasicMLData ideal = new BasicMLData(1);
                ideal[0] = task(current);
                result.Add(input, ideal);
                current += step;
            }

            return result;
        }
开发者ID:benw408701,项目名称:MLHCTransactionPredictor,代码行数:17,代码来源:GenerationUtil.cs

示例10: CreateNoisyXORDataSet

 public static IMLDataSet CreateNoisyXORDataSet(int count)
 {
     var result = new BasicMLDataSet();
     for (int i = 0; i < count; i++)
     {
         for (int j = 0; j < 4; j++)
         {
             var inputData = new BasicMLData(XORInput[j]);
             var idealData = new BasicMLData(XORIdeal[j]);
             var pair = new BasicMLDataPair(inputData, idealData);
             inputData[0] = inputData[0] + RangeRandomizer.Randomize(-0.1, 0.1);
             inputData[1] = inputData[1] + RangeRandomizer.Randomize(-0.1, 0.1);
             result.Add(pair);
         }
     }
     return result;
 }
开发者ID:jongh0,项目名称:MTree,代码行数:17,代码来源:XOR.cs

示例11: TestCluster

        public void TestCluster()
        {
            var set = new BasicMLDataSet();

            int i;
            for (i = 0; i < Data.Length; i++)
            {
                set.Add(new BasicMLData(Data[i]));
            }

            var kmeans = new KMeansClustering(2, set);
            kmeans.Iteration();

            i = 1;
            foreach (IMLCluster cluster in kmeans.Clusters)
            {
                IMLDataSet ds = cluster.CreateDataSet();
                IMLDataPair pair;
                pair = ds[0];
                double t = pair.Input[0];

                for (int j = 0; j < ds.Count; j++)
                {
                    pair = ds[j];

                    for (j = 0; j < pair.Input.Count; j++)
                    {
                        if (t > 10)
                        {
                            Assert.IsTrue(pair.Input[j] > 10);
                        }
                        else
                        {
                            Assert.IsTrue(pair.Input[j] < 10);
                        }
                    }
                }

                i++;
            }
        }
开发者ID:kedrzu,项目名称:encog-dotnet-core,代码行数:41,代码来源:TestKMeans.cs

示例12: TestCluster

        public void TestCluster()
        {
            var set = new BasicMLDataSet();

            int i;
            for (i = 0; i < Data.Length; i++)
            {
                set.Add(new BasicMLData(Data[i]));
            }

            var kmeans = new KMeansClustering(2, set);
            kmeans.Iteration();

            i = 1;
            foreach (IMLCluster cluster in kmeans.Clusters)
            {
                IMLDataSet ds = cluster.CreateDataSet();
                IMLDataPair pair = BasicMLDataPair.CreatePair(ds.InputSize, ds.IdealSize);
                ds.GetRecord(0, pair);
                double t = pair.InputArray[0];

                for (int j = 0; j < ds.Count; j++)
                {
                    ds.GetRecord(j, pair);

                    for (j = 0; j < pair.InputArray.Length; j++)
                    {
                        if (t > 10)
                        {
                            Assert.IsTrue(pair.InputArray[j] > 10);
                        }
                        else
                        {
                            Assert.IsTrue(pair.InputArray[j] < 10);
                        }
                    }
                }

                i++;
            }
        }
开发者ID:firestrand,项目名称:encog-dotnet-core,代码行数:41,代码来源:TestKMeans.cs

示例13: ProcessDoubleSerieIntoIMLDataset

        /// <summary>
        /// Processes the specified double serie into an IMLDataset.
        /// To use this method, you must provide a formated double array.
        /// The number of points in the input window makes the input array , and the predict window will create the array used in ideal.
        /// Example you have an array with 1, 2, 3 , 4 , 5.
        /// You can use this method to make an IMLDataset 4 inputs and 1 ideal (5).
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="_inputWindow">The _input window.</param>
        /// <param name="_predictWindow">The _predict window.</param>
        /// <returns></returns>
        public static IMLDataSet ProcessDoubleSerieIntoIMLDataset(double[] data, int _inputWindow, int _predictWindow)
        {
            var result = new BasicMLDataSet();
            int totalWindowSize = _inputWindow + _predictWindow;
            int stopPoint = data.Length - totalWindowSize;
            for (int i = 0; i < stopPoint; i++)
            {
                var inputData = new BasicMLData(_inputWindow);
                var idealData = new BasicMLData(_predictWindow);
                int index = i;
                // handle input window
                for (int j = 0; j < _inputWindow; j++)
                {
                    inputData[j] = data[index++];
                }

                // handle predict window
                for (int j = 0; j < _predictWindow; j++)
                {
                    idealData[j] = data[index++];
                }
                var pair = new BasicMLDataPair(inputData, idealData);
                result.Add(pair);
            }

            return result;
        }
开发者ID:Romiko,项目名称:encog-dotnet-core,代码行数:38,代码来源:TrainerHelper.cs

示例14: MakeRandomIMLDataset

 /// <summary>
 /// Makes a random dataset with the number of IMLDatapairs.
 /// Quite useful to test networks (benchmarks).
 /// </summary>
 /// <param name="inputs">The inputs.</param>
 /// <param name="predictWindow">The predict window.</param>
 /// <param name="numberofPairs">The numberof pairs.</param>
 /// <returns></returns>
 public static BasicMLDataSet MakeRandomIMLDataset(int inputs, int predictWindow, int numberofPairs)
 {
     BasicMLDataSet SuperSet = new BasicMLDataSet();
     for (int i = 0; i < numberofPairs;i++ )
     {
         double[] firstinput = MakeInputs(inputs);
         double[] secondideal = MakeInputs(inputs);
         IMLDataPair pair = ProcessPairs(firstinput, secondideal, inputs, predictWindow);
         SuperSet.Add(pair);
     }
     return SuperSet;
 }
开发者ID:Romiko,项目名称:encog-dotnet-core,代码行数:20,代码来源:TrainerHelper.cs

示例15: xa1aa8795de6d838b

 public int xa1aa8795de6d838b()
 {
     Matrix matrix;
     int num;
     double num2;
     double num3;
     double num4;
     double num5;
     double num6;
     ChartWindow window2;
     Func<double, Tuple<double, bool>> func = null;
     <>c__DisplayClass10 class2;
     int num7;
     bool flag;
     if (((uint) num3) >= 0)
     {
         double mo;
         this.x20aee281977480cf();
         this.x0fc00f08bd4749a0();
         double[] res = new double[this.x6b73aa01aa019d3a.Count];
         goto Label_02AD;
     }
     if ((((uint) num4) - ((uint) num)) >= 0)
     {
         goto Label_007B;
     }
     Label_0030:
     num7 = res.ToList<double>().IndexOf(res.Max());
     if ((((uint) num5) | 4) == 0)
     {
         goto Label_01C5;
     }
     return num7;
     Label_007B:
     if ((((uint) num4) | 0x7fffffff) == 0)
     {
         goto Label_01FF;
     }
     ChartWindow window = window2;
     if (func == null)
     {
         func = new Func<double, Tuple<double, bool>>(class2, this.<FindMavericNsim41>b__e);
     }
     window.barSeries.ItemsSource = Enumerable.Select<double, Tuple<double, bool>>(res, func);
     window.barSeries.IsSelectionEnabled = false;
     window.ShowDialog();
     goto Label_0030;
     Label_017F:
     num6 = res.Max();
     num = 0;
     Label_0197:
     flag = num < res.Length;
     Label_0148:
     if (flag)
     {
         num++;
         goto Label_0197;
     }
     this.xdc3df58d08a8655f();
     if ((((uint) flag) & 0) != 0)
     {
         goto Label_0258;
     }
     flag = !this.xf69244535d02f4b9;
     if (!flag)
     {
         window2 = new ChartWindow {
             chart = { Title = "Обнаружение выбросов" }
         };
         if ((((uint) num5) & 0) != 0)
         {
             return num7;
         }
         if (((uint) num6) <= uint.MaxValue)
         {
             goto Label_007B;
         }
         goto Label_0148;
     }
     if ((((uint) num) - ((uint) num2)) >= 0)
     {
         goto Label_0030;
     }
     return num7;
     Label_01C5:
     num5 = Math.Sqrt(Enumerable.Select<double, double>(res, new Func<double, double>(class2, (IntPtr) this.<FindMavericNsim41>b__d)).Sum() / ((double) res.Length));
     goto Label_017F;
     Label_01FF:
     flag = num < this.x6b73aa01aa019d3a.Count;
     if ((((uint) num) + ((uint) num6)) < 0)
     {
         goto Label_017F;
     }
     if (flag)
     {
         this.x993b9ddd2c3f1688(num);
         BasicMLDataPair inputData = this.x6b73aa01aa019d3a.Data[num].Clone() as BasicMLDataPair;
         BasicMLDataSet data = new BasicMLDataSet();
         data.Add(inputData);
         num2 = this.x5b0926ce641e48a7.CalculateError(data);
//.........这里部分代码省略.........
开发者ID:neismit,项目名称:emds,代码行数:101,代码来源:x5e7825063a2681aa.cs


注:本文中的BasicMLDataSet.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。