Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/30/11 18:04:03 (14 years ago)
Author:
gkronber
Message:

#1453: Added an ErrorState property to online evaluators to indicate if the result value is valid or if there has been an error in the calculation. Adapted all classes that use one of the online evaluators to check this property.

File:
1 edited

Legend:

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

    r5845 r5894  
    3939
    4040    #region IOnlineEvaluator Members
     41    private OnlineEvaluatorError errorState;
     42    public OnlineEvaluatorError ErrorState {
     43      get { return errorState; }
     44    }
    4145    public double Value {
    4246      get { return MeanSquaredError; }
     
    4549      n = 0;
    4650      sse = 0.0;
     51      errorState = OnlineEvaluatorError.InsufficientElementsAdded;
    4752    }
    4853
    4954    public void Add(double original, double estimated) {
    5055      if (double.IsNaN(estimated) || double.IsInfinity(estimated) ||
    51           double.IsNaN(original) || double.IsInfinity(original) ||
    52         double.IsNaN(sse)) {
    53         sse = double.NaN;
    54       } else {
     56          double.IsNaN(original) || double.IsInfinity(original)) {
     57        errorState = errorState | OnlineEvaluatorError.InvalidValueAdded;
     58      } else if (!errorState.HasFlag(OnlineEvaluatorError.InvalidValueAdded)) {
    5559        double error = estimated - original;
    5660        sse += error * error;
    5761        n++;
     62        errorState = OnlineEvaluatorError.None; // n >= 1
    5863      }
    5964    }
    6065    #endregion
    6166
    62     public static double Calculate(IEnumerable<double> first, IEnumerable<double> second) {
     67    public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineEvaluatorError errorState) {
    6368      IEnumerator<double> firstEnumerator = first.GetEnumerator();
    6469      IEnumerator<double> secondEnumerator = second.GetEnumerator();
     
    7681        throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
    7782      } else {
     83        errorState = mseEvaluator.ErrorState;
    7884        return mseEvaluator.MeanSquaredError;
    7985      }
Note: See TracChangeset for help on using the changeset viewer.