Changeset 702 for trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/MeanAbsolutePercentageErrorEvaluator.cs
- Timestamp:
- 10/29/08 11:21:04 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/MeanAbsolutePercentageErrorEvaluator.cs
r656 r702 27 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Operators; 29 using HeuristicLab.DataAnalysis; 29 30 30 31 namespace HeuristicLab.GP.StructureIdentification { 31 32 public class MeanAbsolutePercentageErrorEvaluator : GPEvaluatorBase { 32 private DoubleData mape;33 33 public override string Description { 34 34 get { … … 43 43 } 44 44 45 public override IOperation Apply(IScope scope) { 46 mape = GetVariableValue<DoubleData>("MAPE", scope, false, false); 47 if(mape == null) { 48 mape = new DoubleData(); 49 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MAPE"), mape)); 50 } 51 52 return base.Apply(scope); 53 } 54 55 public override void Evaluate(int start, int end) { 45 public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) { 56 46 double errorsSum = 0.0; 57 47 int n = 0; 58 48 for(int sample = start; sample < end; sample++) { 59 double estimated = GetEstimatedValue(sample); 60 double original = GetOriginalValue(sample); 61 SetOriginalValue(sample, estimated); 62 if(!double.IsNaN(original) && !double.IsInfinity(original) && original!=0.0) { 49 double estimated = evaluator.Evaluate(sample); 50 double original = dataset.GetValue(targetVariable, sample); 51 52 if(updateTargetValues) { 53 dataset.SetValue(targetVariable, sample, estimated); 54 } 55 56 if(!double.IsNaN(original) && !double.IsInfinity(original) && original != 0.0) { 63 57 double percent_error = Math.Abs((estimated - original) / original); 64 58 errorsSum += percent_error; … … 69 63 if(double.IsNaN(quality) || double.IsInfinity(quality)) 70 64 quality = double.MaxValue; 65 66 // create a variable for the MAPE 67 DoubleData mape = GetVariableValue<DoubleData>("MAPE", scope, false, false); 68 if(mape == null) { 69 mape = new DoubleData(); 70 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MAPE"), mape)); 71 } 72 71 73 mape.Data = quality; 72 74 }
Note: See TracChangeset
for help on using the changeset viewer.