Index: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/AccuracyEvaluator.cs
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/AccuracyEvaluator.cs	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/AccuracyEvaluator.cs	(revision 1299)
@@ -0,0 +1,76 @@
+#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 class AccuracyEvaluator : GPClassificationEvaluatorBase {
+    private const double EPSILON = 1.0E-6;
+    public override string Description {
+      get {
+        return @"Calculates the total accuracy of the model (ratio of correctly classified instances to total number of instances) given a model and the list of possible target class values.";
+      }
+    }
+
+    public AccuracyEvaluator()
+      : 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));
+    }
+
+    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();
+        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("Accuracy"), accuracy));
+      }
+
+      int nSamples = end - start;
+      int nCorrect = 0;
+      for (int sample = start; sample < end; sample++) {
+        double est = evaluator.Evaluate(sample);
+        double origClass = dataset.GetValue(sample, targetVariable);
+        double estClass = double.NaN;
+        // if estimation is lower than the smallest threshold value -> estimated class is the lower class
+        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 = 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 = classes[k];
+              break;
+            }
+          }
+        }
+        if (Math.Abs(estClass - origClass) < EPSILON) nCorrect++;
+      }
+      accuracy.Data = nCorrect / (double)nSamples;
+    }
+  }
+}
Index: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/ClassificationMeanSquaredErrorEvaluator.cs
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/ClassificationMeanSquaredErrorEvaluator.cs	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/ClassificationMeanSquaredErrorEvaluator.cs	(revision 1299)
@@ -0,0 +1,82 @@
+#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 ClassificationMeanSquaredErrorEvaluator : GPClassificationEvaluatorBase {
+    private const double EPSILON = 1.0E-7;
+    public override string Description {
+      get {
+        return @"Evaluates 'FunctionTree' for all samples of 'DataSet' and calculates the mean-squared-error
+for the estimated values vs. the real values of 'TargetVariable'.";
+      }
+    }
+
+    public ClassificationMeanSquaredErrorEvaluator()
+      : base() {
+      AddVariableInfo(new VariableInfo("MSE", "The mean squared error of the model", typeof(DoubleData), VariableKind.New));
+    }
+
+    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 = evaluator.Evaluate(sample);
+        double original = dataset.GetValue(sample, targetVariable);
+        if (!double.IsNaN(original) && !double.IsInfinity(original)) {
+          double error = estimated - original;
+          // between classes use squared error
+          // 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, 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 {
+            errorsSquaredSum += error * error;
+          }
+        }
+      }
+
+      errorsSquaredSum /= (end - start);
+      if (double.IsNaN(errorsSquaredSum) || double.IsInfinity(errorsSquaredSum)) {
+        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;
+    }
+
+    private bool IsEqual(double x, double y) {
+      return Math.Abs(x - y) < EPSILON;
+    }
+  }
+}
Index: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/ConfusionMatrixEvaluator.cs
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/ConfusionMatrixEvaluator.cs	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/ConfusionMatrixEvaluator.cs	(revision 1299)
@@ -0,0 +1,81 @@
+#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 ConfusionMatrixEvaluator : GPClassificationEvaluatorBase {
+    public override string Description {
+      get {
+        return @"Calculates the classifcation matrix of the model.";
+      }
+    }
+
+    public ConfusionMatrixEvaluator()
+      : base() {
+      AddVariableInfo(new VariableInfo("ConfusionMatrix", "The confusion matrix of the model", typeof(IntMatrixData), VariableKind.New));
+    }
+
+    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));
+      }
+
+      int nSamples = end - start;
+      for (int sample = start; sample < end; sample++) {
+        double est = evaluator.Evaluate(sample);
+        double origClass = dataset.GetValue(sample, targetVariable);
+        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 = 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) {
+              estClassIndex = k;
+              break;
+            }
+          }
+        }
+
+        // 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]++;
+      }
+    }
+  }
+}
Index: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/CrossValidation.cs
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/CrossValidation.cs	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/CrossValidation.cs	(revision 1299)
@@ -0,0 +1,115 @@
+#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.Text;
+using System.Xml;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.DataAnalysis;
+
+namespace HeuristicLab.GP.StructureIdentification.Classification
+{
+    public class CrossValidation : OperatorBase
+    {
+
+        private const string DATASET = "Dataset";
+        private const string NFOLD = "n-Fold";
+        private const string TRAININGSAMPLESSTART = "TrainingSamplesStart";
+        private const string TRAININGSAMPLESEND = "TrainingSamplesEnd";
+        private const string VALIDATIONSAMPLESSTART = "ValidationSamplesStart";
+        private const string VALIDATIONSAMPLESEND = "ValidationSamplesEnd";
+        private const string TESTSAMPLESSTART = "TestSamplesStart";
+        private const string TESTSAMPLESEND = "TestSamplesEnd";
+
+        public override string Description
+        {
+            get { return @"TASK"; }
+        }
+
+        public CrossValidation()
+            : base()
+        {
+            AddVariableInfo(new VariableInfo(DATASET, "The original dataset and the new datasets in the newly created subscopes", typeof(Dataset), VariableKind.In));
+            AddVariableInfo(new VariableInfo(NFOLD, "Number of folds for the cross-validation", typeof(IntData), VariableKind.In));
+            AddVariableInfo(new VariableInfo(TRAININGSAMPLESSTART, "The start of training samples in the original dataset and starts of training samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
+            AddVariableInfo(new VariableInfo(TRAININGSAMPLESEND, "The end of training samples in the original dataset and ends of training samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
+            AddVariableInfo(new VariableInfo(VALIDATIONSAMPLESSTART, "The start of validation samples in the original dataset and starts of validation samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
+            AddVariableInfo(new VariableInfo(VALIDATIONSAMPLESEND, "The end of validation samples in the original dataset and ends of validation samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
+            AddVariableInfo(new VariableInfo(TESTSAMPLESSTART, "The start of the test samples in the new datasets", typeof(IntData), VariableKind.New));
+            AddVariableInfo(new VariableInfo(TESTSAMPLESEND, "The end of the test samples in the new datasets", typeof(IntData), VariableKind.New));
+        }
+
+        public override IOperation Apply(IScope scope) {
+      Dataset origDataset = GetVariableValue<Dataset>(DATASET, scope, true);
+      int nFolds = GetVariableValue<IntData>(NFOLD, scope, true).Data;
+      if (nFolds < 2) throw new ArgumentException("The number of folds (nFolds) has to be >=2 for cross validation"); 
+      int origTrainingSamplesStart = GetVariableValue<IntData>(TRAININGSAMPLESSTART, scope, true).Data;
+      int origTrainingSamplesEnd = GetVariableValue<IntData>(TRAININGSAMPLESEND, scope, true).Data;
+      int origValidationSamplesStart = GetVariableValue<IntData>(VALIDATIONSAMPLESSTART, scope, true).Data;
+      int origValidationSamplesEnd = GetVariableValue<IntData>(VALIDATIONSAMPLESEND, scope, true).Data;
+      int n=origDataset.Rows;
+      int origTrainingSamples = (origTrainingSamplesEnd-origTrainingSamplesStart);
+      int origValidationSamples = (origValidationSamplesEnd-origValidationSamplesStart);
+
+      double percentTrainingSamples = origTrainingSamples / (double)(origValidationSamples + origTrainingSamples);
+      int nTestSamples = n / nFolds;
+
+      int newTrainingSamplesStart = 0;
+      int newTrainingSamplesEnd = (int)((n - nTestSamples) * percentTrainingSamples);
+      int newValidationSamplesStart = newTrainingSamplesEnd;
+      int newValidationSamplesEnd = n - nTestSamples;
+      int newTestSamplesStart = n - nTestSamples;
+      int newTestSamplesEnd = n;
+
+      for(int i = 0; i < nFolds; i++) {
+        Scope childScope = new Scope(i.ToString());
+        Dataset rotatedSet = new Dataset();
+
+        double[] samples = new double[origDataset.Samples.Length];
+        Array.Copy(origDataset.Samples, samples, samples.Length);
+        RotateArray(samples, i * nTestSamples * origDataset.Columns);
+
+        rotatedSet.Rows = origDataset.Rows;
+        rotatedSet.Columns = origDataset.Columns;
+        rotatedSet.Samples = samples;
+        childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(DATASET), rotatedSet));
+        childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(TRAININGSAMPLESSTART), new IntData(newTrainingSamplesStart)));
+        childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(TRAININGSAMPLESEND), new IntData(newTrainingSamplesEnd)));
+        childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(VALIDATIONSAMPLESSTART), new IntData(newValidationSamplesStart)));
+        childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(VALIDATIONSAMPLESEND), new IntData(newValidationSamplesEnd)));
+        childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(TESTSAMPLESSTART), new IntData(newTestSamplesStart)));
+        childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(TESTSAMPLESEND), new IntData(newTestSamplesEnd)));
+
+        scope.AddSubScope(childScope);
+      }
+      return null;
+    }
+
+        private void RotateArray(double[] samples, int p)
+        {
+            Array.Reverse(samples, 0, p);
+            Array.Reverse(samples, p, samples.Length - p);
+            Array.Reverse(samples);
+        }
+    }
+}
Index: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/DatasetShuffler.cs
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/DatasetShuffler.cs	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/DatasetShuffler.cs	(revision 1299)
@@ -0,0 +1,60 @@
+#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;
+using HeuristicLab.Random;
+
+namespace HeuristicLab.GP.StructureIdentification.Classification {
+  public class DatasetShuffler : OperatorBase {
+    public DatasetShuffler()
+      : base() {
+      AddVariableInfo(new VariableInfo("Dataset", "Dataset which should be shuffled (random row order)", typeof(Dataset), VariableKind.In | VariableKind.Out));
+      AddVariableInfo(new VariableInfo("Random", "Randomizer", typeof(MersenneTwister), VariableKind.In));
+    }
+
+    public override IOperation Apply(IScope scope) {
+      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
+      MersenneTwister tw = GetVariableValue<MersenneTwister>("Random", scope, true);
+
+      for(int i = 0; i < dataset.Rows - 1; i++) {
+        int j = tw.Next(i, dataset.Rows);
+        ExchangeRows(dataset, i, j);
+      }
+
+      return null;
+    }
+
+    private void ExchangeRows(Dataset dataset, int i, int j) {
+      for(int k = 0; k < dataset.Columns; k++) {
+        double temp = dataset.GetValue(i, k);
+        dataset.SetValue(i, k, dataset.GetValue(j, k));
+        dataset.SetValue(j, k, temp);
+      }
+    }
+  }
+}
Index: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/GPClassificationEvaluatorBase.cs
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/GPClassificationEvaluatorBase.cs	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/GPClassificationEvaluatorBase.cs	(revision 1299)
@@ -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: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/HeuristicLab.GP.StructureIdentification.Classification.csproj
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/HeuristicLab.GP.StructureIdentification.Classification.csproj	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/HeuristicLab.GP.StructureIdentification.Classification.csproj	(revision 1299)
@@ -0,0 +1,132 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>9.0.30729</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{7C20D100-8BEB-433A-9499-F075E2CB9297}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>HeuristicLab.GP.StructureIdentification.Classification</RootNamespace>
+    <AssemblyName>HeuristicLab.GP.StructureIdentification.Classification-3.2</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SignAssembly>true</SignAssembly>
+    <AssemblyOriginatorKeyFile>HeuristicLab.snk</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Xml.Linq">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Data.DataSetExtensions">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AccuracyEvaluator.cs" />
+    <Compile Include="ClassificationMeanSquaredErrorEvaluator.cs" />
+    <Compile Include="ConfusionMatrixEvaluator.cs" />
+    <Compile Include="DatasetShuffler.cs" />
+    <Compile Include="GPClassificationEvaluatorBase.cs" />
+    <Compile Include="CrossValidation.cs" />
+    <Compile Include="HeuristicLabGPClassificationPlugin.cs" />
+    <Compile Include="MulticlassModeller.cs" />
+    <Compile Include="MulticlassOneVsOneAnalyzer.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="ROCAnalyzer.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\HeuristicLab.Constraints\HeuristicLab.Constraints.csproj">
+      <Project>{FCD62C6F-4793-4593-AE9A-0BDCA256EE99}</Project>
+      <Name>HeuristicLab.Constraints</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\HeuristicLab.Core\HeuristicLab.Core.csproj">
+      <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project>
+      <Name>HeuristicLab.Core</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\HeuristicLab.DataAnalysis\HeuristicLab.DataAnalysis.csproj">
+      <Project>{7DD3A97A-56E9-462F-90E2-A351FE7AF5C2}</Project>
+      <Name>HeuristicLab.DataAnalysis</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\HeuristicLab.Data\HeuristicLab.Data.csproj">
+      <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project>
+      <Name>HeuristicLab.Data</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\HeuristicLab.GP.StructureIdentification\HeuristicLab.GP.StructureIdentification.csproj">
+      <Project>{74223A32-C726-4978-BE78-37113A18373C}</Project>
+      <Name>HeuristicLab.GP.StructureIdentification</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\HeuristicLab.GP\HeuristicLab.GP.csproj">
+      <Project>{1F1CF3ED-374C-4288-995B-93F6B872F571}</Project>
+      <Name>HeuristicLab.GP</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
+      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
+      <Name>HeuristicLab.PluginInfrastructure</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\HeuristicLab.Random\HeuristicLab.Random.csproj">
+      <Project>{47019A74-F7F7-482E-83AA-D3F4F777E879}</Project>
+      <Name>HeuristicLab.Random</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="HeuristicLab.snk" />
+    <None Include="Properties\AssemblyInfo.frame" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+  <PropertyGroup>
+    <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+set ProjectDir=$(ProjectDir)
+set SolutionDir=$(SolutionDir)
+set Outdir=$(Outdir)
+
+call PreBuildEvent.cmd</PreBuildEvent>
+  </PropertyGroup>
+</Project>
Index: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/HeuristicLabGPClassificationPlugin.cs
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/HeuristicLabGPClassificationPlugin.cs	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/HeuristicLabGPClassificationPlugin.cs	(revision 1299)
@@ -0,0 +1,40 @@
+#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.Text;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.GP.StructureIdentification.Classification {
+  [ClassInfo(Name = "HeuristicLab.GP.StructureIdentification.Classification-3.2")]
+  [PluginFile(Filename = "HeuristicLab.GP.StructureIdentification.Classification-3.2.dll", Filetype = PluginFileType.Assembly)]
+  [Dependency(Dependency = "HeuristicLab.Constraints-3.2")]
+  [Dependency(Dependency = "HeuristicLab.Core-3.2")]
+  [Dependency(Dependency = "HeuristicLab.Data-3.2")]
+  [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")]
+  [Dependency(Dependency = "HeuristicLab.GP-3.2")]
+  [Dependency(Dependency = "HeuristicLab.GP.StructureIdentification-3.2")]
+  [Dependency(Dependency = "HeuristicLab.Operators-3.2")]
+  [Dependency(Dependency = "HeuristicLab.Random-3.2")]
+  public class HeuristicLabGPClassificationPlugin : PluginBase {
+  }
+}
Index: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/MulticlassModeller.cs
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/MulticlassModeller.cs	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/MulticlassModeller.cs	(revision 1299)
@@ -0,0 +1,150 @@
+#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.Text;
+using System.Xml;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.DataAnalysis;
+
+namespace HeuristicLab.GP.StructureIdentification.Classification {
+  public class MulticlassModeller : OperatorBase {
+
+    private const string DATASET = "Dataset";
+    private const string TARGETVARIABLE = "TargetVariable";
+    private const string TARGETCLASSVALUES = "TargetClassValues";
+    private const string TRAININGSAMPLESSTART = "TrainingSamplesStart";
+    private const string TRAININGSAMPLESEND = "TrainingSamplesEnd";
+    private const string VALIDATIONSAMPLESSTART = "ValidationSamplesStart";
+    private const string VALIDATIONSAMPLESEND = "ValidationSamplesEnd";
+    private const string CLASSAVALUE = "ClassAValue";
+    private const string CLASSBVALUE = "ClassBValue";
+    private const double EPSILON = 1E-6;
+    public override string Description {
+      get { return @"TASK"; }
+    }
+
+    public MulticlassModeller()
+      : base() {
+      AddVariableInfo(new VariableInfo(DATASET, "The original dataset and the new dataset parts in the newly created subscopes", typeof(Dataset), VariableKind.In));
+      AddVariableInfo(new VariableInfo(TARGETVARIABLE, "TargetVariable", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo(TARGETCLASSVALUES, "Class values of the target variable in the original dataset and in the new dataset parts", typeof(ItemList<DoubleData>), VariableKind.In | VariableKind.New));
+      AddVariableInfo(new VariableInfo(CLASSAVALUE, "The original class value of the new class A", typeof(DoubleData), VariableKind.New));
+      AddVariableInfo(new VariableInfo(CLASSBVALUE, "The original class value of the new class B", typeof(DoubleData), VariableKind.New));
+      AddVariableInfo(new VariableInfo(TRAININGSAMPLESSTART, "The start of training samples in the original dataset and starts of training samples in the new dataset parts", typeof(IntData), VariableKind.In | VariableKind.New));
+      AddVariableInfo(new VariableInfo(TRAININGSAMPLESEND, "The end of training samples in the original dataset and ends of training samples in the new dataset parts", typeof(IntData), VariableKind.In | VariableKind.New));
+      AddVariableInfo(new VariableInfo(VALIDATIONSAMPLESSTART, "The start of validation samples in the original dataset and starts of validation samples in the new dataset parts", typeof(IntData), VariableKind.In | VariableKind.New));
+      AddVariableInfo(new VariableInfo(VALIDATIONSAMPLESEND, "The end of validation samples in the original dataset and ends of validation samples in the new dataset parts", typeof(IntData), VariableKind.In | VariableKind.New));
+    }
+
+    public override IOperation Apply(IScope scope) {
+      Dataset origDataset = GetVariableValue<Dataset>(DATASET, scope, true);
+      int targetVariable = GetVariableValue<IntData>(TARGETVARIABLE, scope, true).Data;
+      ItemList<DoubleData> classValues = GetVariableValue<ItemList<DoubleData>>(TARGETCLASSVALUES, scope, true);
+      int origTrainingSamplesStart = GetVariableValue<IntData>(TRAININGSAMPLESSTART, scope, true).Data;
+      int origTrainingSamplesEnd = GetVariableValue<IntData>(TRAININGSAMPLESEND, scope, true).Data;
+      int origValidationSamplesStart = GetVariableValue<IntData>(VALIDATIONSAMPLESSTART, scope, true).Data;
+      int origValidationSamplesEnd = GetVariableValue<IntData>(VALIDATIONSAMPLESEND, scope, true).Data;
+      ItemList<DoubleData> binaryClassValues = new ItemList<DoubleData>();
+      binaryClassValues.Add(new DoubleData(0.0));
+      binaryClassValues.Add(new DoubleData(1.0));
+      for (int i = 0; i < classValues.Count - 1; i++) {
+        for (int j = i + 1; j < classValues.Count; j++) {
+          Dataset dataset = new Dataset();
+          dataset.Columns = origDataset.Columns;
+          double classAValue = classValues[i].Data;
+          double classBValue = classValues[j].Data;
+          int trainingSamplesStart;
+          int trainingSamplesEnd;
+          int validationSamplesStart;
+          int validationSamplesEnd;
+
+          trainingSamplesStart = 0;
+          List<double[]> rows = new List<double[]>();
+          for (int k = origTrainingSamplesStart; k < origTrainingSamplesEnd; k++) {
+            double[] row = new double[dataset.Columns];
+            double targetValue = origDataset.GetValue(k, targetVariable);
+            if (IsEqual(targetValue, classAValue)) {
+              for (int l = 0; l < row.Length; l++) {
+                row[l] = origDataset.GetValue(k, l);
+              }
+              row[targetVariable] = 0;
+              rows.Add(row);
+            } else if (IsEqual(targetValue, classBValue)) {
+              for (int l = 0; l < row.Length; l++) {
+                row[l] = origDataset.GetValue(k, l);
+              }
+              row[targetVariable] = 1.0;
+              rows.Add(row);
+            }
+          }
+          trainingSamplesEnd = rows.Count;
+          validationSamplesStart = rows.Count;
+          for (int k = origValidationSamplesStart; k < origValidationSamplesEnd; k++) {
+            double[] row = new double[dataset.Columns];
+            double targetValue = origDataset.GetValue(k, targetVariable);
+            if (IsEqual(targetValue, classAValue)) {
+              for (int l = 0; l < row.Length; l++) {
+                row[l] = origDataset.GetValue(k, l);
+              }
+              row[targetVariable] = 0;
+              rows.Add(row);
+            } else if (IsEqual(targetValue, classBValue)) {
+              for (int l = 0; l < row.Length; l++) {
+                row[l] = origDataset.GetValue(k, l);
+              }
+              row[targetVariable] = 1.0;
+              rows.Add(row);
+            }
+          }
+          validationSamplesEnd = rows.Count;
+
+          dataset.Rows = rows.Count;
+          dataset.Samples = new double[dataset.Rows * dataset.Columns];
+          for (int k = 0; k < dataset.Rows; k++) {
+            for (int l = 0; l < dataset.Columns; l++) {
+              dataset.SetValue(k, l, rows[k][l]);
+            }
+          }
+
+          Scope childScope = new Scope(classAValue + " vs. " + classBValue);
+
+          childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(TARGETCLASSVALUES), binaryClassValues));
+          childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(CLASSAVALUE), new DoubleData(classAValue)));
+          childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(CLASSBVALUE), new DoubleData(classBValue)));
+          childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(TRAININGSAMPLESSTART), new IntData(trainingSamplesStart)));
+          childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(TRAININGSAMPLESEND), new IntData(trainingSamplesEnd)));
+          childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(VALIDATIONSAMPLESSTART), new IntData(validationSamplesStart)));
+          childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(VALIDATIONSAMPLESEND), new IntData(validationSamplesEnd)));
+          childScope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(DATASET), dataset));
+          scope.AddSubScope(childScope);
+        }
+      }
+      return null;
+    }
+
+    private bool IsEqual(double x, double y) {
+      return Math.Abs(x - y) < EPSILON;
+    }
+  }
+}
Index: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/MulticlassOneVsOneAnalyzer.cs
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/MulticlassOneVsOneAnalyzer.cs	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/MulticlassOneVsOneAnalyzer.cs	(revision 1299)
@@ -0,0 +1,128 @@
+#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.Text;
+using System.Xml;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.DataAnalysis;
+using HeuristicLab.GP.StructureIdentification;
+
+namespace HeuristicLab.GP.StructureIdentification.Classification {
+  public class MulticlassOneVsOneAnalyzer : OperatorBase {
+
+    private const string DATASET = "Dataset";
+    private const string TARGETVARIABLE = "TargetVariable";
+    private const string TARGETCLASSVALUES = "TargetClassValues";
+    private const string SAMPLESSTART = "SamplesStart";
+    private const string SAMPLESEND = "SamplesEnd";
+    private const string CLASSAVALUE = "ClassAValue";
+    private const string CLASSBVALUE = "ClassBValue";
+    private const string BESTMODELLSCOPE = "BestValidationSolution";
+    private const string BESTMODELL = "FunctionTree";
+    private const string VOTES = "Votes";
+    private const string ACCURACY = "Accuracy";
+
+    private const double EPSILON = 1E-6;
+    public override string Description {
+      get { return @"TASK"; }
+    }
+
+    public MulticlassOneVsOneAnalyzer()
+      : base() {
+      AddVariableInfo(new VariableInfo(DATASET, "The dataset to use", typeof(Dataset), VariableKind.In));
+      AddVariableInfo(new VariableInfo(TARGETVARIABLE, "Target variable", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo(TARGETCLASSVALUES, "Class values of the target variable in the original dataset", typeof(ItemList<DoubleData>), VariableKind.In));
+      AddVariableInfo(new VariableInfo(CLASSAVALUE, "The original class value of the class A in the subscope", typeof(DoubleData), VariableKind.In));
+      AddVariableInfo(new VariableInfo(CLASSBVALUE, "The original class value of the class B in the subscope", typeof(DoubleData), VariableKind.In));
+      AddVariableInfo(new VariableInfo(SAMPLESSTART, "The start of samples in the original dataset", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo(SAMPLESEND, "The end of samples in the original dataset", typeof(IntData), VariableKind.In));
+      AddVariableInfo(new VariableInfo(BESTMODELLSCOPE, "The variable containing the scope of the model (incl. meta data)", typeof(IScope), VariableKind.In));
+      AddVariableInfo(new VariableInfo(BESTMODELL, "The variable in the scope of the model that contains the actual model", typeof(BakedFunctionTree), VariableKind.In));
+      AddVariableInfo(new VariableInfo(VOTES, "Array with the votes for each instance", typeof(IntMatrixData), VariableKind.New));
+      AddVariableInfo(new VariableInfo(ACCURACY, "Accuracy of the one-vs-one multi-cass classifier", typeof(DoubleData), VariableKind.New));
+    }
+
+    public override IOperation Apply(IScope scope) {
+      Dataset dataset = GetVariableValue<Dataset>(DATASET, scope, true);
+      int targetVariable = GetVariableValue<IntData>(TARGETVARIABLE, scope, true).Data;
+      int samplesStart = GetVariableValue<IntData>(SAMPLESSTART, scope, true).Data;
+      int samplesEnd = GetVariableValue<IntData>(SAMPLESEND, scope, true).Data;
+      ItemList<DoubleData> classValues = GetVariableValue<ItemList<DoubleData>>(TARGETCLASSVALUES, scope, true);
+      int[,] votes = new int[samplesEnd - samplesStart, classValues.Count];
+
+      foreach(IScope childScope in scope.SubScopes) {
+        double classAValue = GetVariableValue<DoubleData>(CLASSAVALUE, childScope, true).Data;
+        double classBValue = GetVariableValue<DoubleData>(CLASSBVALUE, childScope, true).Data;
+        IScope bestScope = GetVariableValue<IScope>(BESTMODELLSCOPE, childScope, true);
+        BakedFunctionTree functionTree = GetVariableValue<BakedFunctionTree>(BESTMODELL, bestScope, true);
+
+        BakedTreeEvaluator evaluator = new BakedTreeEvaluator();
+        evaluator.ResetEvaluator(functionTree, dataset, targetVariable, samplesStart, samplesEnd, 1.0);
+
+        for(int i = 0; i < (samplesEnd - samplesStart); i++) {
+          double est = evaluator.Evaluate(i + samplesStart);
+          if(est < 0.5) {
+            CastVote(votes, i, classAValue, classValues);
+          } else {
+            CastVote(votes, i, classBValue, classValues);
+          }
+        }
+      }
+
+      int correctlyClassified = 0;
+      for(int i = 0; i < (samplesEnd - samplesStart); i++) {
+        double originalClassValue = dataset.GetValue(i + samplesStart, targetVariable);
+        double estimatedClassValue = classValues[0].Data;
+        int maxVotes = votes[i, 0];
+        int sameVotes = 0;
+        for(int j = 1; j < classValues[j].Data; j++) {
+          if(votes[i, j] > maxVotes) {
+            maxVotes = votes[i, j];
+            estimatedClassValue = classValues[j].Data;
+            sameVotes = 0;
+          } else if(votes[i, j] == maxVotes) {
+            sameVotes++;
+          }
+        }
+        if(IsEqual(originalClassValue, estimatedClassValue) && sameVotes == 0) correctlyClassified++;
+      }
+
+      double accuracy = correctlyClassified / (double)(samplesEnd - samplesStart);
+
+      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(VOTES), new IntMatrixData(votes)));
+      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(ACCURACY), new DoubleData(accuracy)));
+      return null;
+    }
+
+    private void CastVote(int[,] votes, int sample, double votedClass, ItemList<DoubleData> classValues) {
+      for(int i = 0; i < classValues.Count; i++) {
+        if(IsEqual(classValues[i].Data, votedClass)) votes[sample, i]++;
+      }
+    }
+
+    private bool IsEqual(double x, double y) {
+      return Math.Abs(x - y) < EPSILON;
+    }
+  }
+}
Index: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/Properties/AssemblyInfo.frame
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/Properties/AssemblyInfo.frame	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/Properties/AssemblyInfo.frame	(revision 1299)
@@ -0,0 +1,58 @@
+#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.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using HeuristicLab.PluginInfrastructure;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HeuristicLab.GP.StructureIdentification.Classification")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HeuristicLab")]
+[assembly: AssemblyCopyright("(c) 2002-2008 HEAL")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("863021a4-3cde-48be-8af6-dac1077f5fb5")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers 
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("3.2.0.$WCREV$")]
+[assembly: AssemblyFileVersion("3.2.0.$WCREV$")]
+[assembly: AssemblyBuildDate("$WCNOW$")]
Index: branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/ROCAnalyzer.cs
===================================================================
--- branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/ROCAnalyzer.cs	(revision 1299)
+++ branches/plugins/HeuristicLab.GP.StructureIdentification.Classification/3.2/ROCAnalyzer.cs	(revision 1299)
@@ -0,0 +1,245 @@
+﻿#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.DataAnalysis;
+
+
+namespace HeuristicLab.GP.StructureIdentification.Classification {
+  public class ROCAnalyzer : OperatorBase {
+    private ItemList myRocValues;
+    private ItemList<DoubleData> myAucValues;
+
+
+    public override string Description {
+      get { return @"Calculate TPR & FPR for various thresholds on dataset"; }
+    }
+
+    public ROCAnalyzer()
+      : base() {
+      AddVariableInfo(new VariableInfo("Values", "Item list holding the estimated and original values for the ROCAnalyzer", typeof(ItemList), VariableKind.In));
+      AddVariableInfo(new VariableInfo("ROCValues", "The values of the ROCAnalyzer, namely TPR & FPR", typeof(ItemList), VariableKind.New | VariableKind.Out));
+      AddVariableInfo(new VariableInfo("AUCValues", "The AUC Values for each ROC", typeof(ItemList<DoubleData>), VariableKind.New | VariableKind.Out));
+    }
+
+    public override IOperation Apply(IScope scope) {
+      #region initialize HL-variables
+      ItemList values = GetVariableValue<ItemList>("Values", scope, true);
+      myRocValues = GetVariableValue<ItemList>("ROCValues", scope, false, false);
+      if (myRocValues == null) {
+        myRocValues = new ItemList();
+        IVariableInfo info = GetVariableInfo("ROCValues");
+        if (info.Local)
+          AddVariable(new HeuristicLab.Core.Variable(info.ActualName, myRocValues));
+        else
+          scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(info.FormalName), myRocValues));
+      } else {
+        myRocValues.Clear();
+      }
+
+      myAucValues = GetVariableValue<ItemList<DoubleData>>("AUCValues", scope, false, false);
+      if (myAucValues == null) {
+        myAucValues = new ItemList<DoubleData>();
+        IVariableInfo info = GetVariableInfo("AUCValues");
+        if (info.Local)
+          AddVariable(new HeuristicLab.Core.Variable(info.ActualName, myAucValues));
+        else
+          scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(info.FormalName), myAucValues));
+      } else {
+        myAucValues.Clear();
+      }
+      #endregion
+
+      //calculate new ROC Values
+      double estimated = 0.0;
+      double original = 0.0;
+
+      //initialize classes dictionary
+      SortedDictionary<double, List<double>> classes = new SortedDictionary<double, List<double>>();
+      foreach (ItemList value in values) {
+        estimated = ((DoubleData)value[0]).Data;
+        original = ((DoubleData)value[1]).Data;
+        if (!classes.ContainsKey(original))
+          classes[original] = new List<double>();
+        classes[original].Add(estimated);
+      }
+      foreach (double key in classes.Keys)
+        classes[key].Sort();
+  
+      //calculate ROC Curve
+      foreach (double key in classes.Keys) {
+        CalculateBestROC(key, classes);
+      }
+
+      return null;
+    }
+
+    protected void CalculateBestROC(double positiveClassKey, SortedDictionary<double, List<double>> classes) {
+      List<KeyValuePair<double, double>> rocCharacteristics;
+      List<KeyValuePair<double, double>> bestROC;
+      List<KeyValuePair<double, double>> actROC;
+
+      List<double> negatives = new List<double>();
+      foreach (double key in classes.Keys) {
+        if (key != positiveClassKey)
+          negatives.AddRange(classes[key]);
+      }
+      List<double> actNegatives = negatives.Where<double>(value => value < classes[positiveClassKey].Max<double>()).ToList<double>();
+      actNegatives.Add(classes[positiveClassKey].Max<double>());
+      actNegatives.Sort();
+      actNegatives = actNegatives.Reverse<double>().ToList<double>();
+
+      double bestAUC = double.MinValue;
+      double actAUC = 0;
+      //first class
+      if (classes.Keys.ElementAt<double>(0) == positiveClassKey) {
+        rocCharacteristics = null;
+        CalculateROCValuesAndAUC(classes[positiveClassKey], actNegatives, negatives.Count, double.MinValue, ref rocCharacteristics, out  actROC, out actAUC);
+        myAucValues.Add(new DoubleData(actAUC));
+        myRocValues.Add(Convert(actROC));
+      }
+        //middle classes  
+      else if (classes.Keys.ElementAt<double>(classes.Keys.Count - 1) != positiveClassKey) {
+        rocCharacteristics = null;
+        bestROC = new List<KeyValuePair<double, double>>();
+        foreach (double minThreshold in classes[positiveClassKey].Distinct<double>()) {
+          CalculateROCValuesAndAUC(classes[positiveClassKey], actNegatives, negatives.Count, minThreshold, ref rocCharacteristics, out  actROC, out actAUC);
+          if (actAUC > bestAUC) {
+            bestAUC = actAUC;
+            bestROC = actROC;
+          }
+        }
+          myAucValues.Add(new DoubleData(bestAUC));
+          myRocValues.Add(Convert(bestROC));
+        
+      } else { //last class
+        actNegatives = negatives.Where<double>(value => value > classes[positiveClassKey].Min<double>()).ToList<double>();
+        actNegatives.Add(classes[positiveClassKey].Min<double>());
+        actNegatives.Sort();
+        CalculateROCValuesAndAUCForLastClass(classes[positiveClassKey], actNegatives, negatives.Count, out bestROC, out bestAUC);
+        myAucValues.Add(new DoubleData(bestAUC));
+        myRocValues.Add(Convert(bestROC));
+
+      }
+
+    }
+
+    protected void CalculateROCValuesAndAUC(List<double> positives, List<double> negatives, int negativesCount, double minThreshold,
+      ref List<KeyValuePair<double, double>> rocCharacteristics, out List<KeyValuePair<double, double>> roc, out double auc) {
+      double actTP = -1;
+      double actFP = -1;
+      double oldTP = -1;
+      double oldFP = -1;
+      auc = 0;
+      roc = new List<KeyValuePair<double, double>>();
+
+      actTP = positives.Count<double>(value => minThreshold <= value && value <= negatives.Max<double>());
+      actFP = negatives.Count<double>(value => minThreshold <= value );
+      //add point (1,TPR) for AUC 'correct' calculation
+      roc.Add(new KeyValuePair<double, double>(1, actTP / positives.Count));
+      oldTP = actTP;
+      oldFP = negativesCount;
+      roc.Add(new KeyValuePair<double, double>(actFP / negativesCount, actTP / positives.Count));
+
+      if (rocCharacteristics == null) {
+        rocCharacteristics = new List<KeyValuePair<double, double>>();
+        foreach (double maxThreshold in negatives.Distinct<double>()) {
+          auc += ((oldTP + actTP) / positives.Count) * ((oldFP - actFP) / negativesCount) / 2;
+          oldTP = actTP;
+          oldFP = actFP;
+          actTP = positives.Count<double>(value => minThreshold <= value && value < maxThreshold);
+          actFP = negatives.Count<double>(value => minThreshold <= value && value < maxThreshold);
+          rocCharacteristics.Add(new KeyValuePair<double, double>(oldTP - actTP, oldFP - actFP));
+          roc.Add(new KeyValuePair<double, double>(actFP / negativesCount, actTP / positives.Count));
+
+          //stop calculation if truePositiveRate == 0 => straight line with y=0 & save runtime
+          if ((actTP == 0) || (actFP == 0))
+            break;
+        }
+        auc += ((oldTP + actTP) / positives.Count) * ((oldFP - actFP) / negativesCount) / 2;
+      } else { //characteristics of ROCs calculated 
+        foreach (KeyValuePair<double, double> rocCharac in rocCharacteristics) {
+          auc += ((oldTP + actTP) / positives.Count) * ((oldFP - actFP) / negativesCount) / 2;
+          oldTP = actTP;
+          oldFP = actFP;
+          actTP = oldTP - rocCharac.Key;
+          actFP = oldFP - rocCharac.Value;
+          roc.Add(new KeyValuePair<double, double>(actFP / negativesCount, actTP / positives.Count));
+          if ((actTP == 0) || (actFP == 0))
+            break;
+        }
+        auc += ((oldTP + actTP) / positives.Count) * ((oldFP - actFP) / negativesCount) / 2;
+      }
+    }
+
+    protected void CalculateROCValuesAndAUCForLastClass(List<double> positives, List<double> negatives, int negativesCount,
+      out List<KeyValuePair<double, double>> roc, out double auc) {
+      double actTP = -1;
+      double actFP = -1;
+      double oldTP = -1;
+      double oldFP = -1;
+      auc = 0;
+      roc = new List<KeyValuePair<double, double>>();
+
+      actTP = positives.Count<double>(value => value >= negatives.Min<double>());
+      actFP = negatives.Count<double>(value => value >= negatives.Min<double>());
+      //add point (1,TPR) for AUC 'correct' calculation
+      roc.Add(new KeyValuePair<double, double>(1, actTP / positives.Count));
+      oldTP = actTP;
+      oldFP = negativesCount;
+      roc.Add(new KeyValuePair<double, double>(actFP / negativesCount, actTP / positives.Count));
+
+      foreach (double minThreshold in negatives.Distinct<double>()) {
+        auc += ((oldTP + actTP) / positives.Count) * ((oldFP - actFP) / negativesCount) / 2;
+        oldTP = actTP;
+        oldFP = actFP;
+        actTP = positives.Count<double>(value => minThreshold < value);
+        actFP = negatives.Count<double>(value => minThreshold < value);
+        roc.Add(new KeyValuePair<double, double>(actFP / negativesCount, actTP / positives.Count));
+
+        //stop calculation if truePositiveRate == 0 => straight line with y=0 & save runtime
+        if (actTP == 0 || actFP==0)
+          break;
+      }
+      auc += ((oldTP + actTP) / positives.Count) * ((oldFP - actFP) / negativesCount) / 2;
+
+    }
+
+    private ItemList Convert(List<KeyValuePair<double, double>> data) {
+      ItemList list = new ItemList();
+      ItemList row;
+      foreach (KeyValuePair<double, double> dataPoint in data) {
+        row = new ItemList();
+        row.Add(new DoubleData(dataPoint.Key));
+        row.Add(new DoubleData(dataPoint.Value));
+        list.Add(row);
+      }
+      return list;
+    }
+
+  }
+
+}
