- Timestamp:
- 10/23/16 19:33:03 (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
r14353 r14354 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
r14353 r14354 42 42 private const string ProblemDataParameterName = "ProblemData"; 43 43 private const string EstimationLimitsParameterName = "EstimationLimits"; 44 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";45 44 #endregion 46 45 … … 61 60 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; } 62 61 } 63 public ILookupParameter<BoolValue> ApplyLinearScalingParameter {64 get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }65 }66 62 #endregion 67 63 … … 74 70 Parameters.Add(new ValueLookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated.")); 75 71 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"));77 72 #endregion 78 73 … … 84 79 protected SymbolicRegressionPhenotypicDiversityAnalyzer(bool deserializing) 85 80 : 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"));92 81 } 93 82 … … 109 98 } 110 99 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; 100 if (updateCounter.Value == updateInterval) { 101 var trees = SymbolicExpressionTreeParameter.ActualValue; 118 102 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 119 103 var ds = ProblemDataParameter.ActualValue.Dataset; 120 104 var rows = ProblemDataParameter.ActualValue.TrainingIndices; 121 var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, ds, rows).ToArray();122 105 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()))); 106 var evaluatedValues = new ItemArray<DoubleArray>(trees.Select(t => new DoubleArray(interpreter.GetSymbolicExpressionTreeValues(t, ds, rows).ToArray()))); 107 EvaluatedValuesParameter.ActualValue = evaluatedValues; 145 108 } 146 109 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.