Changeset 5894 for trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineMeanSquaredErrorEvaluator.cs
- Timestamp:
- 03/30/11 18:04:03 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineMeanSquaredErrorEvaluator.cs
r5845 r5894 39 39 40 40 #region IOnlineEvaluator Members 41 private OnlineEvaluatorError errorState; 42 public OnlineEvaluatorError ErrorState { 43 get { return errorState; } 44 } 41 45 public double Value { 42 46 get { return MeanSquaredError; } … … 45 49 n = 0; 46 50 sse = 0.0; 51 errorState = OnlineEvaluatorError.InsufficientElementsAdded; 47 52 } 48 53 49 54 public void Add(double original, double estimated) { 50 55 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)) { 55 59 double error = estimated - original; 56 60 sse += error * error; 57 61 n++; 62 errorState = OnlineEvaluatorError.None; // n >= 1 58 63 } 59 64 } 60 65 #endregion 61 66 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) { 63 68 IEnumerator<double> firstEnumerator = first.GetEnumerator(); 64 69 IEnumerator<double> secondEnumerator = second.GetEnumerator(); … … 76 81 throw new ArgumentException("Number of elements in first and second enumeration doesn't match."); 77 82 } else { 83 errorState = mseEvaluator.ErrorState; 78 84 return mseEvaluator.MeanSquaredError; 79 85 }
Note: See TracChangeset
for help on using the changeset viewer.