Index: branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
===================================================================
--- branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj	(revision 7458)
+++ branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj	(revision 7459)
@@ -128,4 +128,7 @@
     <Compile Include="Implementation\Classification\ClassificationSolutionBase.cs" />
     <Compile Include="Implementation\Classification\DiscriminantFunctionClassificationSolutionBase.cs" />
+    <Compile Include="Implementation\Classification\WeightCalculators\AccuracyWeightCalculator.cs" />
+    <Compile Include="Implementation\Classification\WeightCalculators\MajorityVoteWeightCalculator.cs" />
+    <Compile Include="Implementation\Classification\WeightCalculators\WeightCalculator.cs" />
     <Compile Include="Implementation\Clustering\ClusteringProblem.cs" />
     <Compile Include="Implementation\Clustering\ClusteringProblemData.cs" />
@@ -144,4 +147,5 @@
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="Interfaces\Classification\IClassificationEnsembleSolutionWeightCalculator.cs" />
     <Compile Include="Interfaces\Classification\IDiscriminantFunctionThresholdCalculator.cs" />
     <Compile Include="Interfaces\Regression\IRegressionEnsembleModel.cs">
Index: branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs
===================================================================
--- branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs	(revision 7458)
+++ branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs	(revision 7459)
@@ -28,4 +28,5 @@
 using HeuristicLab.Data;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis.Interfaces.Classification;
 
 namespace HeuristicLab.Problems.DataAnalysis {
@@ -55,4 +56,6 @@
     private Dictionary<IClassificationModel, IntRange> testPartitions;
 
+    private IClassificationEnsembleSolutionWeightCalculator weightCalculator;
+
     [StorableConstructor]
     private ClassificationEnsembleSolution(bool deserializing)
@@ -95,4 +98,6 @@
       classificationSolutions = new ItemCollection<IClassificationSolution>();
 
+      weightCalculator = new AccuracyWeightCalculator();
+
       RegisterClassificationSolutionsEventHandler();
     }
@@ -153,4 +158,5 @@
                                          .ToList();
         var rowsEnumerator = rows.GetEnumerator();
+        IEnumerable<double> weights = weightCalculator.CalculateWeights(classificationSolutions);
         // aggregate to make sure that MoveNext is called for all enumerators 
         while (rowsEnumerator.MoveNext() & estimatedValuesEnumerators.Select(en => en.EstimatedValuesEnumerator.MoveNext()).Aggregate(true, (acc, b) => acc & b)) {
@@ -160,5 +166,5 @@
                                     where RowIsTrainingForModel(currentRow, pair.Model) && !RowIsTestForModel(currentRow, pair.Model)
                                     select pair.EstimatedValuesEnumerator;
-          yield return AggregateEstimatedClassValues(selectedEnumerators.Select(x => x.Current));
+          yield return AggregateEstimatedClassValues(selectedEnumerators.Select(x => x.Current), weights);
         }
       }
@@ -172,4 +178,5 @@
                                          .ToList();
         var rowsEnumerator = ProblemData.TestIndizes.GetEnumerator();
+        IEnumerable<double> weights = weightCalculator.CalculateWeights(classificationSolutions);
         // aggregate to make sure that MoveNext is called for all enumerators 
         while (rowsEnumerator.MoveNext() & estimatedValuesEnumerators.Select(en => en.EstimatedValuesEnumerator.MoveNext()).Aggregate(true, (acc, b) => acc & b)) {
@@ -180,5 +187,5 @@
                                     select pair.EstimatedValuesEnumerator;
 
-          yield return AggregateEstimatedClassValues(selectedEnumerators.Select(x => x.Current));
+          yield return AggregateEstimatedClassValues(selectedEnumerators.Select(x => x.Current), weights);
         }
       }
@@ -196,6 +203,7 @@
 
     public override IEnumerable<double> GetEstimatedClassValues(IEnumerable<int> rows) {
+      IEnumerable<double> weights = weightCalculator.CalculateWeights(classificationSolutions);
       return from xs in GetEstimatedClassValueVectors(ProblemData.Dataset, rows)
-             select AggregateEstimatedClassValues(xs);
+             select AggregateEstimatedClassValues(xs, weights);
     }
 
@@ -212,11 +220,30 @@
     }
 
-    private double AggregateEstimatedClassValues(IEnumerable<double> estimatedClassValues) {
-      return estimatedClassValues
-      .GroupBy(x => x)
-      .OrderBy(g => -g.Count())
-      .Select(g => g.Key)
-      .DefaultIfEmpty(double.NaN)
-      .First();
+    private double AggregateEstimatedClassValues(IEnumerable<double> estimatedClassValues, IEnumerable<double> weights) {
+      IDictionary<double, double> weightSum = new Dictionary<double, double>();
+      for (int i = 0; i < estimatedClassValues.Count(); i++) {
+        if (!weightSum.ContainsKey(estimatedClassValues.ElementAt(i)))
+          weightSum[estimatedClassValues.ElementAt(i)] = 0.0;
+        weightSum[estimatedClassValues.ElementAt(i)] += weights.ElementAt(i);
+      }
+      if (weightSum.Count <= 0)
+        return double.NaN;
+      var max = weightSum.Max(x => x.Value);
+      max = weightSum
+        .Where(x => x.Value.Equals(max))
+        .Select(x => x.Key)
+        .First();
+      return max;
+      //old code
+      //return weightSum
+      //  .Where(x => x.Value.Equals(max))
+      //  .Select(x => x.Key)
+      //  .First();
+      //return estimatedClassValues
+      //.GroupBy(x => x)
+      //.OrderBy(g => -g.Count())
+      //.Select(g => g.Key)
+      //.DefaultIfEmpty(double.NaN)
+      //.First();
     }
     #endregion
Index: branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/AccuracyWeightCalculator.cs
===================================================================
--- branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/AccuracyWeightCalculator.cs	(revision 7459)
+++ branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/AccuracyWeightCalculator.cs	(revision 7459)
@@ -0,0 +1,59 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+  /// <summary>
+  /// Represents a weight calculator that gives every classification solution a weight based on the accuracy..
+  /// </summary>
+  [StorableClass]
+  [Item("AccuracyWeightCalculator", "Represents a weight calculator that gives every classification solution a weight based on the accuracy.")]
+  public class AccuracyWeightCalculator : WeightCalculator {
+
+    public AccuracyWeightCalculator()
+      : base() {
+    }
+
+    [StorableConstructor]
+    protected AccuracyWeightCalculator(bool deserializing) : base(deserializing) { }
+    protected AccuracyWeightCalculator(AccuracyWeightCalculator original, Cloner cloner)
+      : base(original, cloner) {
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new AccuracyWeightCalculator(this, cloner);
+    }
+
+    public override IEnumerable<double> CalculateWeights(ItemCollection<IClassificationSolution> classificationSolutions) {
+      double sum = classificationSolutions.Select(s => s.TestAccuracy).Sum();
+      List<double> weights = new List<double>();
+      foreach (var item in classificationSolutions) {
+        weights.Add(item.TestAccuracy / sum);
+      }
+      return weights;
+    }
+  }
+}
Index: branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/MajorityVoteWeightCalculator.cs
===================================================================
--- branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/MajorityVoteWeightCalculator.cs	(revision 7459)
+++ branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/MajorityVoteWeightCalculator.cs	(revision 7459)
@@ -0,0 +1,54 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+  /// <summary>
+  /// Represents a weight calculator that gives every classification solution the same weight.
+  /// </summary>
+  [StorableClass]
+  [Item("MajorityVoteWeightCalculator", "Represents a weight calculator that gives every classification solution the same weight.")]
+  public class MajorityVoteWeightCalculator : WeightCalculator {
+
+    public MajorityVoteWeightCalculator()
+      : base() {
+    }
+
+    [StorableConstructor]
+    protected MajorityVoteWeightCalculator(bool deserializing) : base(deserializing) { }
+    protected MajorityVoteWeightCalculator(MajorityVoteWeightCalculator original, Cloner cloner)
+      : base(original, cloner) {
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new MajorityVoteWeightCalculator(this, cloner);
+    }
+
+    public override IEnumerable<double> CalculateWeights(ItemCollection<IClassificationSolution> classificationSolutions) {
+      return Enumerable.Repeat<double>(1, classificationSolutions.Count);
+    }
+  }
+}
Index: branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/WeightCalculator.cs
===================================================================
--- branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/WeightCalculator.cs	(revision 7459)
+++ branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/WeightCalculator.cs	(revision 7459)
@@ -0,0 +1,47 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Collections.Generic;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis.Interfaces.Classification;
+
+namespace HeuristicLab.Problems.DataAnalysis {
+  /// <summary>
+  /// Base class for weight calculators for classification solutions in an ensemble.
+  /// </summary>
+  [StorableClass]
+  public abstract class WeightCalculator : NamedItem, IClassificationEnsembleSolutionWeightCalculator {
+    [StorableConstructor]
+    protected WeightCalculator(bool deserializing) : base(deserializing) { }
+    protected WeightCalculator(WeightCalculator original, Cloner cloner)
+      : base(original, cloner) {
+    }
+    public WeightCalculator()
+      : base() {
+      this.name = ItemName;
+      this.description = ItemDescription;
+    }
+
+    abstract public IEnumerable<double> CalculateWeights(ItemCollection<IClassificationSolution> classificationSolutions);
+  }
+}
Index: branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationEnsembleSolutionWeightCalculator.cs
===================================================================
--- branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationEnsembleSolutionWeightCalculator.cs	(revision 7459)
+++ branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationEnsembleSolutionWeightCalculator.cs	(revision 7459)
@@ -0,0 +1,29 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Collections.Generic;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.Problems.DataAnalysis.Interfaces.Classification {
+  public interface IClassificationEnsembleSolutionWeightCalculator {
+    IEnumerable<double> CalculateWeights(ItemCollection<IClassificationSolution> classificationSolutions);
+  }
+}
