Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6964


Ignore:
Timestamp:
11/08/11 12:16:27 (13 years ago)
Author:
gkronber
Message:

#1670 changed remaining calculators to follow originalValues/estimatedValues convention.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/NormalizedGiniCalculator.cs

    r6913 r6964  
    2828  public class NormalizedGiniCalculator {
    2929
    30     public static double Calculate(IEnumerable<double> original, IEnumerable<double> estimated, out OnlineCalculatorError errorState) {
    31       if (original.Count() != estimated.Count()) {
    32         throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
     30    public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
     31      var originalValuesArr = originalValues.ToArray();
     32      var estimatedValuesArr = estimatedValues.ToArray();
     33      if (originalValuesArr.Count() != estimatedValuesArr.Count()) {
     34        throw new ArgumentException("Number of elements in originalValues and estimatedValues enumerations doesn't match.");
    3335      }
    34       double oe = Gini(original, estimated, out errorState);
     36      double oe = Gini(originalValuesArr, estimatedValuesArr, out errorState);
    3537      if (errorState != OnlineCalculatorError.None) return double.NaN;
    3638
    37       return oe / (Gini(original, original, out errorState));
     39      return oe / (Gini(originalValuesArr, estimatedValuesArr, out errorState));
    3840    }
    3941
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineAccuracyCalculator.cs

    r6961 r6964  
    8484      if (accuracyCalculator.ErrorState == OnlineCalculatorError.None &&
    8585          (estimatedEnumerator.MoveNext() || originalEnumerator.MoveNext())) {
    86         throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
     86        throw new ArgumentException("Number of elements in originalValues and estimatedValues enumerations doesn't match.");
    8787      } else {
    8888        errorState = accuracyCalculator.ErrorState;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineCovarianceCalcualtor.cs

    r5945 r6964  
    2626  public class OnlineCovarianceCalculator : IOnlineCalculator {
    2727
    28     private double originalMean, estimatedMean, Cn;
     28    private double xMean, yMean, Cn;
    2929    private int n;
    3030    public double Covariance {
     
    4949      n = 0;
    5050      Cn = 0.0;
    51       originalMean = 0.0;
    52       estimatedMean = 0.0;
     51      xMean = 0.0;
     52      yMean = 0.0;
    5353      errorState = OnlineCalculatorError.InsufficientElementsAdded;
    5454    }
    5555
    56     public void Add(double original, double estimated) {
    57       if (double.IsNaN(estimated) || double.IsInfinity(estimated) || double.IsNaN(original) || double.IsInfinity(original) || (errorState & OnlineCalculatorError.InvalidValueAdded) > 0) {
     56    public void Add(double x, double y) {
     57      if (double.IsNaN(y) || double.IsInfinity(y) || double.IsNaN(x) || double.IsInfinity(x) || (errorState & OnlineCalculatorError.InvalidValueAdded) > 0) {
    5858        errorState = errorState | OnlineCalculatorError.InvalidValueAdded;
    5959      } else {
     
    6262
    6363        // online calculation of tMean
    64         originalMean = originalMean + (original - originalMean) / n;
    65         double delta = estimated - estimatedMean; // delta = (y - yMean(n-1))
    66         estimatedMean = estimatedMean + delta / n;
     64        xMean = xMean + (x - xMean) / n;
     65        double delta = y - yMean; // delta = (y - yMean(n-1))
     66        yMean = yMean + delta / n;
    6767
    6868        // online calculation of covariance
    69         Cn = Cn + delta * (original - originalMean); // C(n) = C(n-1) + (y - yMean(n-1)) (t - tMean(n))       
     69        Cn = Cn + delta * (x - xMean); // C(n) = C(n-1) + (y - yMean(n-1)) (t - tMean(n))       
    7070      }
    7171    }
     
    7979      // always move forward both enumerators (do not use short-circuit evaluation!)
    8080      while (firstEnumerator.MoveNext() & secondEnumerator.MoveNext()) {
    81         double estimated = secondEnumerator.Current;
    82         double original = firstEnumerator.Current;
    83         covarianceCalculator.Add(original, estimated);
     81        double x = secondEnumerator.Current;
     82        double y = firstEnumerator.Current;
     83        covarianceCalculator.Add(x, y);
    8484        if (covarianceCalculator.ErrorState != OnlineCalculatorError.None) break;
    8585      }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineDirectionalSymmetryCalculator.cs

    r6802 r6964  
    7878
    7979
    80     public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
    81       IEnumerator<double> firstEnumerator = first.GetEnumerator();
    82       IEnumerator<double> secondEnumerator = second.GetEnumerator();
     80    public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
     81      IEnumerator<double> originalEnumerator = originalValues.GetEnumerator();
     82      IEnumerator<double> estimatedEnumerator = estimatedValues.GetEnumerator();
    8383      OnlineDirectionalSymmetryCalculator dsCalculator = new OnlineDirectionalSymmetryCalculator();
    8484
    8585      // add first element of time series as a reference point
    86       firstEnumerator.MoveNext();
    87       secondEnumerator.MoveNext();
    88       dsCalculator.Add(firstEnumerator.Current, secondEnumerator.Current);
     86      originalEnumerator.MoveNext();
     87      estimatedEnumerator.MoveNext();
     88      dsCalculator.Add(originalEnumerator.Current, estimatedEnumerator.Current);
    8989     
    9090      // always move forward both enumerators (do not use short-circuit evaluation!)
    91       while (firstEnumerator.MoveNext() & secondEnumerator.MoveNext()) {
    92         double estimated = secondEnumerator.Current;
    93         double original = firstEnumerator.Current;
     91      while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) {
     92        double original = originalEnumerator.Current;
     93        double estimated = estimatedEnumerator.Current;
    9494        dsCalculator.Add(original, estimated);
    9595        if (dsCalculator.ErrorState != OnlineCalculatorError.None) break;
     
    9898      // check if both enumerators are at the end to make sure both enumerations have the same length
    9999      if (dsCalculator.ErrorState == OnlineCalculatorError.None &&
    100           (secondEnumerator.MoveNext() || firstEnumerator.MoveNext())) {
    101         throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
     100          (originalEnumerator.MoveNext() || estimatedEnumerator.MoveNext())) {
     101        throw new ArgumentException("Number of elements in originalValues and estimatedValues enumerations doesn't match.");
    102102      } else {
    103103        errorState = dsCalculator.ErrorState;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAbsoluteErrorCalculator.cs

    r6961 r6964  
    8181      if (maeCalculator.ErrorState == OnlineCalculatorError.None &&
    8282         (estimatedEnumerator.MoveNext() || originalEnumerator.MoveNext())) {
    83         throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
     83        throw new ArgumentException("Number of elements in originalValues and estimatedValues enumerations doesn't match.");
    8484      } else {
    8585        errorState = maeCalculator.ErrorState;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanAbsolutePercentageErrorCalculator.cs

    r6961 r6964  
    8383      if (calculator.ErrorState == OnlineCalculatorError.None &&
    8484            (estimatedEnumerator.MoveNext() || originalEnumerator.MoveNext())) {
    85         throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
     85        throw new ArgumentException("Number of elements in originalValues and second estimatedValues doesn't match.");
    8686      } else {
    8787        errorState = calculator.ErrorState;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanSquaredErrorCalculator.cs

    r6961 r6964  
    8181      if (mseCalculator.ErrorState == OnlineCalculatorError.None &&
    8282         (estimatedEnumerator.MoveNext() || originalEnumerator.MoveNext())) {
    83         throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
     83        throw new ArgumentException("Number of elements in originalValues and estimatedValues enumerations doesn't match.");
    8484      } else {
    8585        errorState = mseCalculator.ErrorState;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineNormalizedMeanSquaredErrorCalculator.cs

    r6961 r6964  
    7777      // always move forward both enumerators (do not use short-circuit evaluation!)
    7878      while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) {
     79        double original = originalEnumerator.Current;
    7980        double estimated = estimatedEnumerator.Current;
    80         double original = originalEnumerator.Current;
    8181        normalizedMSECalculator.Add(original, estimated);
    8282        if (normalizedMSECalculator.ErrorState != OnlineCalculatorError.None) break;
     
    8686      if (normalizedMSECalculator.ErrorState == OnlineCalculatorError.None &&
    8787           (estimatedEnumerator.MoveNext() || originalEnumerator.MoveNext())) {
    88         throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
     88        throw new ArgumentException("Number of elements in originalValues and estimatedValues enumeration doesn't match.");
    8989      } else {
    9090        errorState = normalizedMSECalculator.ErrorState;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineTheilsUStatisticCalculator.cs

    r6961 r6964  
    103103      if (calculator.ErrorState == OnlineCalculatorError.None &&
    104104          (estimatedValuesEnumerator.MoveNext() || originalValuesEnumerator.MoveNext())) {
    105         throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
     105        throw new ArgumentException("Number of elements in originalValues and estimatedValues enumerations doesn't match.");
    106106      } else {
    107107        errorState = calculator.ErrorState;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineWeightedDirectionalSymmetryCalculator.cs

    r6807 r6964  
    8383
    8484
    85     public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
    86       IEnumerator<double> firstEnumerator = first.GetEnumerator();
    87       IEnumerator<double> secondEnumerator = second.GetEnumerator();
     85    public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
     86      IEnumerator<double> originalEnumerator = originalValues.GetEnumerator();
     87      IEnumerator<double> estimatedEnumerator = estimatedValues.GetEnumerator();
    8888      OnlineWeightedDirectionalSymmetryCalculator dsCalculator = new OnlineWeightedDirectionalSymmetryCalculator();
    89      
     89
    9090      // add first element of time series as a reference point
    91       firstEnumerator.MoveNext();
    92       secondEnumerator.MoveNext();
    93       dsCalculator.Add(firstEnumerator.Current, secondEnumerator.Current);
     91      originalEnumerator.MoveNext();
     92      estimatedEnumerator.MoveNext();
     93      dsCalculator.Add(originalEnumerator.Current, estimatedEnumerator.Current);
    9494
    9595      // always move forward both enumerators (do not use short-circuit evaluation!)
    96       while (firstEnumerator.MoveNext() & secondEnumerator.MoveNext()) {
    97         double estimated = secondEnumerator.Current;
    98         double original = firstEnumerator.Current;
     96      while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) {
     97        double original = originalEnumerator.Current;
     98        double estimated = estimatedEnumerator.Current;
    9999        dsCalculator.Add(original, estimated);
    100100        if (dsCalculator.ErrorState != OnlineCalculatorError.None) break;
     
    103103      // check if both enumerators are at the end to make sure both enumerations have the same length
    104104      if (dsCalculator.ErrorState == OnlineCalculatorError.None &&
    105           (secondEnumerator.MoveNext() || firstEnumerator.MoveNext())) {
    106         throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
     105          (originalEnumerator.MoveNext() || estimatedEnumerator.MoveNext())) {
     106        throw new ArgumentException("Number of elements in originalValues and estimatedValues enumerations doesn't match.");
    107107      } else {
    108108        errorState = dsCalculator.ErrorState;
Note: See TracChangeset for help on using the changeset viewer.