Changeset 12495 for branches/GBT/HeuristicLab.Problems.DataAnalysis
- Timestamp:
- 06/23/15 12:50:05 (9 years ago)
- Location:
- branches/GBT
- Files:
-
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GBT
- Property svn:mergeinfo changed
/trunk/sources merged: 12392-12393,12397-12401,12422,12424,12428-12435,12442-12443,12445,12455-12458,12461,12463-12465,12470-12476,12478-12482,12485,12488,12490-12494 -
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:mergeinfo changed
-
branches/GBT/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis (added) merged: 12485,12492
- Property svn:mergeinfo changed
-
branches/GBT/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r11763 r12495 222 222 <Compile Include="OnlineCalculators\OnlineMeanSquaredErrorCalculator.cs" /> 223 223 <Compile Include="OnlineCalculators\OnlineNormalizedMeanSquaredErrorCalculator.cs" /> 224 <Compile Include="OnlineCalculators\OnlinePearsonsRCalculator.cs" /> 224 225 <Compile Include="OnlineCalculators\OnlinePearsonsRSquaredCalculator.cs" /> 225 226 <Compile Include="Implementation\Regression\RegressionSolution.cs" /> -
branches/GBT/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs
r12012 r12495 30 30 /// </summary> 31 31 [StorableClass] 32 public abstractclass ClassificationSolution : ClassificationSolutionBase {32 public class ClassificationSolution : ClassificationSolutionBase { 33 33 protected readonly Dictionary<int, double> evaluationCache; 34 34 … … 46 46 evaluationCache = new Dictionary<int, double>(problemData.Dataset.Rows); 47 47 CalculateClassificationResults(); 48 } 49 50 public override IDeepCloneable Clone(Cloner cloner) { 51 return new ClassificationSolution(this, cloner); 48 52 } 49 53 -
branches/GBT/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRDependenceCalculator.cs
r12012 r12495 33 33 34 34 public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) { 35 return Math.Sqrt(OnlinePearsonsRSquaredCalculator.Calculate(originalValues, estimatedValues, out errorState));35 return OnlinePearsonsRCalculator.Calculate(originalValues, estimatedValues, out errorState); 36 36 } 37 37 } -
branches/GBT/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlinePearsonsRSquaredCalculator.cs
r12012 r12495 25 25 26 26 namespace HeuristicLab.Problems.DataAnalysis { 27 [Obsolete("Use OnlinePearsonsRCalculator directly")] 27 28 public class OnlinePearsonsRSquaredCalculator : IOnlineCalculator { 28 private OnlineCovarianceCalculator covCalculator = new OnlineCovarianceCalculator(); 29 private OnlineMeanAndVarianceCalculator sxCalculator = new OnlineMeanAndVarianceCalculator(); 30 private OnlineMeanAndVarianceCalculator syCalculator = new OnlineMeanAndVarianceCalculator(); 29 private readonly OnlinePearsonsRCalculator rCalculator = new OnlinePearsonsRCalculator(); 31 30 32 31 public double RSquared { 33 32 get { 34 double xVar = sxCalculator.PopulationVariance; 35 double yVar = syCalculator.PopulationVariance; 36 if (xVar.IsAlmost(0.0) || yVar.IsAlmost(0.0)) { 37 return 0.0; 38 } else { 39 double r = covCalculator.Covariance / (Math.Sqrt(xVar) * Math.Sqrt(yVar)); 40 return r * r; 41 } 33 if (rCalculator.ErrorState != OnlineCalculatorError.None) return 0.0; 34 else return rCalculator.R * rCalculator.R; 42 35 } 43 36 } … … 47 40 #region IOnlineCalculator Members 48 41 public OnlineCalculatorError ErrorState { 49 get { return covCalculator.ErrorState | sxCalculator.PopulationVarianceErrorState | syCalculator.PopulationVarianceErrorState; }42 get { return rCalculator.ErrorState; } 50 43 } 51 44 public double Value { … … 53 46 } 54 47 public void Reset() { 55 covCalculator.Reset(); 56 sxCalculator.Reset(); 57 syCalculator.Reset(); 48 rCalculator.Reset(); 58 49 } 59 50 60 51 public void Add(double x, double y) { 61 // no need to check validity of values explicitly here as it is checked in all three evaluators 62 covCalculator.Add(x, y); 63 sxCalculator.Add(x); 64 syCalculator.Add(y); 52 rCalculator.Add(x, y); 65 53 } 66 54 … … 68 56 69 57 public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) { 70 IEnumerator<double> firstEnumerator = first.GetEnumerator(); 71 IEnumerator<double> secondEnumerator = second.GetEnumerator(); 72 OnlinePearsonsRSquaredCalculator rSquaredCalculator = new OnlinePearsonsRSquaredCalculator(); 73 74 // always move forward both enumerators (do not use short-circuit evaluation!) 75 while (firstEnumerator.MoveNext() & secondEnumerator.MoveNext()) { 76 double original = firstEnumerator.Current; 77 double estimated = secondEnumerator.Current; 78 rSquaredCalculator.Add(original, estimated); 79 if (rSquaredCalculator.ErrorState != OnlineCalculatorError.None) break; 80 } 81 82 // check if both enumerators are at the end to make sure both enumerations have the same length 83 if (rSquaredCalculator.ErrorState == OnlineCalculatorError.None && 84 (secondEnumerator.MoveNext() || firstEnumerator.MoveNext())) { 85 throw new ArgumentException("Number of elements in first and second enumeration doesn't match."); 86 } else { 87 errorState = rSquaredCalculator.ErrorState; 88 return rSquaredCalculator.RSquared; 89 } 58 var r = OnlinePearsonsRCalculator.Calculate(first, second, out errorState); 59 return r * r; 90 60 } 91 61 }
Note: See TracChangeset
for help on using the changeset viewer.