Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/01/15 00:12:46 (9 years ago)
Author:
bburlacu
Message:

#2480: Reverted changes to the evaluators as they impact performance and memory usage.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionLogResidualEvaluator.cs

    r12973 r12977  
    3030
    3131namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
    32   [Item("Log Residual Evaluator", "Evaluator for symbolic regression models that calculates the mean of logarithmic absolute residuals avg(log( 1 + abs(y' - y)))" +
     32  [Item("Log Residual Evaluator", "Evaluator for symbolic regression models that calculates the mean of logarithmic absolute residuals avg(log( 1 + abs(y' - y)))" + 
    3333                                  "This evaluator does not perform linear scaling!" +
    3434                                  "This evaluator can be useful if the modeled function contains discontinuities (e.g. 1/x). " +
     
    5757      IEnumerable<int> rows = GenerateRowsToEvaluate();
    5858
    59       var problemData = ProblemDataParameter.ActualValue;
    60       var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
    61       var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray();
    62       var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    63       var estimationLimits = EstimationLimitsParameter.ActualValue;
    64 
    65       if (SaveEstimatedValuesToScope) {
    66         var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray();
    67         var scope = ExecutionContext.Scope;
    68         if (scope.Variables.ContainsKey("EstimatedValues"))
    69           scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues);
    70         else
    71           scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues)));
    72       }
    73 
    74       double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper);
     59      double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);
    7560      QualityParameter.ActualValue = new DoubleValue(quality);
    7661
     
    8166      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    8267      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    83       return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit);
    84     }
    85 
    86     private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit) {
    8768      IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    8869
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionMeanRelativeErrorEvaluator.cs

    r12973 r12977  
    5050      IEnumerable<int> rows = GenerateRowsToEvaluate();
    5151
    52       var problemData = ProblemDataParameter.ActualValue;
    53       var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
    54       var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray();
    55       var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    56       var estimationLimits = EstimationLimitsParameter.ActualValue;
    57 
    58       if (SaveEstimatedValuesToScope) {
    59         var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray();
    60         var scope = ExecutionContext.Scope;
    61         if (scope.Variables.ContainsKey("EstimatedValues"))
    62           scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues);
    63         else
    64           scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues)));
    65       }
    66 
    67       double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper);
     52      double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);
    6853      QualityParameter.ActualValue = new DoubleValue(quality);
    6954
     
    7459      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    7560      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    76       return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit);
    77     }
    78 
    79     private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit) {
    8061      IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    8162
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveEvaluator.cs

    r12973 r12977  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2225using HeuristicLab.Common;
    2326using HeuristicLab.Core;
     
    2730namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
    2831  [StorableClass]
    29   public abstract class SymbolicRegressionSingleObjectiveEvaluator : SymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>, ISymbolicRegressionSingleObjectiveEvaluator {
    30     private const string SaveEstimatedValuesToScopeParameterName = "SaveEstimatedValuesToScope";
    31 
    32     public IFixedValueParameter<BoolValue> SaveEstimatedValuesToScopeParameter {
    33       get { return (IFixedValueParameter<BoolValue>)Parameters[SaveEstimatedValuesToScopeParameterName]; }
    34     }
    35 
    36     public bool SaveEstimatedValuesToScope { get { return SaveEstimatedValuesToScopeParameter.Value.Value; } }
    37 
     32  public abstract class SymbolicRegressionSingleObjectiveEvaluator : SymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData>, ISymbolicRegressionSingleObjectiveEvaluator { 
    3833    [StorableConstructor]
    3934    protected SymbolicRegressionSingleObjectiveEvaluator(bool deserializing) : base(deserializing) { }
    4035    protected SymbolicRegressionSingleObjectiveEvaluator(SymbolicRegressionSingleObjectiveEvaluator original, Cloner cloner) : base(original, cloner) { }
    41 
    42     protected SymbolicRegressionSingleObjectiveEvaluator() : base() {
    43       Parameters.Add(new FixedValueParameter<BoolValue>(SaveEstimatedValuesToScopeParameterName, new BoolValue(false)));
    44       SaveEstimatedValuesToScopeParameter.Hidden = true;
    45     }
     36    protected SymbolicRegressionSingleObjectiveEvaluator(): base() {}   
    4637  }
    4738}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.cs

    r12973 r12977  
    2121
    2222using System.Collections.Generic;
    23 using System.Linq;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
     
    4746      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4847
    49       var problemData = ProblemDataParameter.ActualValue;
    50       var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
    51       var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray();
    52       var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    53       var estimationLimits = EstimationLimitsParameter.ActualValue;
    54 
    55       if (SaveEstimatedValuesToScope) {
    56         var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray();
    57         var scope = ExecutionContext.Scope;
    58         if (scope.Variables.ContainsKey("EstimatedValues"))
    59           scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues);
    60         else
    61           scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues)));
    62       }
    63 
    64       double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper, problemData, ApplyLinearScalingParameter.ActualValue.Value);
     48      double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value);
    6549      QualityParameter.ActualValue = new DoubleValue(quality);
    6650
     
    7155      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    7256      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    73       return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, problemData, applyLinearScaling);
    74     }
    75 
    76     private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, bool applyLinearScaling) {
    7757      OnlineCalculatorError errorState;
    7858
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.cs

    r12973 r12977  
    2121
    2222using System.Collections.Generic;
    23 using System.Linq;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
     
    4746      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4847
    49       var problemData = ProblemDataParameter.ActualValue;
    50       var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
    51       var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray();
    52       var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    53       var estimationLimits = EstimationLimitsParameter.ActualValue;
    54 
    55       if (SaveEstimatedValuesToScope) {
    56         var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray();
    57         var scope = ExecutionContext.Scope;
    58         if (scope.Variables.ContainsKey("EstimatedValues"))
    59           scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues);
    60         else
    61           scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues)));
    62       }
    63 
    64       double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper, problemData, ApplyLinearScalingParameter.ActualValue.Value);
     48      double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value);
    6549      QualityParameter.ActualValue = new DoubleValue(quality);
    6650
     
    7155      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    7256      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    73       return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, problemData, applyLinearScaling);
    74     }
    75 
    76     private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, bool applyLinearScaling) {
    7757      OnlineCalculatorError errorState;
    7858
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs

    r12973 r12977  
    2121
    2222using System.Collections.Generic;
    23 using System.Linq;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
     
    4746      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4847
    49       var problemData = ProblemDataParameter.ActualValue;
    50       var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
    51       var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray();
    52       var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    53       var estimationLimits = EstimationLimitsParameter.ActualValue;
    54 
    55       if (SaveEstimatedValuesToScope) {
    56         var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray();
    57         var scope = ExecutionContext.Scope;
    58         if (scope.Variables.ContainsKey("EstimatedValues"))
    59           scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues);
    60         else
    61           scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues)));
    62       }
    63 
    64       double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper, problemData, ApplyLinearScalingParameter.ActualValue.Value);
     48      double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value);
    6549      QualityParameter.ActualValue = new DoubleValue(quality);
    6650
     
    7155      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    7256      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    73       return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, problemData, applyLinearScaling);
    74     }
    75 
    76     private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, bool applyLinearScaling) {
    7757      OnlineCalculatorError errorState;
    7858
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs

    r12973 r12977  
    2121
    2222using System.Collections.Generic;
    23 using System.Linq;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
     
    4948      IEnumerable<int> rows = GenerateRowsToEvaluate();
    5049
    51       var problemData = ProblemDataParameter.ActualValue;
    52       var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
    53       var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows).ToArray();
    54       var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    55       var estimationLimits = EstimationLimitsParameter.ActualValue;
    56 
    57       if (SaveEstimatedValuesToScope) {
    58         var boundedValues = estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray();
    59         var scope = ExecutionContext.Scope;
    60         if (scope.Variables.ContainsKey("EstimatedValues"))
    61           scope.Variables["EstimatedValues"].Value = new DoubleArray(boundedValues);
    62         else
    63           scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(boundedValues)));
    64       }
    65 
    66       double quality = Calculate(targetValues, estimatedValues, estimationLimits.Lower, estimationLimits.Upper, problemData, ApplyLinearScalingParameter.ActualValue.Value);
     50      double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value);
    6751      QualityParameter.ActualValue = new DoubleValue(quality);
    6852
     
    7357      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    7458      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    75       return Calculate(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, problemData, applyLinearScaling);
    76     }
    77 
    78     private static double Calculate(IEnumerable<double> targetValues, IEnumerable<double> estimatedValues, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, bool applyLinearScaling) {
    7959      OnlineCalculatorError errorState;
    8060
     
    9070      }
    9171      if (errorState != OnlineCalculatorError.None) return double.NaN;
    92       return r * r;
     72      return r*r;
    9373    }
    9474
Note: See TracChangeset for help on using the changeset viewer.