Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12218


Ignore:
Timestamp:
03/17/15 17:22:57 (10 years ago)
Author:
ehopf
Message:

#2361: Added missing estimated values bound calculation and removed duplicate code. Note that the current implementation ignores the linear scaling option.

Location:
branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveWeightedPerformanceMeasuresEvaluator.cs

    r12216 r12218  
    102102      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    103103      IEnumerable<double> targetClassValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
     104      IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    104105      OnlineCalculatorError errorState;
    105106      double nmse;
     
    109110      string positiveClassName = problemData.PositiveClass;
    110111      double[] classValues, thresholds;
    111       model.ThresholdCalculator.Calculate(problemData, estimatedValues, targetClassValues, out classValues, out thresholds);
     112      model.ThresholdCalculator.Calculate(problemData, boundedEstimatedValues, targetClassValues, out classValues, out thresholds);
    112113      model.SetThresholdsAndClassValues(thresholds, classValues);
    113114      var performanceCalculator = new ClassificationPerformanceMeasuresCalculator(positiveClassName, problemData.GetClassValue(positiveClassName));
    114       var estimatedClassValues = model.GetEstimatedClassValues(estimatedValues);
     115      var estimatedClassValues = model.GetEstimatedClassValues(boundedEstimatedValues);
    115116      performanceCalculator.Calculate(targetClassValues, estimatedClassValues);
    116117      if (performanceCalculator.ErrorState != OnlineCalculatorError.None)
     
    125126        nmse = nmseCalculator.NormalizedMeanSquaredError;
    126127      } else {
    127         IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    128128        nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetClassValues, boundedEstimatedValues, out errorState);
    129129      }
  • branches/SensitivityEvaluator/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationModel.cs

    r12216 r12218  
    8888      var classValuesArr = classValues.ToArray();
    8989      var thresholdsArr = thresholds.ToArray();
    90       if (thresholdsArr.Length != classValuesArr.Length || thresholdsArr.Length < 1) 
     90      if (thresholdsArr.Length != classValuesArr.Length || thresholdsArr.Length < 1)
    9191        throw new ArgumentException();
    92       if (!double.IsNegativeInfinity(thresholds.First())) 
     92      if (!double.IsNegativeInfinity(thresholds.First()))
    9393        throw new ArgumentException();
    9494
     
    113113    public override IEnumerable<double> GetEstimatedClassValues(Dataset dataset, IEnumerable<int> rows) {
    114114      if (!Thresholds.Any() && !ClassValues.Any()) throw new ArgumentException("No thresholds and class values were set for the current symbolic classification model.");
    115       foreach (var x in GetEstimatedValues(dataset, rows)) {
    116         int classIndex = 0;
    117         // find first threshold value which is larger than x => class index = threshold index + 1
    118         for (int i = 0; i < thresholds.Length; i++) {
    119           if (x > thresholds[i]) classIndex++;
    120           else break;
    121         }
    122         yield return classValues.ElementAt(classIndex - 1);
    123       }
     115      var estimatedValues = GetEstimatedValues(dataset, rows);
     116      return GetEstimatedClassValues(estimatedValues);
    124117    }
    125118    public IEnumerable<double> GetEstimatedClassValues(IEnumerable<double> estimatedValues) {
Note: See TracChangeset for help on using the changeset viewer.