Changeset 12641
- Timestamp:
- 07/07/15 13:34:55 (9 years ago)
- Location:
- trunk/sources
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs
r12012 r12641 57 57 OnlineCalculatorError errorState; 58 58 59 double r 2;59 double r; 60 60 if (applyLinearScaling) { 61 var r 2Calculator = new OnlinePearsonsRSquaredCalculator();62 CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, r 2Calculator, problemData.Dataset.Rows);63 errorState = r 2Calculator.ErrorState;64 r 2 = 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; 65 65 } else { 66 66 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 67 r 2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);67 r = OnlinePearsonsRCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState); 68 68 } 69 69 70 if (errorState != OnlineCalculatorError.None) r 2= double.NaN;71 return new double[2] { r 2, solution.Length };70 if (errorState != OnlineCalculatorError.None) r = double.NaN; 71 return new double[2] { r*r, solution.Length }; 72 72 73 73 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectivePearsonRSquaredEvaluator.cs
r12012 r12641 57 57 OnlineCalculatorError errorState; 58 58 59 double r 2;59 double r; 60 60 if (applyLinearScaling) { 61 var r 2Calculator = new OnlinePearsonsRSquaredCalculator();62 CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, r 2Calculator, problemData.Dataset.Rows);63 errorState = r 2Calculator.ErrorState;64 r 2 = 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; 65 65 } else { 66 66 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 67 r 2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);67 r = OnlinePearsonsRCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState); 68 68 } 69 69 if (errorState != OnlineCalculatorError.None) return double.NaN; 70 return r 2;70 return r*r; 71 71 } 72 72 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs
r12012 r12641 57 57 OnlineCalculatorError errorState; 58 58 59 double r 2;59 double r; 60 60 if (applyLinearScaling) { 61 var r 2Calculator = new OnlinePearsonsRSquaredCalculator();62 CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, r 2Calculator, problemData.Dataset.Rows);63 errorState = r 2Calculator.ErrorState;64 r 2 = 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; 65 65 } else { 66 66 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 67 r 2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);67 r = OnlinePearsonsRCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState); 68 68 } 69 69 70 if (errorState != OnlineCalculatorError.None) r 2= double.NaN;71 return new double[2] { r 2, solution.Length };70 if (errorState != OnlineCalculatorError.None) r = double.NaN; 71 return new double[2] { r*r, solution.Length }; 72 72 } 73 73 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs
r12012 r12641 59 59 OnlineCalculatorError errorState; 60 60 61 double r 2;61 double r; 62 62 if (applyLinearScaling) { 63 var r 2Calculator = new OnlinePearsonsRSquaredCalculator();64 CalculateWithScaling(targetValues, estimatedValues, lowerEstimationLimit, upperEstimationLimit, r 2Calculator, problemData.Dataset.Rows);65 errorState = r 2Calculator.ErrorState;66 r 2 = 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; 67 67 } else { 68 68 IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 69 r 2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);69 r = OnlinePearsonsRCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState); 70 70 } 71 71 if (errorState != OnlineCalculatorError.None) return double.NaN; 72 return r 2;72 return r*r; 73 73 } 74 74 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningOperator.cs
r12461 r12641 63 63 var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); 64 64 OnlineCalculatorError errorState; 65 var quality = OnlinePearsonsR SquaredCalculator.Calculate(targetValues, estimatedValues, out errorState);65 var quality = OnlinePearsonsRCalculator.Calculate(targetValues, estimatedValues, out errorState); 66 66 if (errorState != OnlineCalculatorError.None) return double.NaN; 67 return quality ;67 return quality*quality; 68 68 } 69 69 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolutionImpactValuesCalculator.cs
r12012 r12641 66 66 if (double.IsNaN(originalQuality)) { 67 67 var originalValues = regressionModel.GetEstimatedValues(dataset, rows); 68 originalQuality = OnlinePearsonsR SquaredCalculator.Calculate(targetValues, originalValues, out errorState);68 originalQuality = OnlinePearsonsRCalculator.Calculate(targetValues, originalValues, out errorState); 69 69 if (errorState != OnlineCalculatorError.None) originalQuality = 0.0; 70 70 } … … 83 83 84 84 var estimatedValues = tempModel.GetEstimatedValues(dataset, rows); 85 double newQuality = OnlinePearsonsR SquaredCalculator.Calculate(targetValues, estimatedValues, out errorState);85 double newQuality = OnlinePearsonsRCalculator.Calculate(targetValues, estimatedValues, out errorState); 86 86 if (errorState != OnlineCalculatorError.None) newQuality = 0.0; 87 87 88 impactValue = originalQuality - newQuality;88 impactValue = (originalQuality*originalQuality) - (newQuality*newQuality); 89 89 } 90 90 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis.Views/3.4/InteractiveSymbolicTimeSeriesPrognosisSolutionSimplifierView.cs
r12012 r12641 60 60 List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPostfix().ToList(); 61 61 OnlineCalculatorError errorState; 62 double originalR 2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, originalOutput, out errorState);63 if (errorState != OnlineCalculatorError.None) originalR 2= 0.0;62 double originalR = OnlinePearsonsRCalculator.Calculate(targetValues, originalOutput, out errorState); 63 if (errorState != OnlineCalculatorError.None) originalR = 0.0; 64 64 65 65 foreach (ISymbolicExpressionTreeNode node in nodes) { … … 69 69 SwitchNode(parent, node, replacementNode); 70 70 var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows); 71 double newR 2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, newOutput, out errorState);72 if (errorState != OnlineCalculatorError.None) newR 2= 0.0;71 double newR = OnlinePearsonsRCalculator.Calculate(targetValues, newOutput, out errorState); 72 if (errorState != OnlineCalculatorError.None) newR = 0.0; 73 73 74 74 // impact = 0 if no change 75 75 // impact < 0 if new solution is better 76 76 // impact > 0 if new solution is worse 77 double impact = originalR2 - newR2;77 double impact = (originalR*originalR) - (newR*newR); 78 78 impactAndReplacementValues[node] = new Tuple<double, double>(impact, constantNode.Value); 79 79 SwitchNode(parent, replacementNode, node); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreePhenotypicSimilarityCalculator.cs
r12103 r12641 65 65 66 66 OnlineCalculatorError error; 67 var r 2 = OnlinePearsonsRSquaredCalculator.Calculate(v1, v2, out error);67 var r = OnlinePearsonsRCalculator.Calculate(v1, v2, out error); 68 68 69 if (r 2> 1.0)70 r 2= 1.0;69 if (r > 1.0) 70 r = 1.0; 71 71 72 return error == OnlineCalculatorError.None ? r 2: 0;72 return error == OnlineCalculatorError.None ? r*r : 0; 73 73 } 74 74 … … 87 87 88 88 OnlineCalculatorError error; 89 var r 2 = OnlinePearsonsRSquaredCalculator.Calculate(leftValues, rightValues, out error);89 var r = OnlinePearsonsRCalculator.Calculate(leftValues, rightValues, out error); 90 90 91 if (r 2> 1.0)92 r 2 = 1.0; // sometimes due to fp errors it can happen that the r2is 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) 93 93 94 return error == OnlineCalculatorError.None ? r 2: 0;94 return error == OnlineCalculatorError.None ? r*r : 0; 95 95 } 96 96 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs
r12012 r12641 105 105 TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMSE : double.NaN; 106 106 107 double trainingR 2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);108 TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR 2: double.NaN;109 double testR 2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);110 TestRSquared = errorState == OnlineCalculatorError.None ? testR 2: 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; 111 111 112 112 double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs
r12581 r12641 229 229 TestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN; 230 230 231 double trainingR 2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);232 TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR 2: double.NaN;233 double testR 2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);234 TestRSquared = errorState == OnlineCalculatorError.None ? testR 2: 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; 235 235 236 236 double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisResults.cs
r12012 r12641 394 394 double trainingMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); 395 395 PrognosisTrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMAE : double.NaN; 396 double trainingR 2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);397 PrognosisTrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR 2: double.NaN;396 double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); 397 PrognosisTrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR*trainingR : double.NaN; 398 398 double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState); 399 399 PrognosisTrainingRelativeError = errorState == OnlineCalculatorError.None ? trainingRelError : double.NaN; … … 430 430 double testMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 431 431 PrognosisTestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN; 432 double testR 2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);433 PrognosisTestRSquared = errorState == OnlineCalculatorError.None ? testR 2: double.NaN;432 double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 433 PrognosisTestRSquared = errorState == OnlineCalculatorError.None ? testR*testR : double.NaN; 434 434 double testRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState); 435 435 PrognosisTestRelativeError = errorState == OnlineCalculatorError.None ? testRelError : double.NaN; -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRSquaredDependenceCalculator.cs
r12012 r12641 32 32 33 33 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; 35 36 } 36 37 }
Note: See TracChangeset
for help on using the changeset viewer.