Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/31/11 10:43:58 (14 years ago)
Author:
gkronber
Message:

#1453: improved performance of online evaluators.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineCovarianceEvaluator.cs

    r5894 r5904  
    5555
    5656    public void Add(double original, double estimated) {
    57       if (double.IsNaN(estimated) || double.IsInfinity(estimated) || double.IsNaN(original) || double.IsInfinity(original)) {
     57      if (double.IsNaN(estimated) || double.IsInfinity(estimated) || double.IsNaN(original) || double.IsInfinity(original) || (errorState & OnlineEvaluatorError.InvalidValueAdded) > 0) {
    5858        errorState = errorState | OnlineEvaluatorError.InvalidValueAdded;
    59       } else if (!errorState.HasFlag(OnlineEvaluatorError.InvalidValueAdded)) {
     59      } else {
    6060        n++;
    61         errorState = OnlineEvaluatorError.None;        // n >= 1
     61        errorState = errorState & (~OnlineEvaluatorError.InsufficientElementsAdded);        // n >= 1
    6262
    6363        // online calculation of tMean
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineMeanAbsolutePercentageErrorEvaluator.cs

    r5894 r5904  
    5858        original.IsAlmost(0.0)) {
    5959        errorState = errorState | OnlineEvaluatorError.InvalidValueAdded;
    60       } else if (!errorState.HasFlag(OnlineEvaluatorError.InvalidValueAdded)) {
     60      } else {
    6161        sre += Math.Abs((estimated - original) / original);
    6262        n++;
    63         errorState = OnlineEvaluatorError.None; // n >= 1
     63        errorState = errorState & (~OnlineEvaluatorError.InsufficientElementsAdded);        // n >= 1
    6464      }
    6565    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineMeanAndVarianceCalculator.cs

    r5894 r5904  
    7474
    7575    public void Add(double x) {
    76       if (double.IsNaN(x) || double.IsInfinity(x)) {
     76      if (double.IsNaN(x) || double.IsInfinity(x) || (errorState & OnlineEvaluatorError.InvalidValueAdded) > 0) {
    7777        errorState = errorState | OnlineEvaluatorError.InvalidValueAdded;
    7878        varianceErrorState = errorState | OnlineEvaluatorError.InvalidValueAdded;
    79       } else if (!errorState.HasFlag(OnlineEvaluatorError.InvalidValueAdded)) {
     79      } else {
    8080        n++;
    8181        // See Knuth TAOCP vol 2, 3rd edition, page 232
     
    8383          m_oldM = m_newM = x;
    8484          m_oldS = 0.0;
    85           errorState = OnlineEvaluatorError.None; // n >= 1
     85          errorState = errorState & (~OnlineEvaluatorError.InsufficientElementsAdded);        // n >= 1
    8686        } else {
    87           varianceErrorState = OnlineEvaluatorError.None; // n >= 1
     87          varianceErrorState = varianceErrorState & (~OnlineEvaluatorError.InsufficientElementsAdded);        // n >= 2
    8888          m_newM = m_oldM + (x - m_oldM) / n;
    8989          m_newS = m_oldS + (x - m_oldM) * (x - m_newM);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineMeanSquaredErrorEvaluator.cs

    r5894 r5904  
    5454    public void Add(double original, double estimated) {
    5555      if (double.IsNaN(estimated) || double.IsInfinity(estimated) ||
    56           double.IsNaN(original) || double.IsInfinity(original)) {
     56          double.IsNaN(original) || double.IsInfinity(original) || (errorState & OnlineEvaluatorError.InvalidValueAdded) > 0) {
    5757        errorState = errorState | OnlineEvaluatorError.InvalidValueAdded;
    58       } else if (!errorState.HasFlag(OnlineEvaluatorError.InvalidValueAdded)) {
     58      } else {
    5959        double error = estimated - original;
    6060        sse += error * error;
    6161        n++;
    62         errorState = OnlineEvaluatorError.None; // n >= 1
     62        errorState = errorState & (~OnlineEvaluatorError.InsufficientElementsAdded);        // n >= 1
    6363      }
    6464    }
Note: See TracChangeset for help on using the changeset viewer.