/// <summary> /// Initializes an ELM network for given configurations /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_CreateElm_Click(object sender, EventArgs e) { int inputDays = Int32.Parse(input_InputDays.Text); int outputDays = Int32.Parse(input_OutputDays.Text); dataOffset = outputDays; int hiddenLayerSize = Int32.Parse(input_HiddenLayerSize.Text); int trainPercentage = Int32.Parse(input_TrainPercentage.Text); int biasValue = Int32.Parse(input_BiasValue.Text); if (data != null) { elm = new ELM(inputDays, hiddenLayerSize, outputDays, biasValue, data, trainPercentage); if (elm != null) { button_Train.Enabled = true; } } else { MessageBox.Show("Please check your data", "ELM Creation Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Initializes the statistics window with the appropriate testing type /// </summary> /// <param name="type"></param> /// <param name="testOffset"></param> private void ShowStats(String type, int testOffset) { int inputDays = Int32.Parse(input_InputDays.Text); int outputDays = Int32.Parse(input_OutputDays.Text); int hiddenLayerSize = Int32.Parse(input_HiddenLayerSize.Text); int trainPercentage = Int32.Parse(input_TrainPercentage.Text); int biasValue = Int32.Parse(input_BiasValue.Text); dataOffset = outputDays; double[] openPriceArray = new double[testOffset]; double[] closePriceArray = new double[testOffset]; double[] highPriceArray = new double[testOffset];; double[] lowPriceArray = new double[testOffset]; double[] offsetArray = new double[testOffset]; for (int i = 1; i <= 10; i++) { ELM tempELM = new ELM(inputDays, hiddenLayerSize, outputDays, biasValue, data, trainPercentage); switch (type) { case "Input Days": tempELM = new ELM(i * testOffset, hiddenLayerSize, outputDays, biasValue, data, trainPercentage); break; case "Output Days": tempELM = new ELM(inputDays, hiddenLayerSize, i * testOffset, biasValue, data, trainPercentage); break; case "Hidden Layer Size": tempELM = new ELM(inputDays, i * testOffset, outputDays, biasValue, data, trainPercentage); break; case "Train Percentage": tempELM = new ELM(inputDays, hiddenLayerSize, outputDays, biasValue, data, i * testOffset); break; } tempELM.train(tempELM.Xtrain, tempELM.Ytrain); Matrix <double> tempPrediction = tempELM.predict(tempELM.Xtest); Matrix <double> tempTest = tempELM.Ytest; int tempBestIndex = GetBestIndex(tempPrediction, tempTest); double[] selectedPredSample = tempPrediction.Row(tempBestIndex).ToArray(); double[] selectedTestSample = tempTest.Row(tempBestIndex).ToArray(); double[] predOpenPrice = new ArraySegment <double>(selectedPredSample, 0, dataOffset).ToArray(); double[] predClosePrice = new ArraySegment <double>(selectedPredSample, dataOffset, dataOffset).ToArray(); double[] predHighPrice = new ArraySegment <double>(selectedPredSample, 2 * dataOffset, dataOffset).ToArray(); double[] predLowPrice = new ArraySegment <double>(selectedPredSample, 3 * dataOffset, dataOffset).ToArray(); double[] testOpenPrice = new ArraySegment <double>(selectedTestSample, 0, dataOffset).ToArray(); double[] testClosePrice = new ArraySegment <double>(selectedTestSample, dataOffset, dataOffset).ToArray(); double[] testHighPrice = new ArraySegment <double>(selectedTestSample, 2 * dataOffset, dataOffset).ToArray(); double[] testLowPrice = new ArraySegment <double>(selectedTestSample, 3 * dataOffset, dataOffset).ToArray(); double tempOpenPriceError = GetMeanSquare(predOpenPrice, testOpenPrice); double tempClosePriceError = GetMeanSquare(predClosePrice, testClosePrice); double tempHighPriceError = GetMeanSquare(predHighPrice, testHighPrice); double tempLowPriceError = GetMeanSquare(predLowPrice, testLowPrice); offsetArray[i - 1] = i * testOffset; openPriceArray[i - 1] = tempOpenPriceError; closePriceArray[i - 1] = tempClosePriceError; highPriceArray[i - 1] = tempHighPriceError; lowPriceArray[i - 1] = tempLowPriceError; } StatWindow inputStatWindow = new StatWindow(openPriceArray, closePriceArray, highPriceArray, lowPriceArray, offsetArray, type); inputStatWindow.Show(); }