Ignore:
Timestamp:
01/13/22 14:01:39 (4 months ago)
Author:
mkommend
Message:

#3136: Extracted linear scaling functionality in a dedicated helper class.

File:
1 edited

Legend:

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

    r18190 r18191  
    270270
    271271      // NMSEConstraintsEvaluator sets linear scaling terms itself
    272       if (StructureTemplate.ApplyLinearScaling && !(TreeEvaluator is NMSESingleObjectiveConstraintsEvaluator)) {
    273         AdjustLinearScalingParams(ProblemData, tree, Interpreter);
     272      if (ApplyLinearScaling && !(TreeEvaluator is NMSESingleObjectiveConstraintsEvaluator)) {
     273        LinearScaling.AdjustLinearScalingParams(ProblemData, tree, Interpreter);
    274274      }
    275275
     
    300300    }
    301301
    302     private static void AdjustLinearScalingParams(IRegressionProblemData problemData, ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter) {
    303       var offsetNode = tree.Root.GetSubtree(0).GetSubtree(0);
    304       var scalingNode = offsetNode.Subtrees.Where(x => !(x is NumberTreeNode)).First();
    305 
    306       var offsetNumberNode = (NumberTreeNode)offsetNode.Subtrees.Where(x => x is NumberTreeNode).First();
    307       var scalingNumberNode = (NumberTreeNode)scalingNode.Subtrees.Where(x => x is NumberTreeNode).First();
    308 
    309       var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, problemData.TrainingIndices);
    310       var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices);
    311 
    312       OnlineLinearScalingParameterCalculator.Calculate(estimatedValues, targetValues, out double a, out double b, out OnlineCalculatorError error);
    313       if (error == OnlineCalculatorError.None) {
    314         offsetNumberNode.Value = a;
    315         scalingNumberNode.Value = b;
    316       }
    317     }
    318 
    319 
    320 
    321 
    322 
    323 
    324302    public void Load(IRegressionProblemData data) {
    325303      ProblemData = data;
Note: See TracChangeset for help on using the changeset viewer.