public PredicResults Predict() { double[] present = new double[INPUT_TUPLES * INDEXES_TO_CONSIDER]; double[] actualOutput = new double[OUTPUT_SIZE]; int index = 0; index = _manager.Samples.Count; var result = new PredicResults(); _manager.GetInputData(index - INPUT_TUPLES, present); //_manager.GetOutputData(index - INPUT_TUPLES, actualOutput); var data = new BasicNeuralData(present); var predict = _network.Compute(data); //result.ActualClose = actualOutput[0] * (_manager.GetMax((int)PredicInputIndexe.CloseIndex) - _manager.GetMin((int)PredicInputIndexe.CloseIndex)) + _manager.GetMin((int)PredicInputIndexe.CloseIndex); result.PredictedClose = predict[0] * (_manager.GetMax((int)PredicInputIndexe.CloseIndex) - _manager.GetMin((int)PredicInputIndexe.CloseIndex)) + _manager.GetMin((int)PredicInputIndexe.CloseIndex); //result.ActualPir = actualOutput[1] * (_manager.MaxPrimeRate - _manager.MinPrimeRate) + _manager.MinPrimeRate; //result.PredictedPir = predict[1] * (_manager.MaxPrimeRate - _manager.MinPrimeRate) + _manager.MinPrimeRate; //result.ActualDow = actualOutput[2] * (_manager.MaxDow - _manager.MinDow) + _manager.MinDow; //result.PredictedDow = predict[2] * (_manager.MaxDow - _manager.MinDow) + _manager.MinDow; //result.ActualNasdaq = actualOutput[3] * (_manager.MaxNasdaq - _manager.MinNasdaq) + _manager.MinNasdaq; //result.PredictedNasdaq = predict[3] * (_manager.MaxNasdaq - _manager.MinNasdaq) + _manager.MinNasdaq; result.Date = _manager.GetDateTime(index - 1).AddDays(3); //ErrorCalculation error = new ErrorCalculation(); //error.UpdateError(actualOutput, predict); //result.Error = error.CalculateRMS(); result.Error = 0; return(result); }
/// <summary> /// Predict the results /// </summary> /// <returns>List with the prediction results</returns> public List <PredicResults> Predict(DateTime predictFrom, DateTime predictTo) { var results = new List <PredicResults>(); double[] present = new double[INPUT_TUPLES * INDEXES_TO_CONSIDER]; double[] actualOutput = new double[OUTPUT_SIZE]; int index = 0; foreach (var sample in _manager.Samples) { if (sample.Date.Date.CompareTo(predictFrom.Date) > 0 && sample.Date.Date.CompareTo(predictTo.Date) <= 0) { var result = new PredicResults(); _manager.GetInputData(index - INPUT_TUPLES, present); // _manager.GetOutputData(index - INPUT_TUPLES, actualOutput); var data = new BasicNeuralData(present); var predict = _network.Compute(data); //result.ActualClose = actualOutput[0] * (_manager.GetMax((int)PredicInputIndexe.CloseIndex) - _manager.GetMin((int)PredicInputIndexe.CloseIndex)) + _manager.GetMin((int)PredicInputIndexe.CloseIndex); result.PredictedClose = predict[0] * (_manager.GetMax((int)PredicInputIndexe.CloseIndex) - _manager.GetMin((int)PredicInputIndexe.CloseIndex)) + _manager.GetMin((int)PredicInputIndexe.CloseIndex); //result.ActualPir = actualOutput[1] * (_manager.MaxPrimeRate - _manager.MinPrimeRate) + _manager.MinPrimeRate; //result.PredictedPir = predict[1] * (_manager.MaxPrimeRate - _manager.MinPrimeRate) + _manager.MinPrimeRate; //result.ActualDow = actualOutput[2] * (_manager.MaxDow - _manager.MinDow) + _manager.MinDow; //result.PredictedDow = predict[2] * (_manager.MaxDow - _manager.MinDow) + _manager.MinDow; //result.ActualNasdaq = actualOutput[3] * (_manager.MaxNasdaq - _manager.MinNasdaq) + _manager.MinNasdaq; //result.PredictedNasdaq = predict[3] * (_manager.MaxNasdaq - _manager.MinNasdaq) + _manager.MinNasdaq; result.Date = sample.Date; ErrorCalculation error = new ErrorCalculation(); //error.UpdateError(actualOutput, predict); //result.Error = error.CalculateRMS(); //result.Error = result.ActualClose - result.PredictedClose; result.Error = 0; result.ActualClose = 0; results.Add(result); } index++; } return(results); }