Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/12/08 17:29:01 (16 years ago)
Author:
gkronber
Message:

ignore samples where the original value is 0 to prevent division by zero and thus MAPE=infinite

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/MeanAbsolutePercentageErrorEvaluator.cs

    r482 r555  
    5757    public override void Evaluate(int start, int end) {
    5858      double errorsSum = 0.0;
     59      int n = 0;
    5960      for(int sample = start; sample < end; sample++) {
    6061        double estimated = GetEstimatedValue(sample);
    6162        double original = GetOriginalValue(sample);
    6263        SetOriginalValue(sample, estimated);
    63         if(!double.IsNaN(original) && !double.IsInfinity(original)) {
     64        if(!double.IsNaN(original) && !double.IsInfinity(original) && original!=0.0) {
    6465          double percent_error = Math.Abs((estimated - original) / original);
    6566          errorsSum += percent_error;
     67          n++;
    6668        }
    6769      }
    68       double quality = errorsSum / (end - start);
     70      double quality = errorsSum / n;
    6971      if(double.IsNaN(quality) || double.IsInfinity(quality))
    7072        quality = double.MaxValue;
Note: See TracChangeset for help on using the changeset viewer.