Changeset 712 for trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/EarlyStoppingMeanSquaredErrorEvaluator.cs
- Timestamp:
- 11/05/08 21:34:12 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/EarlyStoppingMeanSquaredErrorEvaluator.cs
r702 r712 47 47 double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, false).Data; 48 48 DoubleData mse = GetVariableValue<DoubleData>("MSE", scope, false, false); 49 if (mse == null) {49 if (mse == null) { 50 50 mse = new DoubleData(); 51 51 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MSE"), mse)); … … 54 54 double errorsSquaredSum = 0; 55 55 int rows = end - start; 56 for (int sample = start; sample < end; sample++) {56 for (int sample = start; sample < end; sample++) { 57 57 double estimated = evaluator.Evaluate(sample); 58 double original = dataset.GetValue( targetVariable, sample);59 if (updateTargetValues) {60 dataset.SetValue( targetVariable, sample, estimated);58 double original = dataset.GetValue(sample, targetVariable); 59 if (updateTargetValues) { 60 dataset.SetValue(sample, targetVariable, estimated); 61 61 } 62 if (!double.IsNaN(original) && !double.IsInfinity(original)) {62 if (!double.IsNaN(original) && !double.IsInfinity(original)) { 63 63 double error = estimated - original; 64 64 errorsSquaredSum += error * error; 65 65 } 66 66 // check the limit and stop as soon as we hit the limit 67 if (errorsSquaredSum / rows >= qualityLimit) {67 if (errorsSquaredSum / rows >= qualityLimit) { 68 68 mse.Data = errorsSquaredSum / (sample - start + 1); // return estimated MSE (when the remaining errors are on average the same) 69 69 return; … … 71 71 } 72 72 errorsSquaredSum /= rows; 73 if (double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {73 if (double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) { 74 74 errorsSquaredSum = double.MaxValue; 75 75 }
Note: See TracChangeset
for help on using the changeset viewer.