Changeset 479 for trunk/sources/HeuristicLab.StructureIdentification/Evaluation/VarianceAccountedForEvaluator.cs
- Timestamp:
- 08/10/08 11:08:07 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.StructureIdentification/Evaluation/VarianceAccountedForEvaluator.cs
r400 r479 53 53 54 54 55 public override double Evaluate(IScope scope, IFunctionTree functionTree, int targetVariable, Dataset dataset) { 56 int trainingStart = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data; 57 int trainingEnd = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data; 58 double[] errors = new double[trainingEnd-trainingStart]; 59 double[] originalTargetVariableValues = new double[trainingEnd-trainingStart]; 60 double targetMean = dataset.GetMean(targetVariable, trainingStart, trainingEnd); 61 for(int sample = trainingStart; sample < trainingEnd; sample++) { 62 double estimated = evaluator.Evaluate(sample); 63 double original = dataset.GetValue(sample, targetVariable); 55 public override double Evaluate(int start, int end) { 56 int nSamples = end - start; 57 double[] errors = new double[nSamples]; 58 double[] originalTargetVariableValues = new double[nSamples]; 59 for(int sample = start; sample < end; sample++) { 60 double estimated = GetEstimatedValue(sample); 61 double original = GetOriginalValue(sample); 64 62 if(!double.IsNaN(original) && !double.IsInfinity(original)) { 65 if(double.IsNaN(estimated) || double.IsInfinity(estimated)) 66 estimated = targetMean + maximumPunishment; 67 else if(estimated > (targetMean + maximumPunishment)) 68 estimated = targetMean + maximumPunishment; 69 else if(estimated < (targetMean - maximumPunishment)) 70 estimated = targetMean - maximumPunishment; 63 errors[sample - start] = original - estimated; 64 originalTargetVariableValues[sample - start] = original; 71 65 } 72 73 errors[sample-trainingStart] = original - estimated;74 originalTargetVariableValues[sample-trainingStart] = original;75 66 } 76 scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (trainingEnd-trainingStart);77 78 67 double errorsVariance = Statistics.Variance(errors); 79 68 double originalsVariance = Statistics.Variance(originalTargetVariableValues);
Note: See TracChangeset
for help on using the changeset viewer.