Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/05/08 21:34:12 (15 years ago)
Author:
gkronber
Message:

fixed a stupid mistake introduced with r702 #328 (GP evaluation doesn't work in a thread parallel engine).

File:
1 edited

Legend:

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

    r702 r712  
    4545    public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) {
    4646      DoubleData accuracy = GetVariableValue<DoubleData>("Accuracy", scope, false, false);
    47       if(accuracy == null) {
     47      if (accuracy == null) {
    4848        accuracy = new DoubleData();
    4949        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("Accuracy"), accuracy));
     
    5252      int nSamples = end - start;
    5353      int nCorrect = 0;
    54       for(int sample = start; sample < end; sample++) {
     54      for (int sample = start; sample < end; sample++) {
    5555        double est = evaluator.Evaluate(sample);
    56         double origClass = dataset.GetValue(targetVariable, sample);
     56        double origClass = dataset.GetValue(sample, targetVariable);
    5757        double estClass = double.NaN;
    5858        // if estimation is lower than the smallest threshold value -> estimated class is the lower class
    59         if(est < thresholds[0]) estClass = classes[0];
     59        if (est < thresholds[0]) estClass = classes[0];
    6060        // if estimation is larger (or equal) than the largest threshold value -> estimated class is the upper class
    61         else if(est >= thresholds[thresholds.Length - 1]) estClass = classes[classes.Length - 1];
     61        else if (est >= thresholds[thresholds.Length - 1]) estClass = classes[classes.Length - 1];
    6262        else {
    6363          // otherwise the estimated class is the class which upper threshold is larger than the estimated value
    64           for(int k = 0; k < thresholds.Length; k++) {
    65             if(thresholds[k] > est) {
     64          for (int k = 0; k < thresholds.Length; k++) {
     65            if (thresholds[k] > est) {
    6666              estClass = classes[k];
    6767              break;
     
    6969          }
    7070        }
    71         if(Math.Abs(estClass - origClass) < EPSILON) nCorrect++;
     71        if (Math.Abs(estClass - origClass) < EPSILON) nCorrect++;
    7272      }
    7373      accuracy.Data = nCorrect / (double)nSamples;
Note: See TracChangeset for help on using the changeset viewer.