示例#1
0
        private void PrintOutputGraph_1stOfEach()
        {
            var input    = new PointCollection();
            var output   = new PointCollection();
            var expected = new PointCollection();

            for (var i = 0; i < _trainingData["Inputs"].Count; i++)
            {
                input.Add(new Point(i, _trainingData["Inputs"][i][0]));
                output.Add(new Point(i, _nn.GenerateOutput(_trainingData["Inputs"][i])[0]));
                expected.Add(new Point(i, _trainingData["Outputs"][i][0]));
            }

            OutputPlot.LineThickness = 2.5;
            OutputPlot.ScaleXAxis    = true;
            OutputPlot.Add("Input", input, Colors.Black);
            OutputPlot.Add("Expected", expected, Colors.White);
            OutputPlot.Add("Output", output, Colors.Purple);
        }
示例#2
0
        private void TestNN()
        {
            var testingData = new List <List <double> >();

            var testingDataJson = Common.GetJsonFromFile();

            foreach (JArray testSet in testingDataJson["Inputs"])
            {
                var ts = new List <double>();
                for (var i = 0; i < testSet.Count(); ++i)
                {
                    ts.Add(testSet[i].Value <double>());
                }
                testingData.Add(ts);
            }

            _trainingDataMeta = testingDataJson["Meta"] as JObject;
            var outputOffset = _trainingDataMeta["OutputOffset"].Value <int>();
            var outputSize   = _trainingDataMeta["OutputSize"].Value <int>();
            var inputSize    = _trainingDataMeta["InputSize"].Value <int>();

            var inputPoints  = new PointCollection();
            var outputPoints = new PointCollection();

            for (var i = 0; i < testingData.Count; i++)
            {
                for (var j = 0; j < inputSize; ++j)
                {
                    var input  = testingData[i][j];
                    var output = j < outputSize?_nn.GenerateOutput(testingData[i])[j] : 0;

                    inputPoints.Add(new Point(i * inputSize + j, input));
                    outputPoints.Add(new Point(i * inputSize + j + outputOffset, output));
                }
            }

            OutputPlot.Clear();
            OutputPlot.LineThickness = 2.5;
            OutputPlot.ScaleXAxis    = true;
            OutputPlot.Add("Input", inputPoints, Colors.White);
            OutputPlot.Add("Output", outputPoints, Colors.Purple);
        }
示例#3
0
        private void XOnDataAvailable(object sender, WaveInEventArgs e)
        {
            var spectrum_cp = new PointCollection();

            var buff = new double[1024];

            for (var i = 0; i < buff.Length; ++i)
            {
                buff[i] = e.Buffer[i];
            }

            var spectrum = DSP.FourierTransform.Spectrum(ref buff);

            for (var i = 0; i < spectrum.Length; ++i)
            {
                spectrum_cp.Add(new Point(i, spectrum[i]));
            }

            OutputPlot.Add("Spectrum", spectrum_cp, Colors.White);
        }
示例#4
0
        private async Task ShowStock(string stock)
        {
            try
            {
                var mongo            = new MongoClient("mongodb://localhost:27017");
                var db               = mongo.GetDatabase("traiding_data");
                var stockCollections = new List <string>();
                using (var cursor = await db.ListCollectionNamesAsync())
                {
                    await cursor.ForEachAsync(d => stockCollections.Add(d.ToString()));
                }


                if (!stockCollections.Contains(stock))
                {
                    MessageBox.Show($"{stock} collection doesn't exist!");
                    return;
                }

                var collection = db.GetCollection <StockData>(stock);
                var res        = (from c in collection.AsQueryable() orderby c.Date descending select c).ToList();

                var pc = new PointCollection();
                for (var i = 0; i < res.Count; ++i)
                {
                    pc.Add(new Point(i, res[i].Close - res[i].Low));
                }

                OutputPlot.Clear();
                OutputPlot.Add(stock, pc, Colors.White);
                MainTabControl_tc.SelectedItem = OutputGraph_Tab_ti;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
示例#5
0
        private void PrintOutputGraph_AllOfEach()
        {
            var outputOffset = _trainingDataMeta["OutputOffset"].Value <int>();
            var input        = new PointCollection();
            var output       = new PointCollection();
            var expected     = new PointCollection();
            var sampleCount  = _trainingData["Inputs"].Count;

            for (var i = 0; i < sampleCount; i++)
            {
                var inputSize  = _trainingData["Inputs"][i].Count;
                var outputSize = _trainingData["Outputs"][i].Count;
                for (var j = 0; j < inputSize; ++j)
                {
                    input.Add(new Point(i * inputSize + j, _trainingData["Inputs"][i][j]));
                }

                for (var j = 0; j < inputSize; ++j)
                {
                    output.Add(new Point(i * inputSize + j + outputOffset,
                                         j < outputSize ? _nn.GenerateOutput(_trainingData["Inputs"][i])[j] : 0));
                }

                for (var j = 0; j < inputSize; j++)
                {
                    expected.Add(new Point(i * inputSize + j + outputOffset,
                                           j < outputSize ? _trainingData["Outputs"][i][j] : 0));
                }
            }

            OutputPlot.LineThickness = 2.5;
            OutputPlot.ScaleXAxis    = true;
            OutputPlot.Add("Input", input, Colors.Black);
            OutputPlot.Add("Expected", expected, Colors.White);
            OutputPlot.Add("Output", output, Colors.Purple);
        }