Changeset 5942


Ignore:
Timestamp:
04/04/11 15:38:16 (9 years ago)
Author:
mkommend
Message:

#1453: Renamed IOnlineEvaluator to IOnlineCalculator

Location:
trunk/sources
Files:
19 edited
7 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs

    r5894 r5942  
    8484      var classifier = new SymbolicDiscriminantFunctionClassificationModel(tree, interpreter);
    8585      classifier.SetThresholdsAndClassValues(thresholds, classValues);
    86       OnlineEvaluatorError errorState;
    87       double originalAccuracy = OnlineAccuracyEvaluator.Calculate(targetClassValues, classifier.GetEstimatedClassValues(dataset, rows), out errorState);
    88       if (errorState != OnlineEvaluatorError.None) originalAccuracy = 0.0;
     86      OnlineCalculatorError errorState;
     87      double originalAccuracy = OnlineAccuracyCalculator.Calculate(targetClassValues, classifier.GetEstimatedClassValues(dataset, rows), out errorState);
     88      if (errorState != OnlineCalculatorError.None) originalAccuracy = 0.0;
    8989
    9090      foreach (ISymbolicExpressionTreeNode node in nodes) {
     
    9999        classifier = new SymbolicDiscriminantFunctionClassificationModel(tree, interpreter);
    100100        classifier.SetThresholdsAndClassValues(thresholds, classValues);
    101         double newAccuracy = OnlineAccuracyEvaluator.Calculate(targetClassValues, classifier.GetEstimatedClassValues(dataset, rows), out errorState);
    102         if (errorState != OnlineEvaluatorError.None) newAccuracy = 0.0;
     101        double newAccuracy = OnlineAccuracyCalculator.Calculate(targetClassValues, classifier.GetEstimatedClassValues(dataset, rows), out errorState);
     102        if (errorState != OnlineCalculatorError.None) newAccuracy = 0.0;
    103103
    104104        // impact = 0 if no change
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs

    r5906 r5942  
    5656      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    5757      IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    58       OnlineEvaluatorError errorState;
    59       double mse = OnlineMeanSquaredErrorEvaluator.Calculate(originalValues, boundedEstimationValues, out errorState);
    60       if (errorState != OnlineEvaluatorError.None) mse = double.NaN;
     58      OnlineCalculatorError errorState;
     59      double mse = OnlineMeanSquaredErrorCalculator.Calculate(originalValues, boundedEstimationValues, out errorState);
     60      if (errorState != OnlineCalculatorError.None) mse = double.NaN;
    6161      return new double[2] { mse, solution.Length };
    6262    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r5906 r5942  
    3434      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    3535      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    36       OnlineEvaluatorError errorState;
    37       double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedValues, originalValues, out errorState);
    38       if (errorState != OnlineEvaluatorError.None) r2 = 0.0;
     36      OnlineCalculatorError errorState;
     37      double r2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedValues, originalValues, out errorState);
     38      if (errorState != OnlineCalculatorError.None) r2 = 0.0;
    3939      return new double[] { r2, solution.Length };
    4040
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveMeanSquaredErrorEvaluator.cs

    r5906 r5942  
    5656      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    5757      IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    58       OnlineEvaluatorError errorState;
    59       double mse = OnlineMeanSquaredErrorEvaluator.Calculate(originalValues, boundedEstimationValues, out errorState);
    60       if (errorState != OnlineEvaluatorError.None) return double.NaN;
     58      OnlineCalculatorError errorState;
     59      double mse = OnlineMeanSquaredErrorCalculator.Calculate(originalValues, boundedEstimationValues, out errorState);
     60      if (errorState != OnlineCalculatorError.None) return double.NaN;
    6161      else return mse;
    6262    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectivePearsonRSquaredEvaluator.cs

    r5906 r5942  
    5555      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    5656      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    57       OnlineEvaluatorError errorState;
    58       double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedValues, originalValues, out errorState);
    59       if (errorState != OnlineEvaluatorError.None) return 0.0;
     57      OnlineCalculatorError errorState;
     58      double r2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedValues, originalValues, out errorState);
     59      if (errorState != OnlineCalculatorError.None) return 0.0;
    6060      else return r2;
    6161    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationModel.cs

    r5894 r5942  
    124124      double alpha;
    125125      double beta;
    126       OnlineEvaluatorError errorState;
     126      OnlineCalculatorError errorState;
    127127      OnlineLinearScalingParameterCalculator.Calculate(estimatedValues, targetValues, out alpha, out beta, out errorState);
    128       if (errorState != OnlineEvaluatorError.None) return;
     128      if (errorState != OnlineCalculatorError.None) return;
    129129
    130130      ConstantTreeNode alphaTreeNode = null;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs

    r5894 r5942  
    7878        .ToArray();
    7979      var targetValues = dataset.GetEnumeratedVariableValues(targetVariable, rows);
    80       OnlineEvaluatorError errorState;
    81       double originalR2 = OnlinePearsonsRSquaredEvaluator.Calculate(targetValues, originalOutput, out errorState);
    82       if (errorState != OnlineEvaluatorError.None) originalR2 = 0.0;
     80      OnlineCalculatorError errorState;
     81      double originalR2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, originalOutput, out errorState);
     82      if (errorState != OnlineCalculatorError.None) originalR2 = 0.0;
    8383
    8484      foreach (ISymbolicExpressionTreeNode node in nodes) {
     
    8888        SwitchNode(parent, node, replacementNode);
    8989        var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows);
    90         double newR2 = OnlinePearsonsRSquaredEvaluator.Calculate(targetValues, newOutput, out errorState);
    91         if (errorState != OnlineEvaluatorError.None) newR2 = 0.0;
     90        double newR2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, newOutput, out errorState);
     91        if (errorState != OnlineCalculatorError.None) newR2 = 0.0;
    9292
    9393        // impact = 0 if no change
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs

    r5906 r5942  
    5656      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    5757      IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    58       OnlineEvaluatorError errorState;
    59       double mse = OnlineMeanSquaredErrorEvaluator.Calculate(originalValues, boundedEstimationValues, out errorState);
    60       if (errorState != OnlineEvaluatorError.None) mse = double.NaN;
     58      OnlineCalculatorError errorState;
     59      double mse = OnlineMeanSquaredErrorCalculator.Calculate(originalValues, boundedEstimationValues, out errorState);
     60      if (errorState != OnlineCalculatorError.None) mse = double.NaN;
    6161      return new double[2] { mse, solution.Length };
    6262    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r5906 r5942  
    5555      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    5656      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    57       OnlineEvaluatorError errorState;
    58       double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedValues, originalValues, out errorState);
    59       if (errorState != OnlineEvaluatorError.None) r2 = 0.0;
     57      OnlineCalculatorError errorState;
     58      double r2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedValues, originalValues, out errorState);
     59      if (errorState != OnlineCalculatorError.None) r2 = 0.0;
    6060      return new double[] { r2, solution.Length };
    6161    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs

    r5906 r5942  
    5858      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    5959      IEnumerable<double> boundedEstimationValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    60       OnlineEvaluatorError errorState;
    61       double mse = OnlineMeanSquaredErrorEvaluator.Calculate(originalValues, boundedEstimationValues, out errorState);
    62       if (errorState != OnlineEvaluatorError.None) return double.NaN;
     60      OnlineCalculatorError errorState;
     61      double mse = OnlineMeanSquaredErrorCalculator.Calculate(originalValues, boundedEstimationValues, out errorState);
     62      if (errorState != OnlineCalculatorError.None) return double.NaN;
    6363      else return mse;
    6464    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs

    r5906 r5942  
    5757      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    5858      IEnumerable<double> originalValues = problemData.Dataset.GetEnumeratedVariableValues(problemData.TargetVariable, rows);
    59       OnlineEvaluatorError errorState;
    60       double r2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedValues, originalValues, out errorState);
    61       if (errorState != OnlineEvaluatorError.None) return 0.0;
     59      OnlineCalculatorError errorState;
     60      double r2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedValues, originalValues, out errorState);
     61      if (errorState != OnlineCalculatorError.None) return 0.0;
    6262      else return r2;
    6363    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs

    r5914 r5942  
    6969      double alpha;
    7070      double beta;
    71       OnlineEvaluatorError errorState;
     71      OnlineCalculatorError errorState;
    7272      OnlineLinearScalingParameterCalculator.Calculate(estimatedValues, targetValues, out alpha, out beta, out errorState);
    73       if (errorState != OnlineEvaluatorError.None) return;
     73      if (errorState != OnlineCalculatorError.None) return;
    7474
    7575      ConstantTreeNode alphaTreeNode = null;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r5809 r5942  
    130130    <Compile Include="Interfaces\Clustering\IClusteringProblemData.cs" />
    131131    <Compile Include="Interfaces\Clustering\IClusteringSolution.cs" />
    132     <Compile Include="OnlineEvaluators\OnlineAccuracyEvaluator.cs" />
     132    <Compile Include="OnlineEvaluators\OnlineAccuracyCalculator.cs" />
    133133    <Compile Include="Implementation\Regression\RegressionProblemData.cs" />
    134134    <Compile Include="Implementation\DataAnalysisProblemData.cs" />
     
    142142    <Compile Include="Interfaces\IDataAnalysisProblemData.cs" />
    143143    <Compile Include="Interfaces\IDataAnalysisSolution.cs" />
    144     <Compile Include="Interfaces\IOnlineEvaluator.cs" />
     144    <Compile Include="Interfaces\IOnlineCalculator.cs" />
    145145    <Compile Include="Interfaces\Regression\IRegressionModel.cs" />
    146146    <Compile Include="Interfaces\Regression\IRegressionProblem.cs" />
    147147    <Compile Include="Interfaces\Regression\IRegressionProblemData.cs" />
    148148    <Compile Include="Interfaces\Regression\IRegressionSolution.cs" />
    149     <Compile Include="OnlineEvaluators\OnlineCovarianceEvaluator.cs" />
    150     <Compile Include="OnlineEvaluators\OnlineMeanAbsolutePercentageErrorEvaluator.cs" />
     149    <Compile Include="OnlineEvaluators\OnlineCovarianceCalcualtor.cs" />
     150    <Compile Include="OnlineEvaluators\OnlineMeanAbsolutePercentageErrorCalculator.cs" />
    151151    <Compile Include="OnlineEvaluators\OnlineMeanAndVarianceCalculator.cs" />
    152     <Compile Include="OnlineEvaluators\OnlineMeanSquaredErrorEvaluator.cs" />
    153     <Compile Include="OnlineEvaluators\OnlineNormalizedMeanSquaredErrorEvaluator.cs" />
    154     <Compile Include="OnlineEvaluators\OnlinePearsonsRSquaredEvaluator.cs" />
     152    <Compile Include="OnlineEvaluators\OnlineMeanSquaredErrorCalculator.cs" />
     153    <Compile Include="OnlineEvaluators\OnlineNormalizedMeanSquaredErrorCalculator.cs" />
     154    <Compile Include="OnlineEvaluators\OnlinePearsonsRSquaredCalculator.cs" />
    155155    <Compile Include="Implementation\Regression\RegressionSolution.cs" />
    156156    <Compile Include="TableFileParser.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs

    r5894 r5942  
    8585      IEnumerable<double> originalTestClassValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TestIndizes);
    8686
    87       OnlineEvaluatorError errorState;
    88       double trainingAccuracy = OnlineAccuracyEvaluator.Calculate(estimatedTrainingClassValues, originalTrainingClassValues, out errorState);
    89       if (errorState != OnlineEvaluatorError.None) trainingAccuracy = double.NaN;
    90       double testAccuracy = OnlineAccuracyEvaluator.Calculate(estimatedTestClassValues, originalTestClassValues, out errorState);
    91       if (errorState != OnlineEvaluatorError.None) testAccuracy = double.NaN;
     87      OnlineCalculatorError errorState;
     88      double trainingAccuracy = OnlineAccuracyCalculator.Calculate(estimatedTrainingClassValues, originalTrainingClassValues, out errorState);
     89      if (errorState != OnlineCalculatorError.None) trainingAccuracy = double.NaN;
     90      double testAccuracy = OnlineAccuracyCalculator.Calculate(estimatedTestClassValues, originalTestClassValues, out errorState);
     91      if (errorState != OnlineCalculatorError.None) testAccuracy = double.NaN;
    9292
    9393      TrainingAccuracy = trainingAccuracy;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolution.cs

    r5894 r5942  
    105105      IEnumerable<double> originalTestValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TestIndizes);
    106106
    107       OnlineEvaluatorError errorState;
    108       double trainingMSE = OnlineMeanSquaredErrorEvaluator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
    109       TrainingMeanSquaredError = errorState == OnlineEvaluatorError.None ? trainingMSE : double.NaN;
    110       double testMSE = OnlineMeanSquaredErrorEvaluator.Calculate(estimatedTestValues, originalTestValues, out errorState);
    111       TestMeanSquaredError = errorState == OnlineEvaluatorError.None ? testMSE : double.NaN;
     107      OnlineCalculatorError errorState;
     108      double trainingMSE = OnlineMeanSquaredErrorCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
     109      TrainingMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingMSE : double.NaN;
     110      double testMSE = OnlineMeanSquaredErrorCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState);
     111      TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMSE : double.NaN;
    112112
    113       double trainingR2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
    114       TrainingRSquared = errorState == OnlineEvaluatorError.None ? trainingR2 : double.NaN;
    115       double testR2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedTestValues, originalTestValues, out errorState);
    116       TestRSquared = errorState == OnlineEvaluatorError.None ? testR2 : double.NaN;
     113      double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
     114      TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
     115      double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState);
     116      TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
    117117    }
    118118
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/NormalDistributionCutPointsThresholdCalculator.cs

    r5894 r5942  
    6464        double classValue = group.Key;
    6565        double mean, variance;
    66         OnlineEvaluatorError meanErrorState, varianceErrorState;
     66        OnlineCalculatorError meanErrorState, varianceErrorState;
    6767        OnlineMeanAndVarianceCalculator.Calculate(estimatedClassValues, out mean, out variance, out meanErrorState, out varianceErrorState);
    6868
    69         if (meanErrorState == OnlineEvaluatorError.None && varianceErrorState == OnlineEvaluatorError.None) {
     69        if (meanErrorState == OnlineCalculatorError.None && varianceErrorState == OnlineCalculatorError.None) {
    7070          classMean[classValue] = mean;
    7171          classStdDev[classValue] = Math.Sqrt(variance);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs

    r5894 r5942  
    4040    private const string TrainingRelativeErrorResultName = "Average relative error (training)";
    4141    private const string TestRelativeErrorResultName = "Average relative error (test)";
     42    private const string TrainingNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (training)";
     43    private const string TestNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (test)";
    4244
    4345    public new IRegressionModel Model {
     
    8183    }
    8284
     85    public double TrainingNormalizedMeanSquaredError {
     86      get { return ((DoubleValue)this[TrainingNormalizedMeanSquaredErrorResultName].Value).Value; }
     87      private set { ((DoubleValue)this[TrainingNormalizedMeanSquaredErrorResultName].Value).Value = value; }
     88    }
     89
     90    public double TestNormalizedMeanSquaredError {
     91      get { return ((DoubleValue)this[TestNormalizedMeanSquaredErrorResultName].Value).Value; }
     92      private set { ((DoubleValue)this[TestNormalizedMeanSquaredErrorResultName].Value).Value = value; }
     93    }
     94
    8395
    8496    [StorableConstructor]
     
    95107      Add(new Result(TrainingRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the training partition", new PercentValue()));
    96108      Add(new Result(TestRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the test partition", new PercentValue()));
     109      Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, "", new DoubleValue()));
     110      Add(new Result(TestNormalizedMeanSquaredErrorResultName, "", new DoubleValue()));
    97111
    98112      RecalculateResults();
     
    114128      IEnumerable<double> originalTestValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TestIndizes);
    115129
    116       OnlineEvaluatorError errorState;
    117       double trainingMSE = OnlineMeanSquaredErrorEvaluator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
    118       TrainingMeanSquaredError = errorState == OnlineEvaluatorError.None ? trainingMSE : double.NaN;
    119       double testMSE = OnlineMeanSquaredErrorEvaluator.Calculate(estimatedTestValues, originalTestValues, out errorState);
    120       TestMeanSquaredError = errorState == OnlineEvaluatorError.None ? testMSE : double.NaN;
     130      OnlineCalculatorError errorState;
     131      double trainingMSE = OnlineMeanSquaredErrorCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
     132      TrainingMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingMSE : double.NaN;
     133      double testMSE = OnlineMeanSquaredErrorCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState);
     134      TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMSE : double.NaN;
    121135
    122       double trainingR2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
    123       TrainingRSquared = errorState == OnlineEvaluatorError.None ? trainingR2 : double.NaN;
    124       double testR2 = OnlinePearsonsRSquaredEvaluator.Calculate(estimatedTestValues, originalTestValues, out errorState);
    125       TestRSquared = errorState == OnlineEvaluatorError.None ? testR2 : double.NaN;
     136      double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
     137      TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
     138      double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState);
     139      TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
    126140
    127       double trainingRelError = OnlineMeanAbsolutePercentageErrorEvaluator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
    128       TrainingRelativeError = errorState == OnlineEvaluatorError.None ? trainingRelError : double.NaN;
    129       double testRelError = OnlineMeanAbsolutePercentageErrorEvaluator.Calculate(estimatedTestValues, originalTestValues, out errorState);
    130       TestRelativeError = errorState == OnlineEvaluatorError.None ? testRelError : double.NaN;
     141      double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
     142      TrainingRelativeError = errorState == OnlineCalculatorError.None ? trainingRelError : double.NaN;
     143      double testRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState);
     144      TestRelativeError = errorState == OnlineCalculatorError.None ? testRelError : double.NaN;
     145
     146      double trainingNMSE = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState);
     147      TrainingNormalizedMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingNMSE : double.NaN;
     148      double testNMSE = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState);
     149      TestNormalizedMeanSquaredError = errorState == OnlineCalculatorError.None ? testNMSE : double.NaN;
    131150    }
    132151
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IOnlineCalculator.cs

    r5941 r5942  
    2424namespace HeuristicLab.Problems.DataAnalysis {
    2525  [Flags]
    26   public enum OnlineEvaluatorError {
     26  public enum OnlineCalculatorError {
    2727    /// <summary>
    2828    /// No error occurred
     
    3838    InsufficientElementsAdded = 2
    3939  }
    40   public interface IOnlineEvaluator {
    41     OnlineEvaluatorError ErrorState { get; }
     40  public interface IOnlineCalculator {
     41    OnlineCalculatorError ErrorState { get; }
    4242    double Value { get; }
    4343    void Reset();
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineAccuracyCalculator.cs

    r5941 r5942  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using HeuristicLab.Common;
    24 using System.Collections.Generic;
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    27   public class OnlineAccuracyEvaluator : IOnlineEvaluator {
     27  public class OnlineAccuracyCalculator : IOnlineCalculator {
    2828
    2929    private int correctlyClassified;
     
    3535    }
    3636
    37     public OnlineAccuracyEvaluator() {
     37    public OnlineAccuracyCalculator() {
    3838      Reset();
    3939    }
    4040
    41     #region IOnlineEvaluator Members
    42     private OnlineEvaluatorError errorState;
    43     public OnlineEvaluatorError ErrorState {
     41    #region IOnlineCalculator Members
     42    private OnlineCalculatorError errorState;
     43    public OnlineCalculatorError ErrorState {
    4444      get { return errorState; }
    4545    }
     
    5050      n = 0;
    5151      correctlyClassified = 0;
    52       errorState = OnlineEvaluatorError.InsufficientElementsAdded;
     52      errorState = OnlineCalculatorError.InsufficientElementsAdded;
    5353    }
    5454
     
    6363          correctlyClassified++;
    6464        }
    65         errorState = OnlineEvaluatorError.None; // number of (non-NaN) samples >= 1
     65        errorState = OnlineCalculatorError.None; // number of (non-NaN) samples >= 1
    6666      }
    6767    }
    6868    #endregion
    6969
    70     public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineEvaluatorError errorState) {
     70    public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
    7171      IEnumerator<double> firstEnumerator = first.GetEnumerator();
    7272      IEnumerator<double> secondEnumerator = second.GetEnumerator();
    73       OnlineAccuracyEvaluator accuracyEvaluator = new OnlineAccuracyEvaluator();
     73      OnlineAccuracyCalculator accuracyCalculator = new OnlineAccuracyCalculator();
    7474
    7575      // always move forward both enumerators (do not use short-circuit evaluation!)
     
    7777        double estimated = secondEnumerator.Current;
    7878        double original = firstEnumerator.Current;
    79         accuracyEvaluator.Add(original, estimated);
     79        accuracyCalculator.Add(original, estimated);
    8080      }
    8181
     
    8484        throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
    8585      } else {
    86         errorState = accuracyEvaluator.ErrorState;
    87         return accuracyEvaluator.Accuracy;
     86        errorState = accuracyCalculator.ErrorState;
     87        return accuracyCalculator.Accuracy;
    8888      }
    8989    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineCovarianceCalcualtor.cs

    r5941 r5942  
    2424
    2525namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineCovarianceEvaluator : IOnlineEvaluator {
     26  public class OnlineCovarianceCalculator : IOnlineCalculator {
    2727
    2828    private double originalMean, estimatedMean, Cn;
     
    3434    }
    3535
    36     public OnlineCovarianceEvaluator() {
     36    public OnlineCovarianceCalculator() {
    3737      Reset();
    3838    }
    3939
    40     #region IOnlineEvaluator Members
    41     private OnlineEvaluatorError errorState;
    42     public OnlineEvaluatorError ErrorState {
     40    #region IOnlineCalculator Members
     41    private OnlineCalculatorError errorState;
     42    public OnlineCalculatorError ErrorState {
    4343      get { return errorState; }
    4444    }
     
    5151      originalMean = 0.0;
    5252      estimatedMean = 0.0;
    53       errorState = OnlineEvaluatorError.InsufficientElementsAdded;
     53      errorState = OnlineCalculatorError.InsufficientElementsAdded;
    5454    }
    5555
    5656    public void Add(double original, double estimated) {
    57       if (double.IsNaN(estimated) || double.IsInfinity(estimated) || double.IsNaN(original) || double.IsInfinity(original) || (errorState & OnlineEvaluatorError.InvalidValueAdded) > 0) {
    58         errorState = errorState | OnlineEvaluatorError.InvalidValueAdded;
     57      if (double.IsNaN(estimated) || double.IsInfinity(estimated) || double.IsNaN(original) || double.IsInfinity(original) || (errorState & OnlineCalculatorError.InvalidValueAdded) > 0) {
     58        errorState = errorState | OnlineCalculatorError.InvalidValueAdded;
    5959      } else {
    6060        n++;
    61         errorState = errorState & (~OnlineEvaluatorError.InsufficientElementsAdded);        // n >= 1
     61        errorState = errorState & (~OnlineCalculatorError.InsufficientElementsAdded);        // n >= 1
    6262
    6363        // online calculation of tMean
     
    7272    #endregion
    7373
    74     public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineEvaluatorError errorState) {
     74    public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
    7575      IEnumerator<double> firstEnumerator = first.GetEnumerator();
    7676      IEnumerator<double> secondEnumerator = second.GetEnumerator();
    77       OnlineCovarianceEvaluator covarianceEvaluator = new OnlineCovarianceEvaluator();
     77      OnlineCovarianceCalculator covarianceCalculator = new OnlineCovarianceCalculator();
    7878
    7979      // always move forward both enumerators (do not use short-circuit evaluation!)
     
    8181        double estimated = secondEnumerator.Current;
    8282        double original = firstEnumerator.Current;
    83         covarianceEvaluator.Add(original, estimated);
     83        covarianceCalculator.Add(original, estimated);
    8484      }
    8585
     
    8888        throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
    8989      } else {
    90         errorState = covarianceEvaluator.ErrorState;
    91         return covarianceEvaluator.Covariance;
     90        errorState = covarianceCalculator.ErrorState;
     91        return covarianceCalculator.Covariance;
    9292      }
    9393    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineLinearScalingParameterCalculator.cs

    r5894 r5942  
    4444          return 1;
    4545        else
    46           return originalTargetCovarianceEvaluator.Covariance / originalMeanAndVarianceCalculator.PopulationVariance;
     46          return originalTargetCovarianceCalculator.Covariance / originalMeanAndVarianceCalculator.PopulationVariance;
    4747      }
    4848    }
    4949
    50     public OnlineEvaluatorError ErrorState {
     50    public OnlineCalculatorError ErrorState {
    5151      get {
    5252        return targetMeanCalculator.MeanErrorState | originalMeanAndVarianceCalculator.MeanErrorState |
    53           originalMeanAndVarianceCalculator.PopulationVarianceErrorState | originalTargetCovarianceEvaluator.ErrorState;
     53          originalMeanAndVarianceCalculator.PopulationVarianceErrorState | originalTargetCovarianceCalculator.ErrorState;
    5454      }
    5555    }
     
    5858    private OnlineMeanAndVarianceCalculator targetMeanCalculator;
    5959    private OnlineMeanAndVarianceCalculator originalMeanAndVarianceCalculator;
    60     private OnlineCovarianceEvaluator originalTargetCovarianceEvaluator;
     60    private OnlineCovarianceCalculator originalTargetCovarianceCalculator;
    6161
    6262    public OnlineLinearScalingParameterCalculator() {
    6363      targetMeanCalculator = new OnlineMeanAndVarianceCalculator();
    6464      originalMeanAndVarianceCalculator = new OnlineMeanAndVarianceCalculator();
    65       originalTargetCovarianceEvaluator = new OnlineCovarianceEvaluator();
     65      originalTargetCovarianceCalculator = new OnlineCovarianceCalculator();
    6666      Reset();
    6767    }
     
    7171      targetMeanCalculator.Reset();
    7272      originalMeanAndVarianceCalculator.Reset();
    73       originalTargetCovarianceEvaluator.Reset();
     73      originalTargetCovarianceCalculator.Reset();
    7474    }
    7575
     
    8383      targetMeanCalculator.Add(target);
    8484      originalMeanAndVarianceCalculator.Add(original);
    85       originalTargetCovarianceEvaluator.Add(original, target);
     85      originalTargetCovarianceCalculator.Add(original, target);
    8686
    8787      cnt++;
     
    9797    /// <param name="beta">Multiplicative factor for the linear scaling</param>
    9898    /// <param name="errorState">Flag that indicates if errors occurred in the calculation of the linea scaling parameters.</param>
    99     public static void Calculate(IEnumerable<double> original, IEnumerable<double> target, out double alpha, out double beta, out OnlineEvaluatorError errorState) {
     99    public static void Calculate(IEnumerable<double> original, IEnumerable<double> target, out double alpha, out double beta, out OnlineCalculatorError errorState) {
    100100      OnlineLinearScalingParameterCalculator calculator = new OnlineLinearScalingParameterCalculator();
    101101      IEnumerator<double> originalEnumerator = original.GetEnumerator();
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineMeanAbsolutePercentageErrorCalculator.cs

    r5941 r5942  
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    27   public class OnlineMeanAbsolutePercentageErrorEvaluator : IOnlineEvaluator {
     27  public class OnlineMeanAbsolutePercentageErrorCalculator : IOnlineCalculator {
    2828
    2929    private double sre;
     
    3535    }
    3636
    37     public OnlineMeanAbsolutePercentageErrorEvaluator() {
     37    public OnlineMeanAbsolutePercentageErrorCalculator() {
    3838      Reset();
    3939    }
    4040
    41     #region IOnlineEvaluator Members
    42     private OnlineEvaluatorError errorState;
    43     public OnlineEvaluatorError ErrorState {
     41    #region IOnlineCalculator Members
     42    private OnlineCalculatorError errorState;
     43    public OnlineCalculatorError ErrorState {
    4444      get { return errorState; }
    4545    }
     
    5050      n = 0;
    5151      sre = 0.0;
    52       errorState = OnlineEvaluatorError.InsufficientElementsAdded;
     52      errorState = OnlineCalculatorError.InsufficientElementsAdded;
    5353    }
    5454
     
    5757          double.IsNaN(original) || double.IsInfinity(original) ||
    5858        original.IsAlmost(0.0)) {
    59         errorState = errorState | OnlineEvaluatorError.InvalidValueAdded;
     59        errorState = errorState | OnlineCalculatorError.InvalidValueAdded;
    6060      } else {
    6161        sre += Math.Abs((estimated - original) / original);
    6262        n++;
    63         errorState = errorState & (~OnlineEvaluatorError.InsufficientElementsAdded);        // n >= 1
     63        errorState = errorState & (~OnlineCalculatorError.InsufficientElementsAdded);        // n >= 1
    6464      }
    6565    }
     
    6767    #endregion
    6868
    69     public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineEvaluatorError errorState) {
     69    public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
    7070      IEnumerator<double> firstEnumerator = first.GetEnumerator();
    7171      IEnumerator<double> secondEnumerator = second.GetEnumerator();
    72       OnlineMeanAbsolutePercentageErrorEvaluator evaluator = new OnlineMeanAbsolutePercentageErrorEvaluator();
     72      OnlineMeanAbsolutePercentageErrorCalculator calculator = new OnlineMeanAbsolutePercentageErrorCalculator();
    7373
    7474      // always move forward both enumerators (do not use short-circuit evaluation!)
     
    7676        double estimated = secondEnumerator.Current;
    7777        double original = firstEnumerator.Current;
    78         evaluator.Add(original, estimated);
     78        calculator.Add(original, estimated);
    7979      }
    8080
     
    8383        throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
    8484      } else {
    85         errorState = evaluator.ErrorState;
    86         return evaluator.MeanAbsolutePercentageError;
     85        errorState = calculator.ErrorState;
     86        return calculator.MeanAbsolutePercentageError;
    8787      }
    8888    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineMeanAndVarianceCalculator.cs

    r5904 r5942  
    2929    private int n;
    3030
    31     private OnlineEvaluatorError varianceErrorState;
    32     public OnlineEvaluatorError VarianceErrorState {
     31    private OnlineCalculatorError varianceErrorState;
     32    public OnlineCalculatorError VarianceErrorState {
    3333      get { return varianceErrorState; }
    3434    }
     
    4040    }
    4141
    42     private OnlineEvaluatorError errorState;
    43     public OnlineEvaluatorError PopulationVarianceErrorState {
     42    private OnlineCalculatorError errorState;
     43    public OnlineCalculatorError PopulationVarianceErrorState {
    4444      get { return errorState; }
    4545    }
     
    5050    }
    5151
    52     public OnlineEvaluatorError MeanErrorState {
     52    public OnlineCalculatorError MeanErrorState {
    5353      get { return errorState; }
    5454    }
     
    6969    public void Reset() {
    7070      n = 0;
    71       errorState = OnlineEvaluatorError.InsufficientElementsAdded;
    72       varianceErrorState = OnlineEvaluatorError.InsufficientElementsAdded;
     71      errorState = OnlineCalculatorError.InsufficientElementsAdded;
     72      varianceErrorState = OnlineCalculatorError.InsufficientElementsAdded;
    7373    }
    7474
    7575    public void Add(double x) {
    76       if (double.IsNaN(x) || double.IsInfinity(x) || (errorState & OnlineEvaluatorError.InvalidValueAdded) > 0) {
    77         errorState = errorState | OnlineEvaluatorError.InvalidValueAdded;
    78         varianceErrorState = errorState | OnlineEvaluatorError.InvalidValueAdded;
     76      if (double.IsNaN(x) || double.IsInfinity(x) || (errorState & OnlineCalculatorError.InvalidValueAdded) > 0) {
     77        errorState = errorState | OnlineCalculatorError.InvalidValueAdded;
     78        varianceErrorState = errorState | OnlineCalculatorError.InvalidValueAdded;
    7979      } else {
    8080        n++;
     
    8383          m_oldM = m_newM = x;
    8484          m_oldS = 0.0;
    85           errorState = errorState & (~OnlineEvaluatorError.InsufficientElementsAdded);        // n >= 1
     85          errorState = errorState & (~OnlineCalculatorError.InsufficientElementsAdded);        // n >= 1
    8686        } else {
    87           varianceErrorState = varianceErrorState & (~OnlineEvaluatorError.InsufficientElementsAdded);        // n >= 2
     87          varianceErrorState = varianceErrorState & (~OnlineCalculatorError.InsufficientElementsAdded);        // n >= 2
    8888          m_newM = m_oldM + (x - m_oldM) / n;
    8989          m_newS = m_oldS + (x - m_oldM) * (x - m_newM);
     
    9696    }
    9797
    98     public static void Calculate(IEnumerable<double> x, out double mean, out double variance, out OnlineEvaluatorError meanErrorState, out OnlineEvaluatorError varianceErrorState) {
     98    public static void Calculate(IEnumerable<double> x, out double mean, out double variance, out OnlineCalculatorError meanErrorState, out OnlineCalculatorError varianceErrorState) {
    9999      OnlineMeanAndVarianceCalculator meanAndVarianceCalculator = new OnlineMeanAndVarianceCalculator();
    100100      foreach (double xi in x) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineMeanSquaredErrorCalculator.cs

    r5941 r5942  
    2424
    2525namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineMeanSquaredErrorEvaluator : IOnlineEvaluator {
     26  public class OnlineMeanSquaredErrorCalculator : IOnlineCalculator {
    2727
    2828    private double sse;
     
    3434    }
    3535
    36     public OnlineMeanSquaredErrorEvaluator() {
     36    public OnlineMeanSquaredErrorCalculator() {
    3737      Reset();
    3838    }
    3939
    40     #region IOnlineEvaluator Members
    41     private OnlineEvaluatorError errorState;
    42     public OnlineEvaluatorError ErrorState {
     40    #region IOnlineCalculator Members
     41    private OnlineCalculatorError errorState;
     42    public OnlineCalculatorError ErrorState {
    4343      get { return errorState; }
    4444    }
     
    4949      n = 0;
    5050      sse = 0.0;
    51       errorState = OnlineEvaluatorError.InsufficientElementsAdded;
     51      errorState = OnlineCalculatorError.InsufficientElementsAdded;
    5252    }
    5353
    5454    public void Add(double original, double estimated) {
    5555      if (double.IsNaN(estimated) || double.IsInfinity(estimated) ||
    56           double.IsNaN(original) || double.IsInfinity(original) || (errorState & OnlineEvaluatorError.InvalidValueAdded) > 0) {
    57         errorState = errorState | OnlineEvaluatorError.InvalidValueAdded;
     56          double.IsNaN(original) || double.IsInfinity(original) || (errorState & OnlineCalculatorError.InvalidValueAdded) > 0) {
     57        errorState = errorState | OnlineCalculatorError.InvalidValueAdded;
    5858      } else {
    5959        double error = estimated - original;
    6060        sse += error * error;
    6161        n++;
    62         errorState = errorState & (~OnlineEvaluatorError.InsufficientElementsAdded);        // n >= 1
     62        errorState = errorState & (~OnlineCalculatorError.InsufficientElementsAdded);        // n >= 1
    6363      }
    6464    }
    6565    #endregion
    6666
    67     public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineEvaluatorError errorState) {
     67    public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
    6868      IEnumerator<double> firstEnumerator = first.GetEnumerator();
    6969      IEnumerator<double> secondEnumerator = second.GetEnumerator();
    70       OnlineMeanSquaredErrorEvaluator mseEvaluator = new OnlineMeanSquaredErrorEvaluator();
     70      OnlineMeanSquaredErrorCalculator mseCalculator = new OnlineMeanSquaredErrorCalculator();
    7171
    7272      // always move forward both enumerators (do not use short-circuit evaluation!)
     
    7474        double estimated = secondEnumerator.Current;
    7575        double original = firstEnumerator.Current;
    76         mseEvaluator.Add(original, estimated);
     76        mseCalculator.Add(original, estimated);
    7777      }
    7878
     
    8181        throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
    8282      } else {
    83         errorState = mseEvaluator.ErrorState;
    84         return mseEvaluator.MeanSquaredError;
     83        errorState = mseCalculator.ErrorState;
     84        return mseCalculator.MeanSquaredError;
    8585      }
    8686    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlineNormalizedMeanSquaredErrorCalculator.cs

    r5941 r5942  
    2424
    2525namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineNormalizedMeanSquaredErrorEvaluator : IOnlineEvaluator {
     26  public class OnlineNormalizedMeanSquaredErrorCalculator : IOnlineCalculator {
    2727    private OnlineMeanAndVarianceCalculator meanSquaredErrorCalculator;
    2828    private OnlineMeanAndVarianceCalculator originalVarianceCalculator;
     
    3636    }
    3737
    38     public OnlineNormalizedMeanSquaredErrorEvaluator() {
     38    public OnlineNormalizedMeanSquaredErrorCalculator() {
    3939      meanSquaredErrorCalculator = new OnlineMeanAndVarianceCalculator();
    4040      originalVarianceCalculator = new OnlineMeanAndVarianceCalculator();
     
    4242    }
    4343
    44     #region IOnlineEvaluator Members
    45     public OnlineEvaluatorError ErrorState {
     44    #region IOnlineCalculator Members
     45    public OnlineCalculatorError ErrorState {
    4646      get { return meanSquaredErrorCalculator.MeanErrorState | originalVarianceCalculator.VarianceErrorState; }
    4747    }
     
    6363    #endregion
    6464
    65     public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineEvaluatorError errorState) {
     65    public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
    6666      IEnumerator<double> firstEnumerator = first.GetEnumerator();
    6767      IEnumerator<double> secondEnumerator = second.GetEnumerator();
    68       OnlineNormalizedMeanSquaredErrorEvaluator normalizedMSEEvaluator = new OnlineNormalizedMeanSquaredErrorEvaluator();
     68      OnlineNormalizedMeanSquaredErrorCalculator normalizedMSECalculator = new OnlineNormalizedMeanSquaredErrorCalculator();
    6969
    7070      // always move forward both enumerators (do not use short-circuit evaluation!)
     
    7272        double estimated = secondEnumerator.Current;
    7373        double original = firstEnumerator.Current;
    74         normalizedMSEEvaluator.Add(original, estimated);
     74        normalizedMSECalculator.Add(original, estimated);
    7575      }
    7676
     
    7979        throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
    8080      } else {
    81         errorState = normalizedMSEEvaluator.ErrorState;
    82         return normalizedMSEEvaluator.NormalizedMeanSquaredError;
     81        errorState = normalizedMSECalculator.ErrorState;
     82        return normalizedMSECalculator.NormalizedMeanSquaredError;
    8383      }
    8484    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineEvaluators/OnlinePearsonsRSquaredCalculator.cs

    r5941 r5942  
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    27   public class OnlinePearsonsRSquaredEvaluator : IOnlineEvaluator {
    28     private OnlineCovarianceEvaluator covEvaluator = new OnlineCovarianceEvaluator();
    29     private OnlineMeanAndVarianceCalculator sxEvaluator = new OnlineMeanAndVarianceCalculator();
    30     private OnlineMeanAndVarianceCalculator syEvaluator = new OnlineMeanAndVarianceCalculator();
     27  public class OnlinePearsonsRSquaredCalculator : IOnlineCalculator {
     28    private OnlineCovarianceCalculator covCalculator = new OnlineCovarianceCalculator();
     29    private OnlineMeanAndVarianceCalculator sxCalculator = new OnlineMeanAndVarianceCalculator();
     30    private OnlineMeanAndVarianceCalculator syCalculator = new OnlineMeanAndVarianceCalculator();
    3131
    3232    public double RSquared {
    3333      get {
    34         double xVar = sxEvaluator.PopulationVariance;
    35         double yVar = syEvaluator.PopulationVariance;
     34        double xVar = sxCalculator.PopulationVariance;
     35        double yVar = syCalculator.PopulationVariance;
    3636        if (xVar.IsAlmost(0.0) || yVar.IsAlmost(0.0)) {
    3737          return 0.0;
    3838        } else {
    39           double r = covEvaluator.Covariance / (Math.Sqrt(xVar) * Math.Sqrt(yVar));
     39          double r = covCalculator.Covariance / (Math.Sqrt(xVar) * Math.Sqrt(yVar));
    4040          return r * r;
    4141        }
     
    4343    }
    4444
    45     public OnlinePearsonsRSquaredEvaluator() { }
     45    public OnlinePearsonsRSquaredCalculator() { }
    4646
    47     #region IOnlineEvaluator Members
    48     public OnlineEvaluatorError ErrorState {
    49       get { return covEvaluator.ErrorState | sxEvaluator.PopulationVarianceErrorState | syEvaluator.PopulationVarianceErrorState; }
     47    #region IOnlineCalculator Members
     48    public OnlineCalculatorError ErrorState {
     49      get { return covCalculator.ErrorState | sxCalculator.PopulationVarianceErrorState | syCalculator.PopulationVarianceErrorState; }
    5050    }
    5151    public double Value {
     
    5353    }
    5454    public void Reset() {
    55       covEvaluator.Reset();
    56       sxEvaluator.Reset();
    57       syEvaluator.Reset();
     55      covCalculator.Reset();
     56      sxCalculator.Reset();
     57      syCalculator.Reset();
    5858    }
    5959
    6060    public void Add(double x, double y) {
    6161      // no need to check validity of values explicitly here as it is checked in all three evaluators
    62       covEvaluator.Add(x, y);
    63       sxEvaluator.Add(x);
    64       syEvaluator.Add(y);
     62      covCalculator.Add(x, y);
     63      sxCalculator.Add(x);
     64      syCalculator.Add(y);
    6565    }
    6666
    6767    #endregion
    6868
    69     public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineEvaluatorError errorState) {
     69    public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
    7070      IEnumerator<double> firstEnumerator = first.GetEnumerator();
    7171      IEnumerator<double> secondEnumerator = second.GetEnumerator();
    72       OnlinePearsonsRSquaredEvaluator rSquaredEvaluator = new OnlinePearsonsRSquaredEvaluator();
     72      OnlinePearsonsRSquaredCalculator rSquaredCalculator = new OnlinePearsonsRSquaredCalculator();
    7373
    7474      // always move forward both enumerators (do not use short-circuit evaluation!)
     
    7676        double estimated = secondEnumerator.Current;
    7777        double original = firstEnumerator.Current;
    78         rSquaredEvaluator.Add(original, estimated);
     78        rSquaredCalculator.Add(original, estimated);
    7979      }
    8080
     
    8383        throw new ArgumentException("Number of elements in first and second enumeration doesn't match.");
    8484      } else {
    85         errorState = rSquaredEvaluator.ErrorState;
    86         return rSquaredEvaluator.RSquared;
     85        errorState = rSquaredCalculator.ErrorState;
     86        return rSquaredCalculator.RSquared;
    8787      }
    8888    }
Note: See TracChangeset for help on using the changeset viewer.