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); } }