Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8114


Ignore:
Timestamp:
06/26/12 09:15:55 (12 years ago)
Author:
mkommend
Message:

#1081: Corrected scaling behavior of symbolic time series models.

Location:
branches/HeuristicLab.TimeSeries
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views/3.4/InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs

    r7989 r8114  
    5151    protected override void UpdateModel(ISymbolicExpressionTree tree) {
    5252      var model = new SymbolicTimeSeriesPrognosisModel(tree, Content.Model.Interpreter);
    53       SymbolicTimeSeriesPrognosisModel.Scale(model, Content.ProblemData);
     53      SymbolicTimeSeriesPrognosisModel.Scale(model, Content.ProblemData, Content.ProblemData.TrainingIndizes);
    5454      Content.Model = model;
    5555    }
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveMeanSquaredErrorEvaluator.cs

    r8010 r8114  
    6969
    7070      double mse;
    71       if (applyLinearScaling) {
     71      if (applyLinearScaling && horizon == 1) { //perform normal evaluation and afterwards scale the solution and calculate the fitness value       
    7272        var mseCalculator = new OnlineMeanSquaredErrorCalculator();
    7373        CalculateWithScaling(targetValues, boundedEstimatedValues, mseCalculator, problemData.Dataset.Rows * horizon);
    7474        errorState = mseCalculator.ErrorState;
    7575        mse = mseCalculator.MeanSquaredError;
     76      } else if (applyLinearScaling) { //first create model to perform linear scaling and afterwards calculate fitness for the scaled model
     77        var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)solution.Clone(), interpreter, lowerEstimationLimit, upperEstimationLimit);
     78        SymbolicTimeSeriesPrognosisModel.Scale(model, problemData, rows);
     79        var scaledSolution = model.SymbolicExpressionTree;
     80        estimatedValues = interpreter.GetSymbolicExpressionTreeValues(scaledSolution, problemData.Dataset, rows, horizions).SelectMany(x => x);
     81        boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
     82        mse = OnlineMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
    7683      } else
    7784        mse = OnlineMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer.cs

    r7989 r8114  
    7777      var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue as ISymbolicTimeSeriesPrognosisExpressionTreeInterpreter, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
    7878      if (ApplyLinearScaling.Value)
    79         SymbolicTimeSeriesPrognosisModel.Scale(model, ProblemDataParameter.ActualValue);
     79        SymbolicTimeSeriesPrognosisModel.Scale(model, ProblemDataParameter.ActualValue, ProblemDataParameter.ActualValue.TrainingIndizes);
    8080      return new SymbolicTimeSeriesPrognosisSolution(model, (ITimeSeriesPrognosisProblemData)ProblemDataParameter.ActualValue.Clone());
    8181    }
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer.cs

    r7989 r8114  
    6666      var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue as ISymbolicTimeSeriesPrognosisExpressionTreeInterpreter, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
    6767      if (ApplyLinearScaling.Value)
    68         SymbolicTimeSeriesPrognosisModel.Scale(model, ProblemDataParameter.ActualValue);
     68        SymbolicTimeSeriesPrognosisModel.Scale(model, ProblemDataParameter.ActualValue, ProblemDataParameter.ActualValue.TrainingIndizes);
    6969      return new SymbolicTimeSeriesPrognosisSolution(model, (ITimeSeriesPrognosisProblemData)ProblemDataParameter.ActualValue.Clone());
    7070    }
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SymbolicTimeSeriesPrognosisModel.cs

    r8010 r8114  
    9898    }
    9999
    100     public static void Scale(SymbolicTimeSeriesPrognosisModel model, ITimeSeriesPrognosisProblemData problemData) {
     100    public static void Scale(SymbolicTimeSeriesPrognosisModel model, ITimeSeriesPrognosisProblemData problemData, IEnumerable<int> rows) {
    101101      var dataset = problemData.Dataset;
    102102      var targetVariable = problemData.TargetVariable;
    103       var rows = problemData.TrainingIndizes;
    104       var estimatedValuesEnumerator = model.Interpreter.GetSymbolicExpressionTreeValues(model.SymbolicExpressionTree, dataset, rows);
    105       var targetValuesEnumerator = problemData.Dataset.GetDoubleValues(targetVariable, rows);
     103      var estimatedValues = model.Interpreter.GetSymbolicExpressionTreeValues(model.SymbolicExpressionTree, dataset, rows);
     104      var boundedEstimatedValues = estimatedValues.LimitToRange(model.lowerEstimationLimit, model.upperEstimationLimit);
     105      var targetValues = problemData.Dataset.GetDoubleValues(targetVariable, rows);
    106106
    107107      double alpha, beta;
    108108      OnlineCalculatorError error;
    109       OnlineLinearScalingParameterCalculator.Calculate(estimatedValuesEnumerator, targetValuesEnumerator, out alpha, out beta, out error);
     109      OnlineLinearScalingParameterCalculator.Calculate(boundedEstimatedValues, targetValues, out alpha, out beta, out error);
    110110      if (error != OnlineCalculatorError.None) return;
    111111
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs

    r7842 r8114  
    227227
    228228    public void ConfigureAsDefaultTimeSeriesPrognosisGrammar() {
    229       Symbols.Where(s => s is Variable).First().Enabled = false;
    230       Symbols.Where(s => s.Name == TrigonometricFunctionsName).First().Enabled = false;
    231       Symbols.Where(s => s.Name == PowerFunctionsName).First().Enabled = false;
    232       Symbols.Where(s => s.Name == ConditionalSymbolsName).First().Enabled = false;
     229      Symbols.First(s => s is Variable).Enabled = false;
     230      Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false;
     231      Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false;
     232      Symbols.First(s => s.Name == ConditionalSymbolsName).Enabled = false;
     233      Symbols.First(s => s.Name == SpecialFunctionsName).Enabled = false;
    233234    }
    234235  }
Note: See TracChangeset for help on using the changeset viewer.