Index: trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/AccuracyEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/AccuracyEvaluator.cs	(revision 696)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/AccuracyEvaluator.cs	(revision 702)
@@ -27,11 +27,9 @@
 using HeuristicLab.Data;
 using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.DataAnalysis;
 
 namespace HeuristicLab.GP.StructureIdentification.Classification {
-  public class AccuracyEvaluator : GPEvaluatorBase {
+  public class AccuracyEvaluator : GPClassificationEvaluatorBase {
     private const double EPSILON = 1.0E-6;
-    private double[] classesArr;
-    private double[] thresholds;
-    private DoubleData accuracy;
     public override string Description {
       get {
@@ -43,9 +41,8 @@
       : base() {
       AddVariableInfo(new VariableInfo("Accuracy", "The total accuracy of the model (ratio of correctly classified instances to total number of instances)", typeof(DoubleData), VariableKind.New));
-      AddVariableInfo(new VariableInfo("TargetClassValues", "The original class values of target variable (for instance negative=0 and positive=1).", typeof(ItemList<DoubleData>), VariableKind.In));
     }
 
-    public override IOperation Apply(IScope scope) {
-      accuracy = GetVariableValue<DoubleData>("Accuracy", scope, false, false);
+    public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) {
+      DoubleData accuracy = GetVariableValue<DoubleData>("Accuracy", scope, false, false);
       if(accuracy == null) {
         accuracy = new DoubleData();
@@ -53,37 +50,23 @@
       }
 
-      ItemList<DoubleData> classes = GetVariableValue<ItemList<DoubleData>>("TargetClassValues", scope, true);
-      classesArr = new double[classes.Count];
-      for(int i = 0; i < classesArr.Length; i++) classesArr[i] = classes[i].Data;
-      Array.Sort(classesArr);
-      thresholds = new double[classes.Count - 1];
-      for(int i = 0; i < classesArr.Length - 1; i++) {
-        thresholds[i] = (classesArr[i] + classesArr[i + 1]) / 2.0;
-      }
-
-      return base.Apply(scope);
-    }
-
-    public override void Evaluate(int start, int end) {
       int nSamples = end - start;
       int nCorrect = 0;
       for(int sample = start; sample < end; sample++) {
-        double est = GetEstimatedValue(sample);
-        double origClass = GetOriginalValue(sample);
+        double est = evaluator.Evaluate(sample);
+        double origClass = dataset.GetValue(targetVariable, sample);
         double estClass = double.NaN;
         // if estimation is lower than the smallest threshold value -> estimated class is the lower class
-        if(est < thresholds[0]) estClass = classesArr[0];
+        if(est < thresholds[0]) estClass = classes[0];
         // if estimation is larger (or equal) than the largest threshold value -> estimated class is the upper class
-        else if(est >= thresholds[thresholds.Length - 1]) estClass = classesArr[classesArr.Length - 1];
+        else if(est >= thresholds[thresholds.Length - 1]) estClass = classes[classes.Length - 1];
         else {
           // otherwise the estimated class is the class which upper threshold is larger than the estimated value
           for(int k = 0; k < thresholds.Length; k++) {
             if(thresholds[k] > est) {
-              estClass = classesArr[k];
+              estClass = classes[k];
               break;
             }
           }
         }
-        SetOriginalValue(sample, estClass);
         if(Math.Abs(estClass - origClass) < EPSILON) nCorrect++;
       }
Index: trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/ClassificationMeanSquaredErrorEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/ClassificationMeanSquaredErrorEvaluator.cs	(revision 696)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/ClassificationMeanSquaredErrorEvaluator.cs	(revision 702)
@@ -29,7 +29,6 @@
 
 namespace HeuristicLab.GP.StructureIdentification.Classification {
-  public class ClassificationMeanSquaredErrorEvaluator : MeanSquaredErrorEvaluator {
-    private const double EPSILON = 1.0E-6;
-    private double[] classesArr;
+  public class ClassificationMeanSquaredErrorEvaluator : GPClassificationEvaluatorBase {
+    private const double EPSILON = 1.0E-7;
     public override string Description {
       get {
@@ -41,21 +40,13 @@
     public ClassificationMeanSquaredErrorEvaluator()
       : base() {
-      AddVariableInfo(new VariableInfo("TargetClassValues", "The original class values of target variable (for instance negative=0 and positive=1).", typeof(ItemList<DoubleData>), VariableKind.In));
+      AddVariableInfo(new VariableInfo("MSE", "The mean squared error of the model", typeof(DoubleData), VariableKind.New));
     }
 
-    public override IOperation Apply(IScope scope) {
-      ItemList<DoubleData> classes = GetVariableValue<ItemList<DoubleData>>("TargetClassValues", scope, true);
-      classesArr = new double[classes.Count];
-      for(int i = 0; i < classesArr.Length; i++) classesArr[i] = classes[i].Data;
-      Array.Sort(classesArr);
-      return base.Apply(scope);
-    }
-
-    public override void Evaluate(int start, int end) {
+    public override void  Evaluate(IScope scope, BakedTreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end)
+{
       double errorsSquaredSum = 0;
       for(int sample = start; sample < end; sample++) {
-        double estimated = GetEstimatedValue(sample);
-        double original = GetOriginalValue(sample);
-        SetOriginalValue(sample, estimated);
+        double estimated = evaluator.Evaluate(sample);
+        double original = dataset.GetValue(targetVariable, sample);
         if(!double.IsNaN(original) && !double.IsInfinity(original)) {
           double error = estimated - original;
@@ -63,6 +54,6 @@
           // on the lower end and upper end only add linear error if the absolute error is larger than 1
           // the error>1.0 constraint is needed for balance because in the interval ]-1, 1[ the squared error is smaller than the absolute error
-          if((IsEqual(original, classesArr[0]) && error < -1.0) ||
-            (IsEqual(original, classesArr[classesArr.Length - 1]) && error > 1.0)) {
+          if((IsEqual(original, classes[0]) && error < -1.0) ||
+            (IsEqual(original, classes[classes.Length - 1]) && error > 1.0)) {
             errorsSquaredSum += Math.Abs(error); // only add linear error below the smallest class or above the largest class
           } else {
@@ -76,4 +67,11 @@
         errorsSquaredSum = double.MaxValue;
       }
+
+      DoubleData mse = GetVariableValue<DoubleData>("MSE", scope, false, false);
+      if(mse == null) {
+        mse = new DoubleData();
+        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MSE"), mse));
+      }
+
       mse.Data = errorsSquaredSum;
     }
Index: trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/ConfusionMatrixEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/ConfusionMatrixEvaluator.cs	(revision 696)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/ConfusionMatrixEvaluator.cs	(revision 702)
@@ -29,9 +29,5 @@
 
 namespace HeuristicLab.GP.StructureIdentification.Classification {
-  public class ConfusionMatrixEvaluator : GPEvaluatorBase {
-    private const double EPSILON = 1.0E-6;
-    private double[] classesArr;
-    private double[] thresholds;
-    private IntMatrixData matrix;
+  public class ConfusionMatrixEvaluator : GPClassificationEvaluatorBase {
     public override string Description {
       get {
@@ -43,35 +39,22 @@
       : base() {
       AddVariableInfo(new VariableInfo("ConfusionMatrix", "The confusion matrix of the model", typeof(IntMatrixData), VariableKind.New));
-      AddVariableInfo(new VariableInfo("TargetClassValues", "The original class values of target variable (for instance negative=0 and positive=1).", typeof(ItemList<DoubleData>), VariableKind.In));
     }
 
-    public override IOperation Apply(IScope scope) {
-      ItemList<DoubleData> classes = GetVariableValue<ItemList<DoubleData>>("TargetClassValues", scope, true);
-      classesArr = new double[classes.Count];
-      for(int i = 0; i < classesArr.Length; i++) classesArr[i] = classes[i].Data;
-      Array.Sort(classesArr);
-      thresholds = new double[classes.Count - 1];
-      for(int i = 0; i < classesArr.Length - 1; i++) {
-        thresholds[i] = (classesArr[i] + classesArr[i + 1]) / 2.0;
+    public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, HeuristicLab.DataAnalysis.Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end) {
+      IntMatrixData matrix = GetVariableValue<IntMatrixData>("ConfusionMatrix", scope, false, false);
+      if(matrix == null) {
+        matrix = new IntMatrixData(new int[classes.Length, classes.Length]);
+        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("ConfusionMatrix"), matrix));
       }
 
-      matrix = GetVariableValue<IntMatrixData>("ConfusionMatrix", scope, false, false);
-      if(matrix == null) {
-        matrix = new IntMatrixData(new int[classesArr.Length, classesArr.Length]);
-        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("ConfusionMatrix"), matrix));
-      }
-      return base.Apply(scope);
-    }
-
-    public override void Evaluate(int start, int end) {
       int nSamples = end - start;
       for(int sample = start; sample < end; sample++) {
-        double est = GetEstimatedValue(sample);
-        double origClass = GetOriginalValue(sample);
+        double est = evaluator.Evaluate(sample);
+        double origClass = dataset.GetValue(targetVariable,sample);
         int estClassIndex = -1;
         // if estimation is lower than the smallest threshold value -> estimated class is the lower class
         if(est < thresholds[0]) estClassIndex = 0;
         // if estimation is larger (or equal) than the largest threshold value -> estimated class is the upper class
-        else if(est >= thresholds[thresholds.Length - 1]) estClassIndex = classesArr.Length - 1;
+        else if(est >= thresholds[thresholds.Length - 1]) estClassIndex = classes.Length - 1;
         else {
           // otherwise the estimated class is the class which upper threshold is larger than the estimated value
@@ -83,17 +66,16 @@
           }
         }
-        SetOriginalValue(sample, classesArr[estClassIndex]);
 
-        int origClassIndex = -1;
-        for(int i = 0; i < classesArr.Length; i++) {
-          if(IsEqual(origClass, classesArr[i])) origClassIndex = i;
+        // find the first threshold index that is larger to the original value
+        int origClassIndex = classes.Length-1;
+        for(int i = 0; i < thresholds.Length; i++) {
+          if(origClass < thresholds[i]) {
+            origClassIndex = i;
+            break;
+          }
         }
         matrix.Data[origClassIndex, estClassIndex]++;
       }
     }
-
-    private bool IsEqual(double x, double y) {
-      return Math.Abs(x - y) < EPSILON;
-    }
   }
 }
Index: trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/GPClassificationEvaluatorBase.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/GPClassificationEvaluatorBase.cs	(revision 702)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/GPClassificationEvaluatorBase.cs	(revision 702)
@@ -0,0 +1,55 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.GP.StructureIdentification;
+using HeuristicLab.DataAnalysis;
+
+namespace HeuristicLab.GP.StructureIdentification.Classification {
+  public abstract class GPClassificationEvaluatorBase : GPEvaluatorBase {
+
+    public GPClassificationEvaluatorBase()
+      : base() {
+      AddVariableInfo(new VariableInfo("TargetClassValues", "The original class values of target variable (for instance negative=0 and positive=1).", typeof(ItemList<DoubleData>), VariableKind.In));
+    }
+
+    public override void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, int start, int end, bool updateTargetValues) {
+
+      ItemList<DoubleData> classes = GetVariableValue<ItemList<DoubleData>>("TargetClassValues", scope, true);
+      double[] classesArr = new double[classes.Count];
+      for(int i = 0; i < classesArr.Length; i++) classesArr[i] = classes[i].Data;
+      Array.Sort(classesArr);
+      double[] thresholds = new double[classes.Count - 1];
+      for(int i = 0; i < classesArr.Length - 1; i++) {
+        thresholds[i] = (classesArr[i] + classesArr[i + 1]) / 2.0;
+      }
+
+      Evaluate(scope, evaluator, dataset, targetVariable, classesArr, thresholds, start, end);
+    }
+
+    public abstract void Evaluate(IScope scope, BakedTreeEvaluator evaluator, Dataset dataset, int targetVariable, double[] classes, double[] thresholds, int start, int end);
+  }
+}
Index: trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/HeuristicLab.GP.StructureIdentification.Classification.csproj
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/HeuristicLab.GP.StructureIdentification.Classification.csproj	(revision 696)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/HeuristicLab.GP.StructureIdentification.Classification.csproj	(revision 702)
@@ -67,4 +67,5 @@
     <Compile Include="ClassificationMeanSquaredErrorEvaluator.cs" />
     <Compile Include="ConfusionMatrixEvaluator.cs" />
+    <Compile Include="GPClassificationEvaluatorBase.cs" />
     <Compile Include="CrossValidation.cs" />
     <Compile Include="FunctionLibraryInjector.cs">
@@ -72,5 +73,4 @@
     </Compile>
     <Compile Include="HeuristicLabGPClassificationPlugin.cs" />
-    <Compile Include="MCCEvaluator.cs" />
     <Compile Include="MulticlassModeller.cs" />
     <Compile Include="MulticlassOneVsOneAnalyzer.cs" />
Index: trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/MCCEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/MCCEvaluator.cs	(revision 696)
+++ 	(revision )
@@ -1,95 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.GP.StructureIdentification;
-
-namespace HeuristicLab.GP.StructureIdentification.Classification {
-  public class MCCEvaluator : GPEvaluatorBase {
-    private double limit;
-    private double[] original = new double[1];
-    private double[] estimated = new double[1];
-    private DoubleData mcc;
-    public override string Description {
-      get {
-        return @"Calculates the matthews correlation coefficient for a given model and class separation threshold";
-      }
-    }
-    public MCCEvaluator()
-      : base() {
-      AddVariableInfo(new VariableInfo("ClassSeparation", "The value of separation between negative and positive target classification values (for instance 0.5 if negative=0 and positive=1).", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("MCC", "The matthews correlation coefficient of the model", typeof(DoubleData), VariableKind.New));
-    }
-
-    public override IOperation Apply(IScope scope) {
-      mcc = GetVariableValue<DoubleData>("MCC", scope, false, false);
-      if(mcc == null) {
-        mcc = new DoubleData();
-        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("MCC"), mcc));
-      }
-      limit = GetVariableValue<DoubleData>("ClassSeparation", scope, true).Data;
-      return base.Apply(scope);
-    }
-
-    public override void Evaluate(int start, int end) {
-      int nSamples = end - start;
-      if(estimated.Length != nSamples) {
-        estimated = new double[nSamples];
-        original = new double[nSamples];
-      }
-
-      double positive = 0;
-      double negative = 0;
-      for(int sample = start; sample < end; sample++) {
-        double est = GetEstimatedValue(sample);
-        double orig = GetOriginalValue(sample);
-        SetOriginalValue(sample, est);
-        estimated[sample - start] = est;
-        original[sample - start] = orig;
-        if(orig >= limit) positive++;
-        else negative++;
-      }
-      Array.Sort(estimated, original);
-      double best_mcc = -1.0;
-      double tp = 0;
-      double fn = positive;
-      double tn = negative;
-      double fp = 0;
-      for(int i = original.Length - 1; i >= 0; i--) {
-        if(original[i] >= limit) {
-          tp++; fn--;
-        } else {
-          tn--; fp++;
-        }
-        double mcc = (tp * tn - fp * fn) / Math.Sqrt(positive * (tp + fn) * (tn + fp) * negative);
-        if(best_mcc < mcc) {
-          best_mcc = mcc;
-        }
-      }
-      this.mcc.Data = best_mcc;
-    }
-  }
-}
Index: trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/MulticlassOneVsOneAnalyzer.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/MulticlassOneVsOneAnalyzer.cs	(revision 696)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/MulticlassOneVsOneAnalyzer.cs	(revision 702)
@@ -79,5 +79,5 @@
 
         BakedTreeEvaluator evaluator = new BakedTreeEvaluator();
-        evaluator.ResetEvaluator(functionTree, dataset);
+        evaluator.ResetEvaluator(functionTree, dataset, targetVariable, samplesStart, samplesEnd, 1.0);
 
         for(int i = 0; i < (samplesEnd - samplesStart); i++) {
