Changeset 479 for trunk/sources/HeuristicLab.StructureIdentification/Evaluation/CoefficientOfDeterminationEvaluator.cs
- Timestamp:
- 08/10/08 11:08:07 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.StructureIdentification/Evaluation/CoefficientOfDeterminationEvaluator.cs
r400 r479 43 43 } 44 44 45 public override double Evaluate(IScope scope, IFunctionTree functionTree, int targetVariable, Dataset dataset) { 46 int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data; 47 int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data; 45 public override double Evaluate(int start, int end) { 48 46 double errorsSquaredSum = 0.0; 49 47 double originalDeviationTotalSumOfSquares = 0.0; 50 double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd); 51 for(int sample = trainingStart; sample < trainingEnd; sample++) { 52 double estimated = evaluator.Evaluate(sample); 53 double original = dataset.GetValue(sample, targetVariable); 48 for(int sample = start; sample < end; sample++) { 49 double estimated = GetEstimatedValue(sample); 50 double original = GetOriginalValue(sample); 54 51 if(!double.IsNaN(original) && !double.IsInfinity(original)) { 55 if(double.IsNaN(estimated) || double.IsInfinity(estimated))56 estimated = targetMean + maximumPunishment;57 else if(estimated > (targetMean + maximumPunishment))58 estimated = targetMean + maximumPunishment;59 else if(estimated < (targetMean - maximumPunishment))60 estimated = targetMean - maximumPunishment;61 62 52 double error = estimated - original; 63 53 errorsSquaredSum += error * error; 64 54 65 double origDeviation = original - targetMean;55 double origDeviation = original - TargetMean; 66 56 originalDeviationTotalSumOfSquares += origDeviation * origDeviation; 67 57 } 68 58 } 69 70 scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (trainingEnd - trainingStart);71 59 72 60 double quality = 1 - errorsSquaredSum / originalDeviationTotalSumOfSquares;
Note: See TracChangeset
for help on using the changeset viewer.