Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/09/08 12:18:20 (16 years ago)
Author:
gkronber
Message:

fixed a few bugs in classification evaluators

Location:
trunk/sources/HeuristicLab.StructureIdentification/Evaluation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/AccuracyEvaluator.cs

    r474 r476  
    6464        double origClass = dataset.GetValue(sample, targetVariable);
    6565        double estClass = double.NaN;
    66         if(est < classesArr[0]) estClass = classesArr[0];
    67         else if(est > classesArr[classesArr.Length - 1]) estClass = classesArr[classesArr.Length - 1];
     66        // if estimation is lower than the smallest threshold value -> estimated class is the lower class
     67        if(est < thresholds[0]) estClass = classesArr[0];
     68        // if estimation is larger (or equal) than the largest threshold value -> estimated class is the upper class
     69        else if(est >= thresholds[thresholds.Length - 1]) estClass = classesArr[classesArr.Length - 1]; 
    6870        else {
     71          // otherwise the estimated class is the class which upper threshold is larger than the estimated value
    6972          for(int k = 0; k < thresholds.Length; k++) {
    7073            if(thresholds[k] > est) {
    71               estClass = classesArr[k + 1];
     74              estClass = classesArr[k];
    7275              break;
    7376            }
  • trunk/sources/HeuristicLab.StructureIdentification/Evaluation/ClassificationMeanSquaredErrorEvaluator.cs

    r475 r476  
    6666        }
    6767        double error = estimated - original;
    68         if(estimated < classesArr[0] ||
    69           estimated > classesArr[classesArr.Length - 1]) {
     68        // between classes use squared error
     69        // on the lower end and upper end only add linear error if the absolute error is larger than 1
     70        // the error>1.0 constraint is needed for balance because in the interval ]-1, 1[ the squared error is smaller than the absolute error
     71        if(error < -1.0 && original == classesArr[0] && estimated < classesArr[0] ||
     72          error > 1.0 && original == classesArr[classesArr.Length - 1] && estimated > classesArr[classesArr.Length - 1]) {
    7073          errorsSquaredSum += Math.Abs(error); // only add linear error below the smallest class or above the largest class
    7174        } else {
     
    7477      }
    7578
    76       errorsSquaredSum /= (trainingEnd-trainingStart);
     79      errorsSquaredSum /= (trainingEnd - trainingStart);
    7780      if(double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
    7881        errorsSquaredSum = double.MaxValue;
    7982      }
    80       scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (trainingEnd-trainingStart);
     83      scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (trainingEnd - trainingStart);
    8184      return errorsSquaredSum;
    8285    }
Note: See TracChangeset for help on using the changeset viewer.