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/SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.cs

    r12012 r12973  
    2121
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    4647      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4748
    48       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value);
     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);
    4965      QualityParameter.ActualValue = new DoubleValue(quality);
    5066
     
    5571      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    5672      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) {
    5777      OnlineCalculatorError errorState;
    5878
Note: See TracChangeset for help on using the changeset viewer.