Changeset 14301
 Timestamp:
 09/22/16 17:00:29 (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/HeuristicLab.OSGAEvaluator/HeuristicLab.OSGAEvaluator/SymbolicRegressionSingleObjectiveOSGAEvaluator.cs
r14281 r14301 292 292 #endregion 293 293 } else { 294 var calculator = new OnlinePearsonsRCalculator();295 294 var trainingPartitionSize = problemData.TrainingPartition.Size; 296 295 var interval = (int)Math.Floor(trainingPartitionSize * RelativeFitnessEvaluationIntervalSize); … … 299 298 // use the actual estimated values for the first i * interval rows of the training partition and and assume the remaining rows are perfectly correlated 300 299 // if the quality of the individual still falls below the parent quality, then we can reject it sooner, otherwise as i increases the whole estimated series will be used 300 var lsc = new OnlineLinearScalingParameterCalculator(); 301 var rcalc = new OnlinePearsonsRCalculator(); 302 var actualQuality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, SymbolicExpressionTreeParameter.ActualValue, estimationLimits.Lower, estimationLimits.Upper, problemData, problemData.TrainingIndices, false); 301 303 for (int i = 0; i < trainingPartitionSize; i += interval) { 302 calculator.Reset(); 303 // save estimated values into the list (for caching) 304 var start = problemData.TrainingPartition.Start; 304 305 int end = Math.Min(trainingPartitionSize, i + interval); 306 // cache estimated values 307 // scale target values to the range of the estimated values 305 308 for (int j = i; j < end && e.MoveNext(); ++j) { 306 309 estimated.Add(e.Current); 307 }308 var start = problemData.TrainingPartition.Start;309 // add (estimated, target) pairs to the calculator310 for (int j = 0; j < end; ++j) {311 310 var index = j + start; 312 calculator.Add(targetValues[index], estimated[j]); 313 } 314 // add (target, target) pairs to the calculator (simulate perfect correlation on the remaining rows) 311 // in the context of the linear scaling calculator, the target value becomes the "original" 312 // while the estimated value becomes the "target" (because we want to scale the target in the range of the estimated) 313 lsc.Add(targetValues[index], e.Current); 314 } 315 var a = lsc.Alpha; // additive scaling term 316 var b = lsc.Beta; // multiplicative scaling factor 317 // calculate the quality 318 for (int j = i; j < end; ++j) { 319 var index = j + start; 320 rcalc.Add(estimated[j], targetValues[index]); 321 } 322 var rcalc2 = (OnlinePearsonsRCalculator)rcalc.Clone(); 315 323 for (int j = end; j < trainingPartitionSize; ++j) { 316 324 var index = j + start; 317 var v = targetValues[index] ;318 calculator.Add(v, v);319 } 320 var r = calculator.ErrorState == OnlineCalculatorError.None ? calculator.R : double.NaN;325 var v = targetValues[index] * b + a; 326 rcalc2.Add(v, targetValues[index]); 327 } 328 var r = rcalc2.ErrorState == OnlineCalculatorError.None ? rcalc2.R : double.NaN; 321 329 quality = r * r; 322 if (!(quality > parentQuality)) 323 break; 330 bool falseReject = false; 331 if (!(quality > parentQuality)) { 332 if (actualQuality > parentQuality) 333 falseReject = true; 334 } 335 // if (!(quality > parentQuality)) 336 // break; 324 337 } 338 325 339 return quality; 326 340 }
Note: See TracChangeset
for help on using the changeset viewer.