Ignore:
Timestamp:
09/12/12 16:20:18 (7 years ago)
Author:
mkommend
Message:

#1924:

  • Changed the accuracy threshold calculator to eliminate the necessity the the class values are ordered.
  • Adapted the symbolic classification simplifier to work with all ISymbolicClassificationModels.
  • Corrected ROCCurvesView to also work if the class values are not sorted.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ThresholdCalculators/AccuracyMaximizationThresholdCalculator.cs

    r8573 r8636  
    5353
    5454    public static void CalculateThresholds(IClassificationProblemData problemData, IEnumerable<double> estimatedValues, IEnumerable<double> targetClassValues, out double[] classValues, out double[] thresholds) {
    55       int slices = 100;
    56       double minThresholdInc = 10e-5; // necessary to prevent infinite loop when maxEstimated - minEstimated is effectively zero (constant model)
     55      const int slices = 100;
     56      const double minThresholdInc = 10e-5; // necessary to prevent infinite loop when maxEstimated - minEstimated is effectively zero (constant model)
    5757      List<double> estimatedValuesList = estimatedValues.ToList();
    5858      double maxEstimatedValue = estimatedValuesList.Max();
     
    6161      var estimatedAndTargetValuePairs =
    6262        estimatedValuesList.Zip(targetClassValues, (x, y) => new { EstimatedValue = x, TargetClassValue = y })
    63         .OrderBy(x => x.EstimatedValue)
    64         .ToList();
     63        .OrderBy(x => x.EstimatedValue).ToList();
    6564
    66       classValues = problemData.ClassValues.OrderBy(x => x).ToArray();
     65      classValues = estimatedAndTargetValuePairs.GroupBy(x => x.TargetClassValue)
     66        .Select(x => new { Median = x.Select(y => y.EstimatedValue).Median(), Class = x.Key })
     67        .OrderBy(x => x.Median).Select(x => x.Class).ToArray();
     68
    6769      int nClasses = classValues.Length;
    6870      thresholds = new double[nClasses];
    6971      thresholds[0] = double.NegativeInfinity;
    70       // thresholds[thresholds.Length - 1] = double.PositiveInfinity;
    7172
    7273      // incrementally calculate accuracy of all possible thresholds
Note: See TracChangeset for help on using the changeset viewer.