Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/29/15 16:49:13 (9 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/SymbolicRegressionLogResidualEvaluator.cs

    r12012 r12973  
    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       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);
     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);
    6075      QualityParameter.ActualValue = new DoubleValue(quality);
    6176
     
    6681      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    6782      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) {
    6887      IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    6988
Note: See TracChangeset for help on using the changeset viewer.