Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/17/12 11:18:40 (12 years ago)
Author:
mkommend
Message:

#1951:

  • Added linear scaling parameter to data analysis problems.
  • Adapted interfaces, evaluators and analyzers accordingly.
  • Added OnlineBoundedMeanSquaredErrorCalculator.
  • Adapted symbolic regression sample unit test.
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

    r8600 r8664  
    151151    <Compile Include="Interfaces\Regression\IRegressionEnsembleSolution.cs" />
    152152    <Compile Include="Implementation\Regression\RegressionSolutionBase.cs" />
     153    <Compile Include="OnlineCalculators\OnlineBoundedMeanSquaredErrorCalculator.cs" />
    153154    <Compile Include="OnlineCalculators\HoeffdingsDependenceCalculator.cs" />
    154155    <Compile Include="OnlineCalculators\OnlineMaxAbsoluteErrorCalculator.cs" />
     
    280281  -->
    281282  <PropertyGroup>
    282    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     283    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    283284set ProjectDir=$(ProjectDir)
    284285set SolutionDir=$(SolutionDir)
     
    287288call PreBuildEvent.cmd
    288289</PreBuildEvent>
    289 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     290    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    290291export ProjectDir=$(ProjectDir)
    291292export SolutionDir=$(SolutionDir)
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineBoundedMeanSquaredErrorCalculator.cs

    r8650 r8664  
    2424
    2525namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineMeanSquaredErrorCalculator : IOnlineCalculator {
     26  public class OnlineBoundedMeanSquaredErrorCalculator : IOnlineCalculator {
    2727
    28     private double sse;
     28    private double errorSum;
    2929    private int n;
    30     public double MeanSquaredError {
     30    public double BoundedMeanSquaredError {
    3131      get {
    32         return n > 0 ? sse / n : 0.0;
     32        return n > 0 ? errorSum / n : 0.0;
    3333      }
    3434    }
    3535
    36     public OnlineMeanSquaredErrorCalculator() {
     36    public double LowerBound { get; private set; }
     37    public double UpperBound { get; private set; }
     38
     39
     40    public OnlineBoundedMeanSquaredErrorCalculator(double lowerBound, double upperbound) {
     41      LowerBound = lowerBound;
     42      UpperBound = upperbound;
    3743      Reset();
    3844    }
     
    4450    }
    4551    public double Value {
    46       get { return MeanSquaredError; }
     52      get { return BoundedMeanSquaredError; }
    4753    }
    4854    public void Reset() {
    4955      n = 0;
    50       sse = 0.0;
     56      errorSum = 0.0;
    5157      errorState = OnlineCalculatorError.InsufficientElementsAdded;
    5258    }
     
    5864      } else {
    5965        double error = estimated - original;
    60         sse += error * error;
     66        if (estimated < LowerBound || estimated > UpperBound)
     67          errorSum += Math.Abs(error);
     68        else
     69          errorSum += error * error;
    6170        n++;
    6271        errorState = errorState & (~OnlineCalculatorError.InsufficientElementsAdded);        // n >= 1
     
    6574    #endregion
    6675
    67     public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
     76    public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, double lowerBound, double upperBound, out OnlineCalculatorError errorState) {
    6877      IEnumerator<double> originalEnumerator = originalValues.GetEnumerator();
    6978      IEnumerator<double> estimatedEnumerator = estimatedValues.GetEnumerator();
    70       OnlineMeanSquaredErrorCalculator mseCalculator = new OnlineMeanSquaredErrorCalculator();
     79      OnlineBoundedMeanSquaredErrorCalculator boundedMseCalculator = new OnlineBoundedMeanSquaredErrorCalculator(lowerBound, upperBound);
    7180
    7281      // always move forward both enumerators (do not use short-circuit evaluation!)
     
    7483        double original = originalEnumerator.Current;
    7584        double estimated = estimatedEnumerator.Current;
    76         mseCalculator.Add(original, estimated);
    77         if (mseCalculator.ErrorState != OnlineCalculatorError.None) break;
     85        boundedMseCalculator.Add(original, estimated);
     86        if (boundedMseCalculator.ErrorState != OnlineCalculatorError.None) break;
    7887      }
    7988
    8089      // check if both enumerators are at the end to make sure both enumerations have the same length
    81       if (mseCalculator.ErrorState == OnlineCalculatorError.None &&
     90      if (boundedMseCalculator.ErrorState == OnlineCalculatorError.None &&
    8291         (estimatedEnumerator.MoveNext() || originalEnumerator.MoveNext())) {
    8392        throw new ArgumentException("Number of elements in originalValues and estimatedValues enumerations doesn't match.");
    8493      } else {
    85         errorState = mseCalculator.ErrorState;
    86         return mseCalculator.MeanSquaredError;
     94        errorState = boundedMseCalculator.ErrorState;
     95        return boundedMseCalculator.BoundedMeanSquaredError;
    8796      }
    8897    }
Note: See TracChangeset for help on using the changeset viewer.