Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/02/21 17:23:10 (3 years 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
Location:
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredAverageSimilarityEvaluator.cs

    r17180 r18103  
    7070    public override IOperation InstrumentedApply() {
    7171      IEnumerable<int> rows = GenerateRowsToEvaluate();
    72       var solution = SymbolicExpressionTreeParameter.ActualValue;
     72      var tree = SymbolicExpressionTreeParameter.ActualValue;
    7373      var problemData = ProblemDataParameter.ActualValue;
    7474      var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
     
    7777
    7878      if (UseConstantOptimization) {
    79         SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
     79        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
    8080      }
    8181
    82       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, solution, estimationLimits.Lower, estimationLimits.Upper, problemData, rows, applyLinearScaling);
     82      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     83        tree, problemData, rows, interpreter, applyLinearScaling,
     84        estimationLimits.Lower, estimationLimits.Upper);
    8385
    8486      if (DecimalPlaces >= 0)
     
    107109      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    108110
    109       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, estimationLimits.Lower, estimationLimits.Upper, problemData, rows, applyLinearScaling);
     111      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     112        tree, problemData, rows,
     113        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     114        applyLinearScaling,
     115        estimationLimits.Lower, estimationLimits.Upper);
    110116
    111117      lock (locker) {
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNestedTreeSizeEvaluator.cs

    r17180 r18103  
    6363    }
    6464
    65     public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
    66       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
     65    public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
     66      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     67         tree, problemData, rows,
     68         interpreter, applyLinearScaling,
     69         lowerEstimationLimit, upperEstimationLimit);
    6770      if (decimalPlaces >= 0)
    6871        r2 = Math.Round(r2, decimalPlaces);
    69       return new double[2] { r2, solution.IterateNodesPostfix().Sum(n => n.GetLength()) }; // sum of the length of the whole sub-tree for each node
     72      return new double[2] { r2, tree.IterateNodesPostfix().Sum(n => n.GetLength()) }; // sum of the length of the whole sub-tree for each node
    7073    }
    7174
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNumberOfVariablesEvaluator.cs

    r17180 r18103  
    6262    }
    6363
    64     public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
    65       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
     64    public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
     65      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     66        tree, problemData, rows, interpreter, applyLinearScaling,
     67        lowerEstimationLimit, upperEstimationLimit);
    6668      if (decimalPlaces >= 0)
    6769        r2 = Math.Round(r2, decimalPlaces);
    68       return new double[2] { r2, solution.IterateNodesPostfix().OfType<IVariableTreeNode>().Count() }; // count the number of variables
     70      return new double[2] { r2, tree.IterateNodesPostfix().OfType<IVariableTreeNode>().Count() }; // count the number of variables
    6971    }
    7072
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredTreeComplexityEvaluator.cs

    r17180 r18103  
    6161    }
    6262
    63     public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
    64       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
     63    public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
     64      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     65         tree, problemData, rows,
     66         interpreter, applyLinearScaling,
     67         lowerEstimationLimit, upperEstimationLimit);
    6568      if (decimalPlaces >= 0)
    6669        r2 = Math.Round(r2, decimalPlaces);
    67       return new double[2] { r2, SymbolicDataAnalysisModelComplexityCalculator.CalculateComplexity(solution) };
     70      return new double[2] { r2, SymbolicDataAnalysisModelComplexityCalculator.CalculateComplexity(tree) };
    6871    }
    6972
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs

    r17180 r18103  
    4747    public override IOperation InstrumentedApply() {
    4848      IEnumerable<int> rows = GenerateRowsToEvaluate();
    49       var solution = SymbolicExpressionTreeParameter.ActualValue;
     49      var tree = SymbolicExpressionTreeParameter.ActualValue;
    5050      var problemData = ProblemDataParameter.ActualValue;
    5151      var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
     
    5454
    5555      if (UseConstantOptimization) {
    56         SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
     56        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
    5757      }
    5858
    59       double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
     59      double[] qualities = Calculate(
     60        tree, ProblemDataParameter.ActualValue,
     61        rows, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     62        ApplyLinearScalingParameter.ActualValue.Value,
     63        EstimationLimitsParameter.ActualValue.Lower,
     64        EstimationLimitsParameter.ActualValue.Upper,
     65        DecimalPlaces);
    6066      QualitiesParameter.ActualValue = new DoubleArray(qualities);
    6167      return base.InstrumentedApply();
    6268    }
    6369
    64     public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
    65       var mse = SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.Calculate(interpreter, solution, lowerEstimationLimit,
    66         upperEstimationLimit, problemData, rows, applyLinearScaling);
     70    public static double[] Calculate(
     71      ISymbolicExpressionTree tree,
     72      IRegressionProblemData problemData,
     73      IEnumerable<int> rows,
     74      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     75      bool applyLinearScaling,
     76      double lowerEstimationLimit, double upperEstimationLimit,
     77      int decimalPlaces) {
     78      var mse = SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.Calculate(
     79        tree, problemData, rows,
     80        interpreter, applyLinearScaling,
     81        lowerEstimationLimit,
     82        upperEstimationLimit);
    6783
    6884      if (decimalPlaces >= 0)
    6985        mse = Math.Round(mse, decimalPlaces);
    7086
    71       return new double[2] { mse, solution.Length };
     87      return new double[2] { mse, tree.Length };
    7288    }
    7389
     
    7793      ApplyLinearScalingParameter.ExecutionContext = context;
    7894
    79       double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
     95      double[] quality = Calculate(
     96        tree, problemData, rows,
     97        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     98        ApplyLinearScalingParameter.ActualValue.Value,
     99        EstimationLimitsParameter.ActualValue.Lower,
     100        EstimationLimitsParameter.ActualValue.Upper, DecimalPlaces);
    80101
    81102      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r17180 r18103  
    6161    }
    6262
    63     public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
    64       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
     63    public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
     64      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     65        tree, problemData, rows, interpreter, applyLinearScaling,
     66        lowerEstimationLimit, upperEstimationLimit);
    6567      if (decimalPlaces >= 0)
    6668        r2 = Math.Round(r2, decimalPlaces);
    67       return new double[2] { r2, solution.Length };
     69      return new double[2] { r2, tree.Length };
    6870    }
    6971
Note: See TracChangeset for help on using the changeset viewer.