Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7678


Ignore:
Timestamp:
03/30/12 23:10:26 (13 years ago)
Author:
mkommend
Message:

#1788: added new online calculators.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r7272 r7678  
    141141    <Compile Include="Interfaces\Regression\IRegressionEnsembleSolution.cs" />
    142142    <Compile Include="Implementation\Regression\RegressionSolutionBase.cs" />
     143    <Compile Include="OnlineCalculators\OnlineMaxAbsoluteErrorCalculator.cs" />
    143144    <Compile Include="OnlineCalculators\OnlineMeanErrorCalculator.cs" />
    144145    <Compile Include="OnlineCalculators\NormalizedGiniCalculator.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMaxAbsoluteErrorCalculator.cs

    r7670 r7678  
    2424
    2525namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineMeanAbsoluteErrorCalculator : IOnlineCalculator {
     26  public class OnlineMaxAbsoluteErrorCalculator : IOnlineCalculator {
    2727
    28     private double sae;
     28    private double mae;
    2929    private int n;
    30     public double MeanAbsoluteError {
     30    public double MaxAbsoluteError {
    3131      get {
    32         return n > 0 ? sae / n : 0.0;
     32        return n > 0 ? mae : 0.0;
    3333      }
    3434    }
    3535
    36     public OnlineMeanAbsoluteErrorCalculator() {
     36    public OnlineMaxAbsoluteErrorCalculator() {
    3737      Reset();
    3838    }
     
    4444    }
    4545    public double Value {
    46       get { return MeanAbsoluteError; }
     46      get { return MaxAbsoluteError; }
    4747    }
    4848    public void Reset() {
    4949      n = 0;
    50       sae = 0.0;
     50      mae = double.MinValue;
    5151      errorState = OnlineCalculatorError.InsufficientElementsAdded;
    5252    }
     
    5757        errorState = errorState | OnlineCalculatorError.InvalidValueAdded;
    5858      } else {
    59         double error = estimated - original;
    60         sae += Math.Abs(error);
     59        double error = Math.Abs(estimated - original);
     60        if (error > mae)
     61          mae = error;
    6162        n++;
    6263        errorState = errorState & (~OnlineCalculatorError.InsufficientElementsAdded);        // n >= 1
     
    6869      IEnumerator<double> originalEnumerator = originalValues.GetEnumerator();
    6970      IEnumerator<double> estimatedEnumerator = estimatedValues.GetEnumerator();
    70       OnlineMeanAbsoluteErrorCalculator maeCalculator = new OnlineMeanAbsoluteErrorCalculator();
     71      OnlineMaxAbsoluteErrorCalculator maeCalculator = new OnlineMaxAbsoluteErrorCalculator();
    7172
    7273      // always move forward both enumerators (do not use short-circuit evaluation!)
     
    8485      } else {
    8586        errorState = maeCalculator.ErrorState;
    86         return maeCalculator.MeanAbsoluteError;
     87        return maeCalculator.MaxAbsoluteError;
    8788      }
    8889    }
Note: See TracChangeset for help on using the changeset viewer.