Changeset 8762 for branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis/3.4/TimeSeries/AutoregressiveModeling.cs
- Timestamp:
- 10/08/12 16:11:03 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis/3.4/TimeSeries/AutoregressiveModeling.cs
r8468 r8762 77 77 /// <param name="timeOffset">The parameter p of the AR(p) specifying the maximum time offset [1,infinity] </param> 78 78 /// <returns>The times series autoregressive solution </returns> 79 public ITimeSeriesPrognosisSolution CreateAutoRegressiveSolution(ITimeSeriesPrognosisProblemData problemData, int timeOffset) {79 public static ITimeSeriesPrognosisSolution CreateAutoRegressiveSolution(ITimeSeriesPrognosisProblemData problemData, int timeOffset) { 80 80 double rmsError, cvRmsError; 81 81 return CreateAutoRegressiveSolution(problemData, timeOffset, out rmsError, out cvRmsError); 82 82 } 83 83 84 internalITimeSeriesPrognosisSolution CreateAutoRegressiveSolution(ITimeSeriesPrognosisProblemData problemData, int timeOffset, out double rmsError, out double cvRmsError) {84 private static ITimeSeriesPrognosisSolution CreateAutoRegressiveSolution(ITimeSeriesPrognosisProblemData problemData, int timeOffset, out double rmsError, out double cvRmsError) { 85 85 string targetVariable = problemData.TargetVariable; 86 86 87 87 double[,] inputMatrix = new double[problemData.TrainingPartition.Size, timeOffset + 1]; 88 var targetValues = problemData.Dataset.Get ReadOnlyDoubleValues(targetVariable);88 var targetValues = problemData.Dataset.GetDoubleValues(targetVariable).ToList(); 89 89 for (int i = 0, row = problemData.TrainingPartition.Start; i < problemData.TrainingPartition.Size; i++, row++) { 90 for (int col = 0; col < timeOffset + 1; col++) {91 inputMatrix[i, col] = targetValues[row - col ];90 for (int col = 0; col < timeOffset; col++) { 91 inputMatrix[i, col] = targetValues[row - col - 1]; 92 92 } 93 93 } 94 // set target values in last column 95 for (int i = 0; i < inputMatrix.GetLength(0); i++) 96 inputMatrix[i, timeOffset] = targetValues[i + problemData.TrainingPartition.Start]; 94 97 95 98 if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x))) … … 119 122 120 123 for (int i = 0; i < timeOffset; i++) { 121 LaggedVariableTreeNode node = (LaggedVariableTreeNode)new HeuristicLab.Problems.DataAnalysis.Symbolic.LaggedVariable().CreateTreeNode();124 LaggedVariableTreeNode node = (LaggedVariableTreeNode)new LaggedVariable().CreateTreeNode(); 122 125 node.VariableName = targetVariable; 123 126 node.Weight = coefficients[i];
Note: See TracChangeset
for help on using the changeset viewer.