Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/19/11 15:48:45 (14 years ago)
Author:
mkommend
Message:

Corrected thresholds classification to maximize the borders between the classes according to the misclassification matrix (ticket #1383).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/SymbolicClassificationSolution.cs

    r5323 r5332  
    111111        double thresholdIncrement = (originalClasses[i] - originalClasses[i - 1]) / slices;
    112112
    113         double bestThreshold = double.NaN;
     113        double lowestBestThreshold = double.NaN;
     114        double highestBestThreshold = double.NaN;
    114115        double bestClassificationScore = double.PositiveInfinity;
    115116
     
    130131            else {
    131132              if (estimatedTarget.Key > lowerThreshold && estimatedTarget.Key < actualThreshold)
     133                //false positive
    132134                classificationScore += ProblemData.MisclassificationMatrix[i - 1, i];
    133135              else
     
    138140          if (classificationScore < bestClassificationScore) {
    139141            bestClassificationScore = classificationScore;
    140             bestThreshold = actualThreshold;
    141           }
     142            lowestBestThreshold = actualThreshold;
     143            highestBestThreshold = actualThreshold;
     144          } else if (Math.Abs(classificationScore - bestClassificationScore) < double.Epsilon)
     145            highestBestThreshold = actualThreshold;
     146
    142147          actualThreshold += thresholdIncrement;
    143148        }
    144         thresholds[i] = bestThreshold;
     149        double falseNegativePenalty = ProblemData.MisclassificationMatrix[i, i - 1];
     150        double falsePositivePenalty = ProblemData.MisclassificationMatrix[i - 1, i];
     151        thresholds[i] = (lowestBestThreshold * falsePositivePenalty + highestBestThreshold * falseNegativePenalty) / (falseNegativePenalty + falsePositivePenalty);
    145152      }
    146153      this.optimalThresholds = new List<double>(thresholds);
Note: See TracChangeset for help on using the changeset viewer.