Example #1
0
        static void Main(string[] args)
        {
            string        fileName     = @"E:\PROJECT\FINAL PROJECT\Other\Test\airpass.dat";
            List <double> originSeries = new List <double>();

            System.IO.StreamReader file = null;
            string line = null;

            try
            {
                file = new System.IO.StreamReader(fileName);
                while ((line = file.ReadLine()) != null)
                {
                    originSeries.Add(Double.Parse(line));
                }
            }
            catch (System.OutOfMemoryException outOfMemory)
            {
                originSeries = null;
            }

            ARIMA arima = new ARIMA();

            arima.SetData(originSeries);
            arima.Run();
        }
Example #2
0
        public void AutoRegression_Test01()
        {
            var lst = nc.GenerateIntSeries(1, 11, 1);
            //create series from the list
            var ser = new Series(lst);
            var ar  = new ARIMA();

            var coeff = ar.AR(ser, 2);

            Assert.Equal(new float[3] {
                1.91f, 0.91f, 0.09f
            }, coeff.Select(x => Convert.ToSingle(Math.Round((double)x, 2))));
        }
Example #3
0
        public void ARIMA_AR_Test01()
        {
            var df    = DataFrame.FromCsv(filePath: $"../../../testdata/earth_quake.txt", sep: '\t', names: null, parseDate: false);
            var newDf = df.SetIndex("Year");
            var ts    = Series.FromDataFrame(newDf, "Quakes");
            //
            DataFrame tsdf = ts.TSToDataFrame(lags: 3);

            var arima = new ARIMA();
            var args  = arima.AR(ts, 3);

            //MagmaSharp.LinAlg.Lss()
        }
Example #4
0
        public static void ARIMA_Test01()
        {
            var df = Daany.DataFrame.FromCsv(filePath: $"AirPassengers.csv",
                                             sep: ',', names: null, parseDate: false);
            ////
            var ts = df.ToSeries("#Passengers");            //create time series

            int p     = 1;
            int d     = 1;
            int q     = 1;
            var model = new ARIMA(p, d, q);

            model.Fit(ts);
        }
Example #5
0
        static void Main(string[] args)
        {
            string fileName = @"E:\PROJECT\FINAL PROJECT\Other\Test\airpass.dat";
            List<double> originSeries = new List<double>();
            System.IO.StreamReader file = null;
            string line = null;
            try
            {
                file = new System.IO.StreamReader(fileName);
                while ((line = file.ReadLine()) != null)
                {
                    originSeries.Add(Double.Parse(line));
                }
            }
            catch (System.OutOfMemoryException outOfMemory)
            {
                originSeries = null;
            }

            ARIMA arima = new ARIMA();
            arima.SetData(originSeries);
            arima.Run();
        }
 private void InitData()
 {
     _trainDataSeries = new List<double>();
     _testDataSeries = new List<double>();
     _dataForTest = new List<double>();
     _dataForForecast = new List<double>();
     modelType = ModelType.SARIMA_ANN;
     isReadTrainData = false;
     isReadTestData = false;
     ARIMAModel = new ARIMA();
     NeuralModel = new Neural();
 }
 private void InitData()
 {
     _dataSeries = new List<double>();
     _errorSeries = new List<double>();
     ARIMAModel = new ARIMA();
     NeuralModel = new Neural();
 }
        private void btnGetData_Click(object sender, EventArgs e)
        {
            _dataSeries = new List<double>();
            System.IO.StreamReader file = null;
            string line = null;
            bool isFormatFileRight = true;
            int beginRow = Convert.ToInt32(this.txtTrainDataFromRow.Text);
            int endRow = Convert.ToInt32(this.txtTrainDataToRow.Text);
            int columnSelected = Convert.ToInt32(this.txtTrainDataColumn.Text);
            int idxRow = 0;
            try
            {
                file = new System.IO.StreamReader(m_TrainingDataFile);
                while ((line = file.ReadLine()) != null)
                {
                    idxRow++;
                    if (idxRow < beginRow || idxRow > endRow)
                        continue;

                    char[] delimiterChars = { ' ', ',' };
                    List<String> words = new List<string>();
                    words.AddRange(line.Split(delimiterChars));
                    words.RemoveAll(item => "" == item);

                    if (columnSelected <= words.Count)
                    {
                        _dataSeries.Add(Double.Parse(words[columnSelected - 1]));
                    }
                    else
                    {
                        isFormatFileRight = false;
                        break;
                    }
                }
                if (!isFormatFileRight)
                {
                    MessageBox.Show("Input is wrong format", null, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _dataSeries = null;
                }
            }
            catch (System.OutOfMemoryException outOfMemory)
            {
                _dataSeries = null;
                MessageBox.Show("File does not found", null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (System.IO.IOException io)
            {
                _dataSeries = null;
                MessageBox.Show("File does not found", null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (System.Exception excp)
            {
                _dataSeries = null;
                MessageBox.Show("Input is wrong format", null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (file != null)
                    file.Close();
            }

            if (_dataSeries != null)
            {
                SettingGetData();
                ARIMAModel = new ARIMA();
                NeuralModel = new Neural();
                ARIMAModel.SetData(_dataSeries);
            }
            else
            {
                MessageBox.Show("Load data fail", null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }