- Timestamp:
- 10/23/16 19:31:18 (8 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs
r14185 r14353 70 70 } 71 71 if (errorState != OnlineCalculatorError.None) return double.NaN; 72 return r *r;72 return r * r; 73 73 } 74 74 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPhenotypicDiversityAnalyzer.cs
r14185 r14353 42 42 private const string ProblemDataParameterName = "ProblemData"; 43 43 private const string EstimationLimitsParameterName = "EstimationLimits"; 44 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 44 45 #endregion 45 46 … … 60 61 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; } 61 62 } 63 public ILookupParameter<BoolValue> ApplyLinearScalingParameter { 64 get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; } 65 } 62 66 #endregion 63 67 … … 70 74 Parameters.Add(new ValueLookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated.")); 71 75 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The upper and lower limit that should be used as cut off value for the output values of symbolic data analysis trees.")); 76 Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Whether or not to apply linear scaling to the estimated values")); 72 77 #endregion 73 78 … … 79 84 protected SymbolicRegressionPhenotypicDiversityAnalyzer(bool deserializing) 80 85 : base(deserializing) { 86 } 87 88 [StorableHook(HookType.AfterDeserialization)] 89 private void AfterDeserialization() { 90 if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) 91 Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Whether or not to apply linear scaling to the estimated values")); 81 92 } 82 93 … … 98 109 } 99 110 100 if (updateCounter.Value == updateInterval) { 101 var trees = SymbolicExpressionTreeParameter.ActualValue; 111 if (updateCounter.Value != updateInterval) return base.Apply(); 112 113 var scopes = ExecutionContext.Scope.SubScopes; 114 var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value; 115 116 foreach (var scope in scopes.Where(x => !x.Variables.ContainsKey("EstimatedValues"))) { 117 var tree = (ISymbolicExpressionTree)scope.Variables["SymbolicExpressionTree"].Value; 102 118 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 103 119 var ds = ProblemDataParameter.ActualValue.Dataset; 104 120 var rows = ProblemDataParameter.ActualValue.TrainingIndices; 121 var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, ds, rows).ToArray(); 105 122 106 var evaluatedValues = new ItemArray<DoubleArray>(trees.Select(t => new DoubleArray(interpreter.GetSymbolicExpressionTreeValues(t, ds, rows).ToArray()))); 107 EvaluatedValuesParameter.ActualValue = evaluatedValues; 123 var estimationLimits = EstimationLimitsParameter.ActualValue; 124 125 if (applyLinearScaling) { 126 var linearScalingCalculator = new OnlineLinearScalingParameterCalculator(); 127 var targetValues = ds.GetDoubleValues(ProblemDataParameter.ActualValue.TargetVariable, rows); 128 int i = 0; 129 foreach (var target in targetValues) { 130 var estimated = estimatedValues[i]; 131 if (!double.IsNaN(estimated) && !double.IsInfinity(estimated)) 132 linearScalingCalculator.Add(estimated, target); 133 i++; 134 } 135 if (linearScalingCalculator.ErrorState == OnlineCalculatorError.None) { 136 var alpha = linearScalingCalculator.Alpha; 137 var beta = linearScalingCalculator.Beta; 138 for (i = 0; i < estimatedValues.Length; ++i) { 139 estimatedValues[i] = estimatedValues[i] * beta + alpha; 140 } 141 } 142 } 143 // add estimated values to escope 144 scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray()))); 108 145 } 109 146 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.