private void InitializeData()
        {
            TrainData.Clear();
            var outMin = double.MaxValue;
            var outMax = double.MinValue;

            for (var i = Min; i <= Max; i += Step)
            {
                var expected = Function(i);
                if (expected > outMax)
                {
                    outMax = expected;
                }
                if (expected < outMin)
                {
                    outMin = expected;
                }

                var point = new TrainingData {
                    Input = new Array3D(Normalize(i, Min, Max)), Expected = new Array3D(expected)
                };
                TrainData.Add(point);
            }

            foreach (var data in TrainData)
            {
                data.Expected[0] = Normalize(data.Expected[0], outMin, outMax);
            }

            TestData.Clear();
            for (var i = 0; i < TrainData.Count; i++)
            {
                var x = Rand.NextDouble() * (Max - Min) + Min;
                TestData.Add(new TrainingData {
                    Input = new Array3D(Normalize(x, Min, Max)), Expected = new Array3D(Normalize(Function(x), outMin, outMax))
                });
            }
        }
        public void SuffleData()
        {
            TestData.Clear();
            TrainData.Clear();

            foreach (var item in RawData)
            {
                if (Random.R.NextDouble(0, 1) < TestRatio)
                {
                    TestData.Add(item.Key, item.Value);
                }
                else
                {
                    TrainData.Add(item.Key, item.Value);
                }
            }

            if (TestData.Count == 0)
            {
                var item = TrainData.Last();
                TestData.Add(item.Key, item.Value);
                TrainData.Remove(item.Key);
            }
        }
示例#3
0
 private void AddAsTrainData(DataEntry entry)
 {
     TrainData.Add(entry);
     Vocabulary.AddRange(entry.stemmedClaim);
 }