Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2827


Ignore:
Timestamp:
02/18/10 13:52:57 (15 years ago)
Author:
gkronber
Message:

Fixed #879 (Calculation of Theil's inequality coefficient U2 should be based on relative errors instead of absolute errors)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Modeling/3.2/SimpleTheilInequalityCoefficientEvaluator.cs

    r2357 r2827  
    3434
    3535where P_t is the predicted change of the target variable and A_t is the measured (original) change.
    36 (P_t = y'_t - y_(t-1), A_t = y_t - y_(t-1)).
     36(P_t = (y'_t - y_(t-1)) / y_(t-1), A_t = (y_t - y_(t-1)) / y_(t-1)).
    3737
    3838U2 is 0 for a perfect prediction and 1 for the naive model y'_t = y_(t-1). An U2 > 1 means the
     
    5858      for (int sample = 1; sample < n; sample++) {
    5959        double prevValue = values[sample - 1, ORIGINAL_INDEX];
    60         double estimatedChange = values[sample, ESTIMATION_INDEX] - prevValue;
    61         double originalChange = values[sample, ORIGINAL_INDEX] - prevValue;
    62         if (!double.IsNaN(originalChange) && !double.IsInfinity(originalChange)) {
    63           double error = estimatedChange - originalChange;
    64           errorsSquaredSum += error * error;
    65           originalSquaredSum += originalChange * originalChange;
     60        double estimatedValue = values[sample, ESTIMATION_INDEX];
     61        double originalValue = values[sample, ORIGINAL_INDEX];
     62        if (!double.IsNaN(originalValue) && !double.IsInfinity(originalValue)) {
     63          double errorEstimatedChange = (estimatedValue - originalValue) / prevValue; // percentage error of predicted change
     64          errorsSquaredSum += errorEstimatedChange * errorEstimatedChange;
     65          double errorNoChange = (prevValue - originalValue) / prevValue; // percentage error of naive model y(t+1) = y(t)
     66          originalSquaredSum += errorNoChange * errorNoChange;
    6667          nSamples++;
    6768        }
Note: See TracChangeset for help on using the changeset viewer.