Free cookie consent management tool by TermsFeed Policy Generator

Changeset 712


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).

Location:
trunk/sources
Files:
14 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;
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/ClassificationMeanSquaredErrorEvaluator.cs

    r702 r712  
    4343    }
    4444
    45     public override void  Evaluate(IScope scope, BakedTreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end)
    46 {
     45    public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) {
    4746      double errorsSquaredSum = 0;
    48       for(int sample = start; sample < end; sample++) {
     47      for (int sample = start; sample < end; sample++) {
    4948        double estimated = evaluator.Evaluate(sample);
    50         double original = dataset.GetValue(targetVariable, sample);
    51         if(!double.IsNaN(original) && !double.IsInfinity(original)) {
     49        double original = dataset.GetValue(sample, targetVariable);
     50        if (!double.IsNaN(original) && !double.IsInfinity(original)) {
    5251          double error = estimated - original;
    5352          // between classes use squared error
    5453          // on the lower end and upper end only add linear error if the absolute error is larger than 1
    5554          // the error>1.0 constraint is needed for balance because in the interval ]-1, 1[ the squared error is smaller than the absolute error
    56           if((IsEqual(original, classes[0]) && error < -1.0) ||
     55          if ((IsEqual(original, classes[0]) && error < -1.0) ||
    5756            (IsEqual(original, classes[classes.Length - 1]) && error > 1.0)) {
    5857            errorsSquaredSum += Math.Abs(error); // only add linear error below the smallest class or above the largest class
     
    6463
    6564      errorsSquaredSum /= (end - start);
    66       if(double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
     65      if (double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
    6766        errorsSquaredSum = double.MaxValue;
    6867      }
    6968
    7069      DoubleData mse = GetVariableValue<DoubleData>("MSE", scope, false, false);
    71       if(mse == null) {
     70      if (mse == null) {
    7271        mse = new DoubleData();
    7372        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MSE"), mse));
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/ConfusionMatrixEvaluator.cs

    r702 r712  
    4343    public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) {
    4444      IntMatrixData matrix = GetVariableValue<IntMatrixData>("ConfusionMatrix", scope, false, false);
    45       if(matrix == null) {
     45      if (matrix == null) {
    4646        matrix = new IntMatrixData(new int[classes.Length, classes.Length]);
    4747        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("ConfusionMatrix"), matrix));
     
    4949
    5050      int nSamples = end - start;
    51       for(int sample = start; sample < end; sample++) {
     51      for (int sample = start; sample < end; sample++) {
    5252        double est = evaluator.Evaluate(sample);
    53         double origClass = dataset.GetValue(targetVariable,sample);
     53        double origClass = dataset.GetValue(sample, targetVariable);
    5454        int estClassIndex = -1;
    5555        // if estimation is lower than the smallest threshold value -> estimated class is the lower class
    56         if(est < thresholds[0]) estClassIndex = 0;
     56        if (est < thresholds[0]) estClassIndex = 0;
    5757        // if estimation is larger (or equal) than the largest threshold value -> estimated class is the upper class
    58         else if(est >= thresholds[thresholds.Length - 1]) estClassIndex = classes.Length - 1;
     58        else if (est >= thresholds[thresholds.Length - 1]) estClassIndex = classes.Length - 1;
    5959        else {
    6060          // otherwise the estimated class is the class which upper threshold is larger than the estimated value
    61           for(int k = 0; k < thresholds.Length; k++) {
    62             if(thresholds[k] > est) {
     61          for (int k = 0; k < thresholds.Length; k++) {
     62            if (thresholds[k] > est) {
    6363              estClassIndex = k;
    6464              break;
     
    6868
    6969        // find the first threshold index that is larger to the original value
    70         int origClassIndex = classes.Length-1;
    71         for(int i = 0; i < thresholds.Length; i++) {
    72           if(origClass < thresholds[i]) {
     70        int origClassIndex = classes.Length - 1;
     71        for (int i = 0; i < thresholds.Length; i++) {
     72          if (origClass < thresholds[i]) {
    7373            origClassIndex = i;
    7474            break;
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/MulticlassModeller.cs

    r668 r712  
    6969      binaryClassValues.Add(new DoubleData(0.0));
    7070      binaryClassValues.Add(new DoubleData(1.0));
    71       for(int i = 0; i < classValues.Count-1; i++) {
    72         for(int j = i+1; j < classValues.Count; j++) {
     71      for (int i = 0; i < classValues.Count - 1; i++) {
     72        for (int j = i + 1; j < classValues.Count; j++) {
    7373          Dataset dataset = new Dataset();
    7474          dataset.Columns = origDataset.Columns;
     
    8282          trainingSamplesStart = 0;
    8383          List<double[]> rows = new List<double[]>();
    84           for(int k = origTrainingSamplesStart; k < origTrainingSamplesEnd; k++) {
     84          for (int k = origTrainingSamplesStart; k < origTrainingSamplesEnd; k++) {
    8585            double[] row = new double[dataset.Columns];
    8686            double targetValue = origDataset.GetValue(k, targetVariable);
    87             if(IsEqual(targetValue, classAValue)) {
    88               for(int l = 0; l < row.Length; l++) {
     87            if (IsEqual(targetValue, classAValue)) {
     88              for (int l = 0; l < row.Length; l++) {
    8989                row[l] = origDataset.GetValue(k, l);
    9090              }
    9191              row[targetVariable] = 0;
    9292              rows.Add(row);
    93             } else if(IsEqual(targetValue, classBValue)) {
    94               for(int l = 0; l < row.Length; l++) {
     93            } else if (IsEqual(targetValue, classBValue)) {
     94              for (int l = 0; l < row.Length; l++) {
    9595                row[l] = origDataset.GetValue(k, l);
    9696              }
     
    101101          trainingSamplesEnd = rows.Count;
    102102          validationSamplesStart = rows.Count;
    103           for(int k = origValidationSamplesStart; k < origValidationSamplesEnd; k++) {
     103          for (int k = origValidationSamplesStart; k < origValidationSamplesEnd; k++) {
    104104            double[] row = new double[dataset.Columns];
    105105            double targetValue = origDataset.GetValue(k, targetVariable);
    106             if(IsEqual(targetValue, classAValue)) {
    107               for(int l = 0; l < row.Length; l++) {
     106            if (IsEqual(targetValue, classAValue)) {
     107              for (int l = 0; l < row.Length; l++) {
    108108                row[l] = origDataset.GetValue(k, l);
    109109              }
    110110              row[targetVariable] = 0;
    111111              rows.Add(row);
    112             } else if(IsEqual(targetValue, classBValue)) {
    113               for(int l = 0; l < row.Length; l++) {
     112            } else if (IsEqual(targetValue, classBValue)) {
     113              for (int l = 0; l < row.Length; l++) {
    114114                row[l] = origDataset.GetValue(k, l);
    115115              }
     
    122122          dataset.Rows = rows.Count;
    123123          dataset.Samples = new double[dataset.Rows * dataset.Columns];
    124           for(int k = 0; k < dataset.Rows; k++) {
    125             for(int l = 0; l < dataset.Columns; l++) {
     124          for (int k = 0; k < dataset.Rows; k++) {
     125            for (int l = 0; l < dataset.Columns; l++) {
    126126              dataset.SetValue(k, l, rows[k][l]);
    127127            }
    128128          }
    129129
    130           Scope childScope = new Scope(classAValue+" vs. "+classBValue);
     130          Scope childScope = new Scope(classAValue + " vs. " + classBValue);
    131131
    132132          childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(TARGETCLASSVALUES), binaryClassValues));
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/AveragePercentageChangeEvaluator.cs

    r702 r712  
    4545      bool differential = GetVariableValue<BoolData>("Differential", scope, true).Data;
    4646      DoubleData apc = GetVariableValue<DoubleData>("APC", scope, false, false);
    47       if(apc == null) {
     47      if (apc == null) {
    4848        apc = new DoubleData();
    4949        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("APC"), apc));
     
    5151
    5252      double percentageSum = 0;
    53       for(int sample = start; sample < end; sample++) {
     53      for (int sample = start; sample < end; sample++) {
    5454        double prevOriginal;
    5555        double originalPercentageChange;
    5656        double estimatedPercentageChange;
    57         if(differential) {
    58           prevOriginal = dataset.GetValue(targetVariable,sample - 1);
    59           originalPercentageChange = (dataset.GetValue(targetVariable,sample) - prevOriginal) / prevOriginal;
     57        if (differential) {
     58          prevOriginal = dataset.GetValue(sample - 1, targetVariable);
     59          originalPercentageChange = (dataset.GetValue(sample, targetVariable) - prevOriginal) / prevOriginal;
    6060          estimatedPercentageChange = (evaluator.Evaluate(sample) - prevOriginal) / prevOriginal;
    61           if(updateTargetValues) {
    62             dataset.SetValue(targetVariable, sample, estimatedPercentageChange * prevOriginal + prevOriginal);
     61          if (updateTargetValues) {
     62            dataset.SetValue(sample, targetVariable, estimatedPercentageChange * prevOriginal + prevOriginal);
    6363          }
    6464        } else {
    65           originalPercentageChange = dataset.GetValue(targetVariable,sample);
     65          originalPercentageChange = dataset.GetValue(sample, targetVariable);
    6666          estimatedPercentageChange = evaluator.Evaluate(sample);
    67           if(updateTargetValues) {
    68             dataset.SetValue(targetVariable, sample, estimatedPercentageChange);
     67          if (updateTargetValues) {
     68            dataset.SetValue(sample, targetVariable, estimatedPercentageChange);
    6969          }
    7070        }
    71         if(!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) {
    72           if((estimatedPercentageChange > 0 && originalPercentageChange > 0) ||
     71        if (!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) {
     72          if ((estimatedPercentageChange > 0 && originalPercentageChange > 0) ||
    7373            (estimatedPercentageChange < 0 && originalPercentageChange < 0)) {
    7474            percentageSum += Math.Abs(originalPercentageChange);
    75           } else if((estimatedPercentageChange > 0 && originalPercentageChange < 0) ||
     75          } else if ((estimatedPercentageChange > 0 && originalPercentageChange < 0) ||
    7676            (estimatedPercentageChange < 0 && originalPercentageChange > 0)) {
    7777            percentageSum -= Math.Abs(originalPercentageChange);
     
    8181
    8282      percentageSum /= (end - start);
    83       if(double.IsNaN(percentageSum) || double.IsInfinity(percentageSum)) {
     83      if (double.IsNaN(percentageSum) || double.IsInfinity(percentageSum)) {
    8484        percentageSum = double.MinValue;
    8585      }
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/ProfitEvaluator.cs

    r702 r712  
    4747      double transactionCost = GetVariableValue<DoubleData>("TransactionCost", scope, true).Data;
    4848      DoubleData profit = GetVariableValue<DoubleData>("Profit", scope, false, false);
    49       if(profit == null) {
     49      if (profit == null) {
    5050        profit = new DoubleData();
    5151        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("Profit"), profit));
     
    5555      double cB = 0;
    5656      double exchangeRate = double.MaxValue;
    57       for(int sample = start; sample < end; sample++) {
     57      for (int sample = start; sample < end; sample++) {
    5858        exchangeRate = dataset.GetValue(sample, exchangeRateVarIndex);
    59         double originalPercentageChange = dataset.GetValue(targetVariable, sample);
     59        double originalPercentageChange = dataset.GetValue(sample, targetVariable);
    6060        double estimatedPercentageChange = evaluator.Evaluate(sample);
    61         if(updateTargetValues) {
    62           dataset.SetValue(targetVariable, sample, estimatedPercentageChange);
     61        if (updateTargetValues) {
     62          dataset.SetValue(sample, targetVariable, estimatedPercentageChange);
    6363        }
    64         if(!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) {
    65           if(estimatedPercentageChange > 0) {
     64        if (!double.IsNaN(originalPercentageChange) && !double.IsInfinity(originalPercentageChange)) {
     65          if (estimatedPercentageChange > 0) {
    6666            // prediction is the rate of B/A will increase (= get more B for one A) => exchange all B to A
    6767            cA += (cB / exchangeRate) * (1 - transactionCost);
    6868            cB = 0;
    69           } else if(estimatedPercentageChange < 0) {
     69          } else if (estimatedPercentageChange < 0) {
    7070            // prediction is the rate of B/A will drop (= get more A for one B) => exchange all A to B
    7171            cB += (cA * exchangeRate) * (1 - transactionCost);
     
    7575      }
    7676
    77       if(double.IsNaN(cA) || double.IsInfinity(cA) || double.IsInfinity(cB) || double.IsNaN(cB)) {
     77      if (double.IsNaN(cA) || double.IsInfinity(cA) || double.IsInfinity(cB) || double.IsNaN(cB)) {
    7878        cA = 0;
    7979        cB = 0;
  • trunk/sources/HeuristicLab.GP.StructureIdentification.TimeSeries/TheilInequalityCoefficientEvaluator.cs

    r702 r712  
    5555
    5656    public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {
    57     #region create result variables
     57      #region create result variables
    5858      DoubleData theilInequaliy = GetVariableValue<DoubleData>("TheilInequalityCoefficient", scope, false, false);
    59       if(theilInequaliy == null) {
     59      if (theilInequaliy == null) {
    6060        theilInequaliy = new DoubleData();
    6161        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TheilInequalityCoefficient"), theilInequaliy));
    6262      }
    6363      DoubleData uBias = GetVariableValue<DoubleData>("TheilInequalityCoefficientBias", scope, false, false);
    64       if(uBias == null) {
     64      if (uBias == null) {
    6565        uBias = new DoubleData();
    6666        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TheilInequalityCoefficientBias"), uBias));
    6767      }
    6868      DoubleData uVariance = GetVariableValue<DoubleData>("TheilInequalityCoefficientVariance", scope, false, false);
    69       if(uVariance == null) {
     69      if (uVariance == null) {
    7070        uVariance = new DoubleData();
    7171        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TheilInequalityCoefficientVariance"), uVariance));
    7272      }
    7373      DoubleData uCovariance = GetVariableValue<DoubleData>("TheilInequalityCoefficientCovariance", scope, false, false);
    74       if(uCovariance == null) {
     74      if (uCovariance == null) {
    7575        uCovariance = new DoubleData();
    7676        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TheilInequalityCoefficientCovariance"), uCovariance));
     
    8383      double[] originalChanges = new double[end - start];
    8484      int nSamples = 0;
    85       for(int sample = start; sample < end; sample++) {
    86         double prevValue = dataset.GetValue(targetVariable, sample - 1);
     85      for (int sample = start; sample < end; sample++) {
     86        double prevValue = dataset.GetValue(sample - 1, targetVariable);
    8787        double estimatedChange = evaluator.Evaluate(sample) - prevValue;
    88         double originalChange = dataset.GetValue(targetVariable, sample) - prevValue;
    89         if(updateTargetValues) {
    90           dataset.SetValue(targetVariable, sample, estimatedChange + prevValue);
     88        double originalChange = dataset.GetValue(sample, targetVariable) - prevValue;
     89        if (updateTargetValues) {
     90          dataset.SetValue(sample, targetVariable, estimatedChange + prevValue);
    9191        }
    92         if(!double.IsNaN(originalChange) && !double.IsInfinity(originalChange)) {
     92        if (!double.IsNaN(originalChange) && !double.IsInfinity(originalChange)) {
    9393          double error = estimatedChange - originalChange;
    9494          errorsSquaredSum += error * error;
     
    100100      }
    101101      double quality = Math.Sqrt(errorsSquaredSum / nSamples) / Math.Sqrt(originalSquaredSum / nSamples);
    102       if(double.IsNaN(quality) || double.IsInfinity(quality))
     102      if (double.IsNaN(quality) || double.IsInfinity(quality))
    103103        quality = double.MaxValue;
    104104      theilInequaliy.Data = quality; // U2
  • trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/CoefficientOfDeterminationEvaluator.cs

    r702 r712  
    4646      double originalDeviationTotalSumOfSquares = 0.0;
    4747      double targetMean = dataset.GetMean(targetVariable, start, end);
    48       for(int sample = start; sample < end; sample++) {
     48      for (int sample = start; sample < end; sample++) {
    4949        double estimated = evaluator.Evaluate(sample);
    50         double original = dataset.GetValue(targetVariable, sample);
    51         if(updateTargetValues) {
    52           dataset.SetValue(targetVariable, sample, estimated);
     50        double original = dataset.GetValue(sample, targetVariable);
     51        if (updateTargetValues) {
     52          dataset.SetValue(sample, targetVariable, estimated);
    5353        }
    54         if(!double.IsNaN(original) && !double.IsInfinity(original)) {
     54        if (!double.IsNaN(original) && !double.IsInfinity(original)) {
    5555          double error = estimated - original;
    5656          errorsSquaredSum += error * error;
     
    6262
    6363      double quality = 1 - errorsSquaredSum / originalDeviationTotalSumOfSquares;
    64       if(quality > 1)
     64      if (quality > 1)
    6565        throw new InvalidProgramException();
    66       if(double.IsNaN(quality) || double.IsInfinity(quality))
     66      if (double.IsNaN(quality) || double.IsInfinity(quality))
    6767        quality = double.MaxValue;
    6868
    6969      DoubleData r2 = GetVariableValue<DoubleData>("R2", scope, false, false);
    70       if(r2 == null) {
     70      if (r2 == null) {
    7171        r2 = new DoubleData();
    7272        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("R2"), r2));
  • trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/EarlyStoppingMeanSquaredErrorEvaluator.cs

    r702 r712  
    4747      double qualityLimit = GetVariableValue<DoubleData>("QualityLimit", scope, false).Data;
    4848      DoubleData mse = GetVariableValue<DoubleData>("MSE", scope, false, false);
    49       if(mse == null) {
     49      if (mse == null) {
    5050        mse = new DoubleData();
    5151        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MSE"), mse));
     
    5454      double errorsSquaredSum = 0;
    5555      int rows = end - start;
    56       for(int sample = start; sample < end; sample++) {
     56      for (int sample = start; sample < end; sample++) {
    5757        double estimated = evaluator.Evaluate(sample);
    58         double original = dataset.GetValue(targetVariable, sample);
    59         if(updateTargetValues) {
    60           dataset.SetValue(targetVariable, sample, estimated);
     58        double original = dataset.GetValue(sample, targetVariable);
     59        if (updateTargetValues) {
     60          dataset.SetValue(sample, targetVariable, estimated);
    6161        }
    62         if(!double.IsNaN(original) && !double.IsInfinity(original)) {
     62        if (!double.IsNaN(original) && !double.IsInfinity(original)) {
    6363          double error = estimated - original;
    6464          errorsSquaredSum += error * error;
    6565        }
    6666        // check the limit and stop as soon as we hit the limit
    67         if(errorsSquaredSum / rows >= qualityLimit) {
     67        if (errorsSquaredSum / rows >= qualityLimit) {
    6868          mse.Data = errorsSquaredSum / (sample - start + 1); // return estimated MSE (when the remaining errors are on average the same)
    6969          return;
     
    7171      }
    7272      errorsSquaredSum /= rows;
    73       if(double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
     73      if (double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
    7474        errorsSquaredSum = double.MaxValue;
    7575      }
  • trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/GPEvaluatorBase.cs

    r702 r712  
    5757      double[] backupValues = null;
    5858      // prepare for autoregressive modelling by saving the original values of the target-variable to a backup array
    59       if(useEstimatedValues &&
    60         (backupValues == null || backupValues.Length!=end-start)) {
     59      if (useEstimatedValues &&
     60        (backupValues == null || backupValues.Length != end - start)) {
    6161        backupValues = new double[end - start];
    62         for(int i = start; i < end; i++) {
     62        for (int i = start; i < end; i++) {
    6363          backupValues[i - start] = dataset.GetValue(i, targetVariable);
    6464        }
     
    7272
    7373      // restore the values of the target variable from the backup array if necessary
    74       if(useEstimatedValues) {
    75         for(int i = start; i < end; i++) {
     74      if (useEstimatedValues) {
     75        for (int i = start; i < end; i++) {
    7676          dataset.SetValue(i, targetVariable, backupValues[i - start]);
    7777        }
     
    7979
    8080      // update the value of total evaluated nodes
    81       scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (end-start);
     81      scope.GetVariableValue<DoubleData>("TotalEvaluatedNodes", true).Data = totalEvaluatedNodes + treeSize * (end - start);
    8282      return null;
    8383    }
  • trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/MeanAbsolutePercentageErrorEvaluator.cs

    r702 r712  
    4646      double errorsSum = 0.0;
    4747      int n = 0;
    48       for(int sample = start; sample < end; sample++) {
     48      for (int sample = start; sample < end; sample++) {
    4949        double estimated = evaluator.Evaluate(sample);
    50         double original = dataset.GetValue(targetVariable, sample);
     50        double original = dataset.GetValue(sample, targetVariable);
    5151
    52         if(updateTargetValues) {
    53           dataset.SetValue(targetVariable, sample, estimated);
     52        if (updateTargetValues) {
     53          dataset.SetValue(sample, targetVariable, estimated);
    5454        }
    55        
    56         if(!double.IsNaN(original) && !double.IsInfinity(original) && original != 0.0) {
     55
     56        if (!double.IsNaN(original) && !double.IsInfinity(original) && original != 0.0) {
    5757          double percent_error = Math.Abs((estimated - original) / original);
    5858          errorsSum += percent_error;
     
    6161      }
    6262      double quality = errorsSum / n;
    63       if(double.IsNaN(quality) || double.IsInfinity(quality))
     63      if (double.IsNaN(quality) || double.IsInfinity(quality))
    6464        quality = double.MaxValue;
    6565
    6666      // create a variable for the MAPE
    6767      DoubleData mape = GetVariableValue<DoubleData>("MAPE", scope, false, false);
    68       if(mape == null) {
     68      if (mape == null) {
    6969        mape = new DoubleData();
    7070        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MAPE"), mape));
  • trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/MeanSquaredErrorEvaluator.cs

    r702 r712  
    4545    public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {
    4646      double errorsSquaredSum = 0;
    47       for(int sample = start; sample < end; sample++) {
    48         double original = dataset.GetValue(targetVariable, sample);
     47      for (int sample = start; sample < end; sample++) {
     48        double original = dataset.GetValue(sample, targetVariable);
    4949        double estimated = evaluator.Evaluate(sample);
    50         if(updateTargetValues) {
    51           dataset.SetValue(targetVariable, sample, estimated);
     50        if (updateTargetValues) {
     51          dataset.SetValue(sample, targetVariable, estimated);
    5252        }
    53         if(!double.IsNaN(original) && !double.IsInfinity(original)) {
     53        if (!double.IsNaN(original) && !double.IsInfinity(original)) {
    5454          double error = estimated - original;
    5555          errorsSquaredSum += error * error;
     
    5858
    5959      errorsSquaredSum /= (end - start);
    60       if(double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
     60      if (double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
    6161        errorsSquaredSum = double.MaxValue;
    6262      }
    6363
    6464      DoubleData mse = GetVariableValue<DoubleData>("MSE", scope, false, false);
    65       if(mse == null) {
     65      if (mse == null) {
    6666        mse = new DoubleData();
    6767        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MSE"), mse));
  • trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/SimpleEvaluator.cs

    r702 r712  
    3838    public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {
    3939      ItemList values = GetVariableValue<ItemList>("Values", scope, false, false);
    40       if(values == null) {
     40      if (values == null) {
    4141        values = new ItemList();
    4242        IVariableInfo info = GetVariableInfo("Values");
    43         if(info.Local)
     43        if (info.Local)
    4444          AddVariable(new HeuristicLab.Core.Variable(info.ActualName, values));
    4545        else
     
    4848      values.Clear();
    4949
    50       for(int sample = start; sample < end; sample++) {
     50      for (int sample = start; sample < end; sample++) {
    5151        ItemList row = new ItemList();
    5252        double estimated = evaluator.Evaluate(sample);
    53         double original = dataset.GetValue(targetVariable, sample);
    54         if(updateTargetValues) {
    55           dataset.SetValue(targetVariable, sample, estimated);
     53        double original = dataset.GetValue(sample, targetVariable);
     54        if (updateTargetValues) {
     55          dataset.SetValue(sample, targetVariable, estimated);
    5656        }
    5757        row.Add(new DoubleData(estimated));
  • trunk/sources/HeuristicLab.GP.StructureIdentification/Evaluators/VarianceAccountedForEvaluator.cs

    r702 r712  
    5757      double[] errors = new double[nSamples];
    5858      double[] originalTargetVariableValues = new double[nSamples];
    59       for(int sample = start; sample < end; sample++) {
     59      for (int sample = start; sample < end; sample++) {
    6060        double estimated = evaluator.Evaluate(sample);
    61         double original = dataset.GetValue(targetVariable, sample);
    62         if(updateTargetValues) {
    63           dataset.SetValue(targetVariable, sample, estimated);
     61        double original = dataset.GetValue(sample, targetVariable);
     62        if (updateTargetValues) {
     63          dataset.SetValue(sample, targetVariable, estimated);
    6464        }
    65         if(!double.IsNaN(original) && !double.IsInfinity(original)) {
     65        if (!double.IsNaN(original) && !double.IsInfinity(original)) {
    6666          errors[sample - start] = original - estimated;
    6767          originalTargetVariableValues[sample - start] = original;
     
    7272      double quality = 1 - errorsVariance / originalsVariance;
    7373
    74       if(double.IsNaN(quality) || double.IsInfinity(quality)) {
     74      if (double.IsNaN(quality) || double.IsInfinity(quality)) {
    7575        quality = double.MaxValue;
    7676      }
    7777      DoubleData vaf = GetVariableValue<DoubleData>("VAF", scope, false, false);
    78       if(vaf == null) {
     78      if (vaf == null) {
    7979        vaf = new DoubleData();
    8080        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("VAF"), vaf));
Note: See TracChangeset for help on using the changeset viewer.