Ignore:
Timestamp:
12/02/21 17:23:10 (7 months ago)
Author:
dpiringe
Message:

#3136

  • refactor the evaluation logic of NMSESingleObjectiveConstraintsEvaluator
  • refactor the new method Evaluate for PearsonRSquaredAverageSimilarityEvaluator
  • change the parameter order of some evaluate/calculate methods
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs

    r18095 r18103  
    4848      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4949
    50       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value);
     50      double quality = Calculate(
     51        solution, ProblemDataParameter.ActualValue,
     52        rows, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     53        ApplyLinearScalingParameter.ActualValue.Value,
     54        EstimationLimitsParameter.ActualValue.Lower,
     55        EstimationLimitsParameter.ActualValue.Upper);
    5156      QualityParameter.ActualValue = new DoubleValue(quality);
    5257
     
    5459    }
    5560
    56     public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling) {
    57       IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
     61    //TODO: refactor like evaluate method
     62    public static double Calculate(
     63      ISymbolicExpressionTree tree,
     64      IRegressionProblemData problemData,
     65      IEnumerable<int> rows,
     66      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     67      bool applyLinearScaling,
     68      double lowerEstimationLimit,
     69      double upperEstimationLimit) {
     70      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, rows);
    5871      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    5972      OnlineCalculatorError errorState;
     
    7891      ApplyLinearScalingParameter.ExecutionContext = context;
    7992
    80       double r2 = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value);
     93      double r2 = Calculate(
     94         tree, problemData, rows,
     95         SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     96         ApplyLinearScalingParameter.ActualValue.Value,
     97         EstimationLimitsParameter.ActualValue.Lower,
     98         EstimationLimitsParameter.ActualValue.Upper);
    8199
    82100      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     
    87105    }
    88106
    89     public override double Evaluate(IRegressionProblemData problemData,
    90       ISymbolicExpressionTree solution,
     107    public override double Evaluate(
     108      ISymbolicExpressionTree tree,
     109      IRegressionProblemData problemData,
     110      IEnumerable<int> rows,
    91111      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
    92       IEnumerable<int> rows = null,
    93112      bool applyLinearScaling = true,
    94113      double lowerEstimationLimit = double.MinValue,
    95114      double upperEstimationLimit = double.MaxValue) {
    96       return Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows ?? problemData.TrainingIndices, applyLinearScaling);
     115      return Calculate(
     116        tree, problemData, rows,
     117        interpreter, applyLinearScaling,
     118        lowerEstimationLimit, upperEstimationLimit);
    97119    }
    98120  }
Note: See TracChangeset for help on using the changeset viewer.