private void btnForecastARIMA_Click(object sender, EventArgs e)
        {
            List <double> forecastSeries;
            int           aHead       = 0;
            AHead_Form    aHeadDialog = new AHead_Form();

            if (aHeadDialog.ShowDialog() == DialogResult.OK)
            {
                aHead = aHeadDialog.GetAHead();
            }
            aHeadDialog.Dispose();
            if (aHead > 0)
            {
                //ARIMAModel.Forecast(aHead, out forecastSeries);
                //Statistic.DrawForecastSeriesData(_dataSeries, 0, forecastSeries, 0);
            }
            else
            {
                MessageBox.Show(this, "Please enter input in correct format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnForecastNeural_Click(object sender, EventArgs e)
        {
            //NeuralModel.Forecast(30);
            List <double> forecastSeries;
            int           aHead       = 0;
            AHead_Form    aHeadDialog = new AHead_Form();

            if (aHeadDialog.ShowDialog() == DialogResult.OK)
            {
                // Read the contents of testDialog's TextBox.
                aHead = aHeadDialog.GetAHead();
            }
            aHeadDialog.Dispose();
            if (aHead > 0)
            {
                NeuralModel.Forecast(aHead, out forecastSeries);
                Statistic.DrawForecastSeriesData(_errorSeries, 0, forecastSeries, 0);
            }
            else
            {
                MessageBox.Show(this, "Please enter input in correct format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        private void btnForecast_Click(object sender, EventArgs e)
        {
            List<double> forecastResultARIMASeries = new List<double>();
            List<double> testResultARIMASeries = new List<double>();
            List<double> testErrorARIMASeries = new List<double>();
            List<double> forecastResultNeuralSeries = new List<double>();
            List<double> forecastDataNeuralSeries = new List<double>();

            List<double> forecastResultSeries = new List<double>();
            int aHead = 0;
            AHead_Form aHeadDialog = new AHead_Form();

            if (aHeadDialog.ShowDialog() == DialogResult.OK)
            {
                aHead = aHeadDialog.GetAHead();
            }
            aHeadDialog.Dispose();

            if (aHead <= 0)
            {
                MessageBox.Show(this, "Please enter input in correct format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ARIMAModel.Forecast(_dataForForecast, aHead, out forecastResultARIMASeries);

            ARIMAModel.ComputeTestingResult(_dataForForecast, out testResultARIMASeries);
            for (int i = 0; i < _dataForForecast.Count; i++)
            {
                testErrorARIMASeries.Add(_dataForForecast[i] - testResultARIMASeries[i]);
            }

            for (int i = 0; i < NeuralModel.GetNumDataForInput(); i++)
            {
                forecastDataNeuralSeries.Add(testErrorARIMASeries[testErrorARIMASeries.Count - NeuralModel.GetNumDataForInput() + i]);
            }

            NeuralModel.Forecast(forecastDataNeuralSeries, aHead, out forecastResultNeuralSeries);
            for (int i = 0; i < forecastResultARIMASeries.Count; i++)
            {
                forecastResultSeries.Add(forecastResultARIMASeries[i] + forecastResultNeuralSeries[i]);
            }

            //Draw forecast result
            chartForecast.Series.Clear();
            System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
            series1.ChartArea = "ChartArea1";
            series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            series1.Color = System.Drawing.Color.Blue;
            series1.IsVisibleInLegend = false;

            System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
            series2.ChartArea = "ChartArea1";
            series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            series2.Color = System.Drawing.Color.Red;
            series2.IsVisibleInLegend = false;

            for (int i = 0; i < _dataForForecast.Count; i++)
            {
                series1.Points.AddXY(i + 1, _dataForForecast[i]);
            }
            chartForecast.Series.Add(series1);

            series2.Points.AddXY(_dataForForecast.Count, _dataForForecast[_dataForForecast.Count - 1]);
            for (int i = 0; i < forecastResultSeries.Count; i++)
            {
                series2.Points.AddXY(_dataForForecast.Count + i + 1, forecastResultSeries[i]);
            }
            chartForecast.Series.Add(series2);

            StringBuilder result = new StringBuilder();
            result.Append(String.Format("Forecast data for {0} ahead time\n", aHead));
            for (int i = 0; i < forecastResultSeries.Count; i++)
            {
                result.Append(String.Format("  {0}\t{1}\n", i+1, String.Format("{0:0.###}", forecastResultSeries[i])));
            }

            this.richTextForecast.Text = result.ToString();
        }
Пример #4
0
        private void btnForecastNeural_Click(object sender, EventArgs e)
        {
            List<double> forecastResultNeuralSeries = new List<double>();
            List<double> forecastDataNeuralSeries = new List<double>();
            List<double> testResultARIMASeries = new List<double>();
            List<double> testErrorARIMASeries = new List<double>();
            int aHead = 0;
            AHead_Form aHeadDialog = new AHead_Form();

            if (aHeadDialog.ShowDialog() == DialogResult.OK)
            {
                aHead = aHeadDialog.GetAHead();
            }
            aHeadDialog.Dispose();

            if (aHead <= 0)
            {
                MessageBox.Show(this, "Please enter input in correct format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (modelType == ModelType.SARIMA_ANN)
            {
                ARIMAModel.ComputeTestingResult(_dataForForecast, out testResultARIMASeries);
                for (int i = 0; i < _dataForForecast.Count; i++)
                {
                    testErrorARIMASeries.Add(_dataForForecast[i] - testResultARIMASeries[i]);
                }

                for (int i = 0; i < NeuralModel.GetNumDataForInput(); i++)
                {
                    forecastDataNeuralSeries.Add(testErrorARIMASeries[testErrorARIMASeries.Count - NeuralModel.GetNumDataForInput() + i]);
                }

                NeuralModel.Forecast(forecastDataNeuralSeries, aHead, out forecastResultNeuralSeries);
                Statistic.DrawForecastSeriesData(testErrorARIMASeries, 0, forecastResultNeuralSeries, 0);
            }
            else
            {
                NeuralModel.Forecast(_dataForForecast, aHead, out forecastResultNeuralSeries);
                Statistic.DrawForecastSeriesData(_dataForForecast, 0, forecastResultNeuralSeries, 0);
            }
        }
Пример #5
0
        private void btnForecastARIMA_Click(object sender, EventArgs e)
        {
            List<double> forecastARIMASeries;
            int aHead = 0;
            AHead_Form aHeadDialog = new AHead_Form();

            if (aHeadDialog.ShowDialog() == DialogResult.OK)
            {
                aHead = aHeadDialog.GetAHead();
            }
            aHeadDialog.Dispose();

            if (aHead > 0)
            {
                ARIMAModel.Forecast(_dataForForecast, aHead, out forecastARIMASeries);
                Statistic.DrawForecastSeriesData(_dataForForecast, 0, forecastARIMASeries, 0);
            }
            else
            {
                MessageBox.Show(this, "Please enter input in correct format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #6
0
        private void btnForecastNeural_Click(object sender, EventArgs e)
        {
            //NeuralModel.Forecast(30);
            List<double> forecastSeries;
            int aHead = 0;
            AHead_Form aHeadDialog = new AHead_Form();

            if (aHeadDialog.ShowDialog() == DialogResult.OK)
            {
                // Read the contents of testDialog's TextBox.
                aHead = aHeadDialog.GetAHead();
            }
            aHeadDialog.Dispose();
            if (aHead > 0)
            {
                NeuralModel.Forecast(aHead, out forecastSeries);
                Statistic.DrawForecastSeriesData(_errorSeries, 0, forecastSeries, 0);
            }
            else
            {
                MessageBox.Show(this, "Please enter input in correct format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }