Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8762


Ignore:
Timestamp:
10/08/12 16:11:03 (12 years ago)
Author:
mkommend
Message:

#1081: Fixed serialization and corrected AR(n) modeling.

Location:
branches/HeuristicLab.TimeSeries
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis/3.4/TimeSeries/AutoregressiveModeling.cs

    r8468 r8762  
    7777    /// <param name="timeOffset">The parameter p of the AR(p) specifying the maximum time offset [1,infinity] </param>
    7878    /// <returns>The times series autoregressive solution </returns>
    79     public ITimeSeriesPrognosisSolution CreateAutoRegressiveSolution(ITimeSeriesPrognosisProblemData problemData, int timeOffset) {
     79    public static ITimeSeriesPrognosisSolution CreateAutoRegressiveSolution(ITimeSeriesPrognosisProblemData problemData, int timeOffset) {
    8080      double rmsError, cvRmsError;
    8181      return CreateAutoRegressiveSolution(problemData, timeOffset, out rmsError, out cvRmsError);
    8282    }
    8383
    84     internal ITimeSeriesPrognosisSolution 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) {
    8585      string targetVariable = problemData.TargetVariable;
    8686
    8787      double[,] inputMatrix = new double[problemData.TrainingPartition.Size, timeOffset + 1];
    88       var targetValues = problemData.Dataset.GetReadOnlyDoubleValues(targetVariable);
     88      var targetValues = problemData.Dataset.GetDoubleValues(targetVariable).ToList();
    8989      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];
    9292        }
    9393      }
     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];
    9497
    9598      if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x)))
     
    119122
    120123      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();
    122125        node.VariableName = targetVariable;
    123126        node.Weight = coefficients[i];
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisResults.cs

    r8750 r8762  
    322322    #endregion
    323323
    324 
     324    [Storable]
    325325    private int trainingHorizon;
    326     [Storable]
    327326    public int TrainingHorizon {
    328327      get { return trainingHorizon; }
     
    335334    }
    336335
     336    [Storable]
    337337    private int testHorizon;
    338     [Storable]
    339338    public int TestHorizon {
    340339      get { return testHorizon; }
     
    351350    public ITimeSeriesPrognosisSolution Solution {
    352351      get { return solution; }
     352      private set { solution = value; } //necessary for persistence
    353353    }
    354354
Note: See TracChangeset for help on using the changeset viewer.