Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12641


Ignore:
Timestamp:
07/07/15 13:34:55 (9 years ago)
Author:
gkronber
Message:

#2392: fixed all warnings by using PearsonsRCalculator instead of PearsonsRSquaredCalculator

Location:
trunk/sources
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r12012 r12641  
    5757      OnlineCalculatorError errorState;
    5858
    59       double r2;
     59      double r;
    6060      if (applyLinearScaling) {
    61         var r2Calculator = new OnlinePearsonsRSquaredCalculator();
    62         CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, r2Calculator, problemData.Dataset.Rows);
    63         errorState = r2Calculator.ErrorState;
    64         r2 = r2Calculator.RSquared;
     61        var rCalculator = new OnlinePearsonsRCalculator();
     62        CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, rCalculator, problemData.Dataset.Rows);
     63        errorState = rCalculator.ErrorState;
     64        r = rCalculator.R;
    6565      } else {
    6666        IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    67         r2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
     67        r = OnlinePearsonsRCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
    6868      }
    6969
    70       if (errorState != OnlineCalculatorError.None) r2 = double.NaN;
    71       return new double[2] { r2, solution.Length };
     70      if (errorState != OnlineCalculatorError.None) r = double.NaN;
     71      return new double[2] { r*r, solution.Length };
    7272
    7373    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectivePearsonRSquaredEvaluator.cs

    r12012 r12641  
    5757      OnlineCalculatorError errorState;
    5858
    59       double r2;
     59      double r;
    6060      if (applyLinearScaling) {
    61         var r2Calculator = new OnlinePearsonsRSquaredCalculator();
    62         CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, r2Calculator, problemData.Dataset.Rows);
    63         errorState = r2Calculator.ErrorState;
    64         r2 = r2Calculator.RSquared;
     61        var rCalculator = new OnlinePearsonsRCalculator();
     62        CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, rCalculator, problemData.Dataset.Rows);
     63        errorState = rCalculator.ErrorState;
     64        r = rCalculator.R;
    6565      } else {
    6666        IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    67         r2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
     67        r = OnlinePearsonsRCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
    6868      }
    6969      if (errorState != OnlineCalculatorError.None) return double.NaN;
    70       return r2;
     70      return r*r;
    7171    }
    7272
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r12012 r12641  
    5757      OnlineCalculatorError errorState;
    5858
    59       double r2;
     59      double r;
    6060      if (applyLinearScaling) {
    61         var r2Calculator = new OnlinePearsonsRSquaredCalculator();
    62         CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, r2Calculator, problemData.Dataset.Rows);
    63         errorState = r2Calculator.ErrorState;
    64         r2 = r2Calculator.RSquared;
     61        var rCalculator = new OnlinePearsonsRCalculator();
     62        CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, rCalculator, problemData.Dataset.Rows);
     63        errorState = rCalculator.ErrorState;
     64        r = rCalculator.R;
    6565      } else {
    6666        IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    67         r2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
     67        r = OnlinePearsonsRCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
    6868      }
    6969
    70       if (errorState != OnlineCalculatorError.None) r2 = double.NaN;
    71       return new double[2] { r2, solution.Length };
     70      if (errorState != OnlineCalculatorError.None) r = double.NaN;
     71      return new double[2] { r*r, solution.Length };
    7272    }
    7373
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs

    r12012 r12641  
    5959      OnlineCalculatorError errorState;
    6060
    61       double r2;
     61      double r;
    6262      if (applyLinearScaling) {
    63         var r2Calculator = new OnlinePearsonsRSquaredCalculator();
    64         CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, r2Calculator, problemData.Dataset.Rows);
    65         errorState = r2Calculator.ErrorState;
    66         r2 = r2Calculator.RSquared;
     63        var rCalculator = new OnlinePearsonsRCalculator();
     64        CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, rCalculator, problemData.Dataset.Rows);
     65        errorState = rCalculator.ErrorState;
     66        r = rCalculator.R;
    6767      } else {
    6868        IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    69         r2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
     69        r = OnlinePearsonsRCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
    7070      }
    7171      if (errorState != OnlineCalculatorError.None) return double.NaN;
    72       return r2;
     72      return r*r;
    7373    }
    7474
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningOperator.cs

    r12461 r12641  
    6363      var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    6464      OnlineCalculatorError errorState;
    65       var quality = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, estimatedValues, out errorState);
     65      var quality = OnlinePearsonsRCalculator.Calculate(targetValues, estimatedValues, out errorState);
    6666      if (errorState != OnlineCalculatorError.None) return double.NaN;
    67       return quality;
     67      return quality*quality;
    6868    }
    6969
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolutionImpactValuesCalculator.cs

    r12012 r12641  
    6666      if (double.IsNaN(originalQuality)) {
    6767        var originalValues = regressionModel.GetEstimatedValues(dataset, rows);
    68         originalQuality = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, originalValues, out errorState);
     68        originalQuality = OnlinePearsonsRCalculator.Calculate(targetValues, originalValues, out errorState);
    6969        if (errorState != OnlineCalculatorError.None) originalQuality = 0.0;
    7070      }
     
    8383
    8484      var estimatedValues = tempModel.GetEstimatedValues(dataset, rows);
    85       double newQuality = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, estimatedValues, out errorState);
     85      double newQuality = OnlinePearsonsRCalculator.Calculate(targetValues, estimatedValues, out errorState);
    8686      if (errorState != OnlineCalculatorError.None) newQuality = 0.0;
    8787
    88       impactValue = originalQuality - newQuality;
     88      impactValue = (originalQuality*originalQuality) - (newQuality*newQuality);
    8989    }
    9090  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views/3.4/InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs

    r12012 r12641  
    6060      List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPostfix().ToList();
    6161      OnlineCalculatorError errorState;
    62       double originalR2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, originalOutput, out errorState);
    63       if (errorState != OnlineCalculatorError.None) originalR2 = 0.0;
     62      double originalR = OnlinePearsonsRCalculator.Calculate(targetValues, originalOutput, out errorState);
     63      if (errorState != OnlineCalculatorError.None) originalR = 0.0;
    6464
    6565      foreach (ISymbolicExpressionTreeNode node in nodes) {
     
    6969        SwitchNode(parent, node, replacementNode);
    7070        var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows);
    71         double newR2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, newOutput, out errorState);
    72         if (errorState != OnlineCalculatorError.None) newR2 = 0.0;
     71        double newR = OnlinePearsonsRCalculator.Calculate(targetValues, newOutput, out errorState);
     72        if (errorState != OnlineCalculatorError.None) newR = 0.0;
    7373
    7474        // impact = 0 if no change
    7575        // impact < 0 if new solution is better
    7676        // impact > 0 if new solution is worse
    77         double impact = originalR2 - newR2;
     77        double impact = (originalR*originalR) - (newR*newR);
    7878        impactAndReplacementValues[node] = new Tuple<double, double>(impact, constantNode.Value);
    7979        SwitchNode(parent, replacementNode, node);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreePhenotypicSimilarityCalculator.cs

    r12103 r12641  
    6565
    6666      OnlineCalculatorError error;
    67       var r2 = OnlinePearsonsRSquaredCalculator.Calculate(v1, v2, out error);
     67      var r = OnlinePearsonsRCalculator.Calculate(v1, v2, out error);
    6868
    69       if (r2 > 1.0)
    70         r2 = 1.0;
     69      if (r > 1.0)
     70        r = 1.0;
    7171
    72       return error == OnlineCalculatorError.None ? r2 : 0;
     72      return error == OnlineCalculatorError.None ? r*r : 0;
    7373    }
    7474
     
    8787
    8888      OnlineCalculatorError error;
    89       var r2 = OnlinePearsonsRSquaredCalculator.Calculate(leftValues, rightValues, out error);
     89      var r = OnlinePearsonsRCalculator.Calculate(leftValues, rightValues, out error);
    9090
    91       if (r2 > 1.0)
    92         r2 = 1.0; // sometimes due to fp errors it can happen that the r2 is over 1 (like 1.0000000009)
     91      if (r > 1.0)
     92        r = 1.0; // sometimes due to fp errors it can happen that the correlation is over 1 (like 1.0000000009)
    9393
    94       return error == OnlineCalculatorError.None ? r2 : 0;
     94      return error == OnlineCalculatorError.None ? r*r : 0;
    9595    }
    9696  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs

    r12012 r12641  
    105105      TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMSE : double.NaN;
    106106
    107       double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    108       TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
    109       double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    110       TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
     107      double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     108      TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR*trainingR : double.NaN;
     109      double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     110      TestRSquared = errorState == OnlineCalculatorError.None ? testR*testR : double.NaN;
    111111
    112112      double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs

    r12581 r12641  
    229229      TestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN;
    230230
    231       double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    232       TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
    233       double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    234       TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
     231      double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     232      TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR*trainingR : double.NaN;
     233      double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     234      TestRSquared = errorState == OnlineCalculatorError.None ? testR*testR : double.NaN;
    235235
    236236      double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisResults.cs

    r12012 r12641  
    394394      double trainingMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    395395      PrognosisTrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMAE : double.NaN;
    396       double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    397       PrognosisTrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
     396      double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     397      PrognosisTrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR*trainingR : double.NaN;
    398398      double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    399399      PrognosisTrainingRelativeError = errorState == OnlineCalculatorError.None ? trainingRelError : double.NaN;
     
    430430      double testMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    431431      PrognosisTestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN;
    432       double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    433       PrognosisTestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
     432      double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     433      PrognosisTestRSquared = errorState == OnlineCalculatorError.None ? testR*testR : double.NaN;
    434434      double testRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    435435      PrognosisTestRelativeError = errorState == OnlineCalculatorError.None ? testRelError : double.NaN;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRSquaredDependenceCalculator.cs

    r12012 r12641  
    3232
    3333    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
    34       return OnlinePearsonsRSquaredCalculator.Calculate(originalValues, estimatedValues, out errorState);
     34      var r = OnlinePearsonsRCalculator.Calculate(originalValues, estimatedValues, out errorState);
     35      return r * r;
    3536    }
    3637  }
Note: See TracChangeset for help on using the changeset viewer.