Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/29/11 20:05:38 (13 years ago)
Author:
gkronber
Message:

#1081 worked on multi-variate time series prognosis

Location:
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4
Files:
6 edited

Legend:

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

    • Property svn:ignore
      •  

        old new  
        33HeuristicLabProblemsDataAnalysisSymbolicTimeSeriesPrognosisPlugin.cs
        44obj
         5Plugin.cs
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveMeanSquaredErrorEvaluator.cs

    r6802 r7100  
    4848      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4949
    50       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);
     50      double quality = Calculate(SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);
    5151      QualityParameter.ActualValue = new DoubleValue(quality);
    5252
     
    5656    public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, ITimeSeriesPrognosisProblemData problemData, IEnumerable<int> rows) {
    5757      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    58       IEnumerable<double> originalValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    59       IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    60       OnlineCalculatorError errorState;
    61       double mse = OnlineMeanSquaredErrorCalculator.Calculate(originalValues, boundedEstimationValues, out errorState);
    62       if (errorState != OnlineCalculatorError.None) return double.NaN;
    63       else return mse;
     58      OnlineMeanAndVarianceCalculator meanCalculator = new OnlineMeanAndVarianceCalculator();
     59      foreach (var targetVariable in problemData.TargetVariables) {
     60        IEnumerable<double> originalValues = problemData.Dataset.GetDoubleValues(targetVariable, rows);
     61        IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit,
     62                                                                                   upperEstimationLimit);
     63        OnlineCalculatorError errorState;
     64        meanCalculator.Add(OnlineMeanSquaredErrorCalculator.Calculate(originalValues, boundedEstimationValues, out errorState));
     65        if (errorState != OnlineCalculatorError.None) return double.NaN;
     66      }
     67      return meanCalculator.Mean;
    6468    }
    6569
    6670    public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, ITimeSeriesPrognosisProblemData problemData, IEnumerable<int> rows) {
    67       SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context;
     71      SymbolicTimeSeriesPrognosisInterpreterParameter.ExecutionContext = context;
    6872      EstimationLimitsParameter.ExecutionContext = context;
    6973
    70       double mse = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows);
     74      double mse = Calculate(SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows);
    7175
    7276
    73       SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     77      SymbolicTimeSeriesPrognosisInterpreterParameter.ExecutionContext = null;
    7478      EstimationLimitsParameter.ExecutionContext = null;
    7579
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectivePearsonRSquaredEvaluator.cs

    r6802 r7100  
    4848      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4949
    50       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);
     50      double quality = Calculate(SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);
    5151      QualityParameter.ActualValue = new DoubleValue(quality);
    5252
     
    5656    public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, ITimeSeriesPrognosisProblemData problemData, IEnumerable<int> rows) {
    5757      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    58       IEnumerable<double> originalValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    59       OnlineCalculatorError errorState;
    60       double r2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedValues, originalValues, out errorState);
    61       if (errorState != OnlineCalculatorError.None) return 0.0;
    62       else return r2;
     58      var meanCalculator = new OnlineMeanAndVarianceCalculator();
     59      foreach (var targetVariable in problemData.TargetVariables) {
     60        IEnumerable<double> originalValues = problemData.Dataset.GetDoubleValues(targetVariable, rows);
     61        OnlineCalculatorError errorState;
     62        meanCalculator.Add(OnlinePearsonsRSquaredCalculator.Calculate(estimatedValues, originalValues, out errorState));
     63        if (errorState != OnlineCalculatorError.None) return 0.0;
     64      }
     65      return meanCalculator.Mean;
    6366    }
    6467
    6568    public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, ITimeSeriesPrognosisProblemData problemData, IEnumerable<int> rows) {
    66       SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context;
     69      SymbolicTimeSeriesPrognosisInterpreterParameter.ExecutionContext = context;
    6770      EstimationLimitsParameter.ExecutionContext = context;
    6871
    69       double r2 = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows);
     72      double r2 = Calculate(SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows);
    7073
    71       SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     74      SymbolicTimeSeriesPrognosisInterpreterParameter.ExecutionContext = null;
    7275      EstimationLimitsParameter.ExecutionContext = null;
    7376
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveProblem.cs

    r7099 r7100  
    6969      UpdateEstimationLimits();
    7070    }
    71    
     71
    7272    private void ConfigureGrammarSymbols() {
    7373      var grammar = SymbolicExpressionTreeGrammar as TypeCoherentExpressionGrammar;
     
    7777    private void InitializeOperators() {
    7878      Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer());
    79       Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer());
    80       Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveOverfittingAnalyzer());
     79      //Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer());
     80      //Operators.Add(new SymbolicTimeSeriesPrognosisSingleObjectiveOverfittingAnalyzer());
    8181      ParameterizeOperators();
    8282    }
    8383
    8484    private void UpdateEstimationLimits() {
    85       if (ProblemData.TrainingIndizes.Any()) {
    86         var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes).ToList();
    87         var mean = targetValues.Average();
    88         var range = targetValues.Max() - targetValues.Min();
    89         EstimationLimits.Upper = mean + PunishmentFactor * range;
    90         EstimationLimits.Lower = mean - PunishmentFactor * range;
    91       } else {
    92         EstimationLimits.Upper = double.MaxValue;
    93         EstimationLimits.Lower = double.MinValue;
    94       }
     85      //if (ProblemData.TrainingIndizes.Any()) {
     86      //  var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariables, ProblemData.TrainingIndizes).ToList();
     87      //  var mean = targetValues.Average();
     88      //  var range = targetValues.Max() - targetValues.Min();
     89      //  EstimationLimits.Upper = mean + PunishmentFactor * range;
     90      //  EstimationLimits.Lower = mean - PunishmentFactor * range;
     91      //} else {
     92      EstimationLimits.Upper = double.MaxValue;
     93      EstimationLimits.Lower = double.MinValue;
     94      //}
    9595    }
    9696
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer.cs

    r6802 r7100  
    3434  [StorableClass]
    3535  public sealed class SymbolicTimeSeriesPrognosisSingleObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<ISymbolicTimeSeriesPrognosisSolution>,
    36   ISymbolicDataAnalysisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator {
     36  ISymbolicTimeSeriesPrognosisInterpreterOperator, ISymbolicDataAnalysisBoundedOperator {
    3737    private const string ProblemDataParameterName = "ProblemData";
    38     private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";
     38    private const string SymbolicTimeSeriesPrognosisInterpreterParameterName = "SymbolicTimeSeriesPrognosisInterpreter";
    3939    private const string EstimationLimitsParameterName = "EstimationLimits";
    4040    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
     
    4343      get { return (ILookupParameter<ITimeSeriesPrognosisProblemData>)Parameters[ProblemDataParameterName]; }
    4444    }
    45     public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter {
    46       get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
     45    public ILookupParameter<ISymbolicTimeSeriesPrognosisInterpreter> SymbolicTimeSeriesPrognosisInterpreterParameter {
     46      get { return (ILookupParameter<ISymbolicTimeSeriesPrognosisInterpreter>)Parameters[SymbolicTimeSeriesPrognosisInterpreterParameterName]; }
    4747    }
    4848    public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter {
     
    6666      : base() {
    6767      Parameters.Add(new LookupParameter<ITimeSeriesPrognosisProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution."));
    68       Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree."));
     68      Parameters.Add(new LookupParameter<ISymbolicTimeSeriesPrognosisInterpreter>(SymbolicTimeSeriesPrognosisInterpreterParameterName, "The symbolic time series prognosis interpreter for the symbolic expression tree."));
    6969      Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model."));
    7070      Parameters.Add(new ValueParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the produced symbolic regression solution should be linearly scaled.", new BoolValue(true)));
     
    7575
    7676    protected override ISymbolicTimeSeriesPrognosisSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
    77       var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
     77      var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue);
    7878      if (ApplyLinearScaling.Value)
    7979        SymbolicTimeSeriesPrognosisModel.Scale(model, ProblemDataParameter.ActualValue);
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SingleObjective/SymbolicTimeSeriesPrognosisSingleObjectiveValidationBestSolutionAnalyzer.cs

    r6802 r7100  
    6767
    6868    protected override ISymbolicTimeSeriesPrognosisSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) {
    69       var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper);
     69      var model = new SymbolicTimeSeriesPrognosisModel((ISymbolicExpressionTree)bestTree.Clone(), SymbolicTimeSeriesPrognosisInterpreterParameter.ActualValue);
    7070      if (ApplyLinearScaling.Value)
    7171        SymbolicTimeSeriesPrognosisModel.Scale(model, ProblemDataParameter.ActualValue);
Note: See TracChangeset for help on using the changeset viewer.