Changeset 8660 for branches/GP-MoveOperators/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators
- Timestamp:
- 09/14/12 18:58:15 (12 years ago)
- Location:
- branches/GP-MoveOperators
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MoveOperators
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/GP-MoveOperators/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
-
branches/GP-MoveOperators/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/AccuracyMaximizationThresholdCalculator.cs
r8206 r8660 85 85 //all positives 86 86 if (pair.TargetClassValue.IsAlmost(classValues[i - 1])) { 87 if (pair.EstimatedValue > lowerThreshold && pair.EstimatedValue < actualThreshold)87 if (pair.EstimatedValue > lowerThreshold && pair.EstimatedValue <= actualThreshold) 88 88 //true positive 89 classificationScore += problemData.GetClassificationPenalty( classValues[i - 1], classValues[i - 1]);89 classificationScore += problemData.GetClassificationPenalty(pair.TargetClassValue, pair.TargetClassValue); 90 90 else 91 91 //false negative 92 classificationScore += problemData.GetClassificationPenalty( classValues[i], classValues[i - 1]);92 classificationScore += problemData.GetClassificationPenalty(pair.TargetClassValue, classValues[i]); 93 93 } 94 94 //all negatives 95 95 else { 96 if (pair.EstimatedValue > lowerThreshold && pair.EstimatedValue < actualThreshold) 97 //false positive 98 classificationScore += problemData.GetClassificationPenalty(classValues[i - 1], classValues[i]); 99 else 100 //true negative, consider only upper class 101 classificationScore += problemData.GetClassificationPenalty(classValues[i], classValues[i]); 96 //false positive 97 if (pair.EstimatedValue > lowerThreshold && pair.EstimatedValue <= actualThreshold) 98 classificationScore += problemData.GetClassificationPenalty(pair.TargetClassValue, classValues[i - 1]); 99 else if (pair.EstimatedValue <= lowerThreshold) 100 classificationScore += problemData.GetClassificationPenalty(pair.TargetClassValue, classValues[i - 2]); 101 else if (pair.EstimatedValue > actualThreshold) { 102 if (pair.TargetClassValue < classValues[i - 1]) //negative in wrong class, consider upper class 103 classificationScore += problemData.GetClassificationPenalty(pair.TargetClassValue, classValues[i]); 104 else //true negative, must be optimized by the other thresholds 105 classificationScore += problemData.GetClassificationPenalty(pair.TargetClassValue, pair.TargetClassValue); 106 } 102 107 } 103 108 } -
branches/GP-MoveOperators/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/NormalDistributionCutPointsThresholdCalculator.cs
r7259 r8660 107 107 double maxDensityClassValue = -1; 108 108 foreach (var classValue in originalClasses) { 109 double density = NormalDensity(m, classMean[classValue], classStdDev[classValue]);109 double density = LogNormalDensity(m, classMean[classValue], classStdDev[classValue]); 110 110 if (density > maxDensity) { 111 111 maxDensity = density; … … 139 139 } 140 140 141 private static double NormalDensity(double x, double mu, double sigma) { 142 if (sigma.IsAlmost(0.0)) { 143 if (x.IsAlmost(mu)) return 1.0; else return 0.0; 144 } else { 145 return (1.0 / Math.Sqrt(2.0 * Math.PI * sigma * sigma)) * Math.Exp(-((x - mu) * (x - mu)) / (2.0 * sigma * sigma)); 146 } 141 private static double LogNormalDensity(double x, double mu, double sigma) { 142 return -0.5 * Math.Log(2.0 * Math.PI * sigma * sigma) - ((x - mu) * (x - mu)) / (2.0 * sigma * sigma); 147 143 } 148 144
Note: See TracChangeset
for help on using the changeset viewer.