Ignore:
Timestamp:
09/29/15 16:49:13 (4 years ago)
Author:
bburlacu
Message:

#2480: Implemented the necessary changes in the evaluators, and removed obsolete code from the phenotypic diversity analyzer.

File:
1 edited

Legend:

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

    r12012 r12973  
    5050      IEnumerable<int> rows = GenerateRowsToEvaluate();
    5151
    52       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);
     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);
    5368      QualityParameter.ActualValue = new DoubleValue(quality);
    5469
     
    5974      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    6075      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) {
    6180      IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    6281
Note: See TracChangeset for help on using the changeset viewer.