Index: /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj
===================================================================
--- /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 15966)
+++ /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 15967)
@@ -372,5 +372,5 @@
     <Compile Include="M5Regression\Interfaces\ISplitter.cs" />
     <Compile Include="M5Regression\LeafModels\ComponentReducedLinearModel.cs" />
-    <Compile Include="M5Regression\LeafModels\DampenedLinearModel.cs" />
+    <Compile Include="M5Regression\LeafModels\DampenedModel.cs" />
     <Compile Include="M5Regression\LeafModels\PreconstructedLinearModel.cs" />
     <Compile Include="M5Regression\LeafTypes\ComplexLeaf.cs" />
@@ -380,5 +380,4 @@
     <Compile Include="M5Regression\LeafTypes\GaussianProcessLeaf.cs" />
     <Compile Include="M5Regression\LeafTypes\LinearLeaf.cs" />
-    <Compile Include="M5Regression\LeafTypes\LogisticLeaf.cs" />
     <Compile Include="M5Regression\LeafTypes\M5Leaf.cs" />
     <Compile Include="M5Regression\LeafTypes\M5regLeaf.cs" />
Index: /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/ComponentReducedLinearModel.cs
===================================================================
--- /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/ComponentReducedLinearModel.cs	(revision 15966)
+++ /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/ComponentReducedLinearModel.cs	(revision 15967)
@@ -28,7 +28,7 @@
 namespace HeuristicLab.Algorithms.DataAnalysis {
   [StorableClass]
-  public class ComponentReducedLinearModel : RegressionModel, IConfidenceRegressionModel {
+  public class ComponentReducedLinearModel : RegressionModel {
     [Storable]
-    private IConfidenceRegressionModel Model;
+    private IRegressionModel Model;
     [Storable]
     private PrincipleComponentTransformation Pca;
@@ -40,5 +40,5 @@
       Pca = cloner.Clone(original.Pca);
     }
-    public ComponentReducedLinearModel(string targetVariable, IConfidenceRegressionModel model, PrincipleComponentTransformation pca) : base(targetVariable) {
+    public ComponentReducedLinearModel(string targetVariable, IRegressionModel model, PrincipleComponentTransformation pca) : base(targetVariable) {
       Model = model;
       Pca = pca;
@@ -56,9 +56,5 @@
     }
     public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
-      return new ConfidenceRegressionSolution(this, problemData);
-    }
-    public IEnumerable<double> GetEstimatedVariances(IDataset dataset, IEnumerable<int> rows) {
-      var data = ReduceDataset(dataset, rows.ToArray());
-      return Model.GetEstimatedVariances(Pca.TransformDataset(data), Enumerable.Range(0, data.Rows));
+      return new RegressionSolution(this, problemData);
     }
 
Index: /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/DampenedModel.cs
===================================================================
--- /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/DampenedModel.cs	(revision 15967)
+++ /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/DampenedModel.cs	(revision 15967)
@@ -0,0 +1,121 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2017 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 HeuristicLab.Common;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis;
+
+namespace HeuristicLab.Algorithms.DataAnalysis {
+  //mulitdimensional extension of http://www2.stat.duke.edu/~tjl13/s101/slides/unit6lec3H.pdf
+  [StorableClass]
+  public class DampenedModel : RegressionModel {
+    [Storable]
+    protected IRegressionModel Model;
+    [Storable]
+    private double Min;
+    [Storable]
+    private double Max;
+    [Storable]
+    private double Dampening;
+
+    [StorableConstructor]
+    protected DampenedModel(bool deserializing) : base(deserializing) { }
+    protected DampenedModel(DampenedModel original, Cloner cloner) : base(original, cloner) {
+      Model = cloner.Clone(original.Model);
+      Min = original.Min;
+      Max = original.Max;
+      Dampening = original.Dampening;
+    }
+    protected DampenedModel(IRegressionModel model, IRegressionProblemData pd, double dampening) : base(model.TargetVariable) {
+      Model = model;
+      Min = pd.TargetVariableTrainingValues.Min();
+      Max = pd.TargetVariableTrainingValues.Max();
+      Dampening = dampening;
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new DampenedModel(this, cloner);
+    }
+
+    public static IConfidenceRegressionModel DampenModel(IConfidenceRegressionModel model, IRegressionProblemData pd, double dampening) {
+      return new ConfidenceDampenedModel(model, pd, dampening);
+    }
+    public static IRegressionModel DampenModel(IRegressionModel model, IRegressionProblemData pd, double dampening) {
+      var cmodel = model as IConfidenceRegressionModel;
+      return cmodel != null ? new ConfidenceDampenedModel(cmodel, pd, dampening) : new DampenedModel(model, pd, dampening);
+    }
+
+    public override IEnumerable<string> VariablesUsedForPrediction {
+      get { return Model.VariablesUsedForPrediction; }
+    }
+    public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
+      var slow = Sigmoid(-Dampening);
+      var shigh = Sigmoid(Dampening);
+      foreach (var x in Model.GetEstimatedValues(dataset, rows)) {
+        var y = Rescale(x, Min, Max, -Dampening, Dampening);
+        y = Sigmoid(y);
+        y = Rescale(y, slow, shigh, Min, Max);
+        yield return y;
+      }
+    }
+    public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
+      return new RegressionSolution(this, problemData);
+    }
+
+    private static double Rescale(double x, double oMin, double oMax, double nMin, double nMax) {
+      var d = oMax - oMin;
+      var nd = nMax - nMin;
+      if (d.IsAlmost(0)) {
+        d = 1;
+        nMin += nd / 2;
+        nd = 0;
+      }
+      return ((x - oMin) / d) * nd + nMin;
+    }
+    private static double Sigmoid(double x) {
+      return 1 / (1 + Math.Exp(-x));
+    }
+
+
+    [StorableClass]
+    private sealed class ConfidenceDampenedModel : DampenedModel, IConfidenceRegressionModel {
+      #region HLConstructors
+      [StorableConstructor]
+      private ConfidenceDampenedModel(bool deserializing) : base(deserializing) { }
+      private ConfidenceDampenedModel(ConfidenceDampenedModel original, Cloner cloner) : base(original, cloner) { }
+      public ConfidenceDampenedModel(IConfidenceRegressionModel model, IRegressionProblemData pd, double dampening) : base(model, pd, dampening) { }
+      public override IDeepCloneable Clone(Cloner cloner) {
+        return new ConfidenceDampenedModel(this, cloner);
+      }
+      #endregion
+
+      public IEnumerable<double> GetEstimatedVariances(IDataset dataset, IEnumerable<int> rows) {
+        return ((IConfidenceRegressionModel)Model).GetEstimatedVariances(dataset, rows);
+      }
+
+      public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
+        return new ConfidenceRegressionSolution(this, problemData);
+      }
+    }
+  }
+}
Index: /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/PreconstructedLinearModel.cs
===================================================================
--- /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/PreconstructedLinearModel.cs	(revision 15966)
+++ /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/PreconstructedLinearModel.cs	(revision 15967)
@@ -31,17 +31,9 @@
   //mulitdimensional extension of http://www2.stat.duke.edu/~tjl13/s101/slides/unit6lec3H.pdf
   [StorableClass]
-  internal sealed class PreconstructedLinearModel : RegressionModel, IConfidenceRegressionModel {
+  internal sealed class PreconstructedLinearModel : RegressionModel {
     [Storable]
     public Dictionary<string, double> Coefficients { get; private set; }
     [Storable]
     public double Intercept { get; private set; }
-    [Storable]
-    private Dictionary<string, double> Means { get; set; }
-    [Storable]
-    private Dictionary<string, double> Variances { get; set; }
-    [Storable]
-    private double ResidualVariance { get; set; }
-    [Storable]
-    private int SampleSize { get; set; }
 
     public override IEnumerable<string> VariablesUsedForPrediction {
@@ -54,23 +46,12 @@
       if (original.Coefficients != null) Coefficients = original.Coefficients.ToDictionary(x => x.Key, x => x.Value);
       Intercept = original.Intercept;
-      if (original.Means != null) Means = original.Means.ToDictionary(x => x.Key, x => x.Value);
-      if (original.Variances != null) Variances = original.Variances.ToDictionary(x => x.Key, x => x.Value);
-      ResidualVariance = original.ResidualVariance;
-      SampleSize = original.SampleSize;
     }
-    public PreconstructedLinearModel(Dictionary<string, double> means, Dictionary<string, double> variances, Dictionary<string, double> coefficients, double intercept, string targetvariable, double residualVariance = 0, double sampleSize = 0) : base(targetvariable) {
+    public PreconstructedLinearModel(Dictionary<string, double> coefficients, double intercept, string targetvariable) : base(targetvariable) {
       Coefficients = coefficients;
       Intercept = intercept;
-      Variances = variances;
-      Means = means;
-      ResidualVariance = 0;
-      SampleSize = 0;
     }
     public PreconstructedLinearModel(double intercept, string targetvariable) : base(targetvariable) {
       Coefficients = new Dictionary<string, double>();
       Intercept = intercept;
-      Variances = new Dictionary<string, double>();
-      ResidualVariance = 0;
-      SampleSize = 0;
     }
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -79,11 +60,9 @@
     #endregion
 
-    public static PreconstructedLinearModel CreateConfidenceLinearModel(IRegressionProblemData pd, out double rmse, out double cvRmse) {
-      rmse = double.NaN;
-      cvRmse = double.NaN;
-      return AlternativeCalculation(pd);
+    public static PreconstructedLinearModel CreateLinearModel(IRegressionProblemData pd, out double rmse) {
+      return AlternativeCalculation(pd, out rmse);
     }
 
-    private static PreconstructedLinearModel ClassicCalculation(IRegressionProblemData pd, out double rmse, out double cvRmse) {
+    private static PreconstructedLinearModel ClassicCalculation(IRegressionProblemData pd) {
       var inputMatrix = pd.Dataset.ToArray(pd.AllowedInputVariables.Concat(new[] {
         pd.TargetVariable
@@ -98,38 +77,25 @@
       alglib.lrbuild(inputMatrix, inputMatrix.GetLength(0), nFeatures, out retVal, out lm, out ar);
       if (retVal != 1) throw new ArgumentException("Error in calculation of linear regression solution");
-      rmse = ar.rmserror;
-      cvRmse = ar.cvrmserror;
 
       alglib.lrunpack(lm, out coefficients, out nFeatures);
-
-
-      var means = pd.AllowedInputVariables.ToDictionary(n => n, n => pd.Dataset.GetDoubleValues(n).Average());
-      var variances = pd.AllowedInputVariables.ToDictionary(n => n, n => pd.Dataset.GetDoubleValues(n).Variance());
       var coeffs = pd.AllowedInputVariables.Zip(coefficients, (s, d) => new {s, d}).ToDictionary(x => x.s, x => x.d);
-      var res = new PreconstructedLinearModel(means, variances, coeffs, coefficients[nFeatures], pd.TargetVariable);
-
-      res.ResidualVariance = pd.TargetVariableValues.Zip(res.GetEstimatedValues(pd.Dataset, pd.TrainingIndices), (x, y) => x - y).Variance();
-      res.SampleSize = pd.TrainingIndices.Count();
+      var res = new PreconstructedLinearModel(coeffs, coefficients[nFeatures], pd.TargetVariable);
       return res;
     }
 
-    private static PreconstructedLinearModel AlternativeCalculation(IRegressionProblemData pd) {
-      var means = pd.AllowedInputVariables.ToDictionary(n1 => n1, n1 => pd.Dataset.GetDoubleValues(n1).Average());
-      var variances = pd.AllowedInputVariables.ToDictionary(n1 => n1, n1 => pd.Dataset.GetDoubleValues(n1).Variance());
-      var cmean = pd.TargetVariableTrainingValues.Average();
+    private static PreconstructedLinearModel AlternativeCalculation(IRegressionProblemData pd, out double rmse) {
       var variables = pd.AllowedInputVariables.ToList();
       var n = variables.Count;
       var m = pd.TrainingIndices.Count();
 
-      //Set up X^T and y
+      //Set up X^T
       var inTr = new double[n + 1, m];
       for (var i = 0; i < n; i++) {
-        var v = variables[i];
-        var vdata = pd.Dataset.GetDoubleValues(v, pd.TrainingIndices).ToArray();
+        var vdata = pd.Dataset.GetDoubleValues(variables[i], pd.TrainingIndices).ToArray();
         for (var j = 0; j < m; j++) inTr[i, j] = vdata[j];
       }
-
       for (var i = 0; i < m; i++) inTr[n, i] = 1;
 
+      //Set up y
       var y = new double[m, 1];
       var ydata = pd.TargetVariableTrainingValues.ToArray();
@@ -138,23 +104,35 @@
       //Perform linear regression
       var aTy = new double[n + 1, 1];
-      alglib.rmatrixgemm(n + 1, 1, m, 1, inTr, 0, 0, 0, y, 0, 0, 0, 0, ref aTy, 0, 0); //aTy = inTr * y;
       var aTa = new double[n + 1, n + 1];
-      alglib.rmatrixgemm(n + 1, n + 1, m, 1, inTr, 0, 0, 0, inTr, 0, 0, 1, 0, ref aTa, 0, 0); //aTa = inTr * t(inTr) +aTa //
-      alglib.spdmatrixcholesky(ref aTa, n + 1, true);
+      var aTyVector = new double[n + 1];
       int info;
       alglib.densesolverreport report;
       double[] coefficients;
-      var aTyVector = new double[n + 1];
+
+      //Perform linear regression
+      alglib.rmatrixgemm(n + 1, 1, m, 1, inTr, 0, 0, 0, y, 0, 0, 0, 0, ref aTy, 0, 0); //aTy = inTr * y;
+      alglib.rmatrixgemm(n + 1, n + 1, m, 1, inTr, 0, 0, 0, inTr, 0, 0, 1, 0, ref aTa, 0, 0); //aTa = inTr * t(inTr) +aTa //
+      alglib.spdmatrixcholesky(ref aTa, n + 1, true);
       for (var i = 0; i < n + 1; i++) aTyVector[i] = aTy[i, 0];
       alglib.spdmatrixcholeskysolve(aTa, n + 1, true, aTyVector, out info, out report, out coefficients);
-      double rmse, cvrmse;
-      if (info != 1) return ClassicCalculation(pd, out rmse, out cvrmse);
 
-      //extract coefficients
-      var intercept = coefficients[n];
-      var coeffs = new Dictionary<string, double>();
-      for (var i = 0; i < n; i++) coeffs.Add(variables[i], coefficients[i]);
+      //if cholesky calculation fails fall bakc to classic linear regresseion 
+      if (info != 1) {
+        alglib.linearmodel lm;
+        alglib.lrreport ar;
+        int retVal;
+        var inputMatrix = pd.Dataset.ToArray(pd.AllowedInputVariables.Concat(new[] {
+          pd.TargetVariable
+        }), pd.AllIndices);
+        alglib.lrbuild(inputMatrix, inputMatrix.GetLength(0), n, out retVal, out lm, out ar);
+        if (retVal != 1) throw new ArgumentException("Error in calculation of linear regression solution");
+        alglib.lrunpack(lm, out coefficients, out n);
+      }
 
-      return new PreconstructedLinearModel(means, variances, coeffs, intercept, pd.TargetVariable);
+      var coeffs = Enumerable.Range(0, n).ToDictionary(i => variables[i], i => coefficients[i]);
+      var model = new PreconstructedLinearModel(coeffs, coefficients[n], pd.TargetVariable);
+      rmse = pd.TrainingIndices.Select(i => pd.Dataset.GetDoubleValue(pd.TargetVariable, i) - model.GetEstimatedValue(pd.Dataset, i)).Sum(r => r * r) / m;
+      rmse = Math.Sqrt(rmse);
+      return model;
     }
 
@@ -167,19 +145,8 @@
     }
 
-    public IEnumerable<double> GetEstimatedVariances(IDataset dataset, IEnumerable<int> rows) {
-      return rows.Select(i => GetEstimatedVariance(dataset, i));
-    }
-
     #region helpers
     private double GetEstimatedValue(IDataset dataset, int row) {
       return Intercept + (Coefficients.Count == 0 ? 0 : Coefficients.Sum(s => s.Value * dataset.GetDoubleValue(s.Key, row)));
     }
-    private double GetEstimatedVariance(IDataset dataset, int row) {
-      if (SampleSize == 0) return 0.0;
-      var sum = (from var in Variances let d = dataset.GetDoubleValue(var.Key, row) - Means[var.Key] select d * d / var.Value).Sum();
-      var res = ResidualVariance * (SampleSize - 1) / (SampleSize - 2) * (1.0 / SampleSize + sum / (SampleSize - 1));
-      if (double.IsInfinity(res) || double.IsNaN(res)) return 0.0;
-      return Math.Sqrt(res);
-    }
     #endregion
   }
Index: /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/ComponentReductionLinearLeaf.cs
===================================================================
--- /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/ComponentReductionLinearLeaf.cs	(revision 15966)
+++ /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/ComponentReductionLinearLeaf.cs	(revision 15967)
@@ -57,5 +57,5 @@
     #region IModelType
     public override bool ProvidesConfidence {
-      get { return true; }
+      get { return false; }
     }
     public override IRegressionModel Build(IRegressionProblemData pd, IRandom random,
@@ -71,11 +71,10 @@
         foreach (var v in pd2.InputVariables.CheckedItems.ToArray())
           pd2.InputVariables.SetItemCheckedState(v.Value, inputs.Contains(v.Value.Value));
-        double cvRmse;
         double rmse;
-        var model = PreconstructedLinearModel.CreateConfidenceLinearModel(pd2, out rmse, out cvRmse);
-        if (cvRmse > bestCvrmse) continue;
+        var model = PreconstructedLinearModel.CreateLinearModel(pd2, out rmse);
+        if (rmse > bestCvrmse) continue;
         bestModel = new ComponentReducedLinearModel(pd2.TargetVariable, model, pca);
         noParameters = i + 1;
-        bestCvrmse = cvRmse;
+        bestCvrmse = rmse;
       }
       return bestModel;
Index: /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/LeafBase.cs
===================================================================
--- /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/LeafBase.cs	(revision 15966)
+++ /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/LeafBase.cs	(revision 15967)
@@ -26,4 +26,6 @@
 using HeuristicLab.Common;
 using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 using HeuristicLab.Problems.DataAnalysis;
@@ -33,4 +35,20 @@
   public abstract class LeafBase : ParameterizedNamedItem, ILeafModel {
     public const string LeafBuildingStateVariableName = "LeafBuildingState";
+    public const string UseDampeningParameterName = "UseDampening";
+    private const string DampeningParameterName = "DampeningStrenght";
+
+    public IFixedValueParameter<DoubleValue> DampeningParameter {
+      get { return Parameters[DampeningParameterName] as IFixedValueParameter<DoubleValue>; }
+    }
+    public IFixedValueParameter<BoolValue> UseDampeningParameter {
+      get { return (IFixedValueParameter<BoolValue>)Parameters[UseDampeningParameterName]; }
+    }
+
+    public bool UseDampening {
+      get { return UseDampeningParameter.Value.Value; }
+    }
+    public double Dampening {
+      get { return DampeningParameter.Value.Value; }
+    }
 
     #region Constructors & Cloning
@@ -38,5 +56,8 @@
     protected LeafBase(bool deserializing) : base(deserializing) { }
     protected LeafBase(LeafBase original, Cloner cloner) : base(original, cloner) { }
-    public LeafBase() { }
+    protected LeafBase() {
+      Parameters.Add(new FixedValueParameter<BoolValue>(UseDampeningParameterName, "Whether logistic dampening should be used to prevent extreme extrapolation", new BoolValue(false)));
+      Parameters.Add(new FixedValueParameter<DoubleValue>(DampeningParameterName, "Determines the strenght of the logistic dampening. Must be > 0.0. Larger numbers make more conservative predictions.", new DoubleValue(1.5)));
+    }
     #endregion
 
@@ -73,4 +94,8 @@
       int numP;
       var model = Build(pd, parameters.Random, cancellation, out numP);
+      if (UseDampening && Dampening > 0.0) {
+        model = DampenedModel.DampenModel(model, pd, Dampening);
+      }
+
       numParams = numP;
       cancellation.ThrowIfCancellationRequested();
Index: /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/LinearLeaf.cs
===================================================================
--- /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/LinearLeaf.cs	(revision 15966)
+++ /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/LinearLeaf.cs	(revision 15967)
@@ -44,5 +44,5 @@
     #region IModelType
     public override bool ProvidesConfidence {
-      get { return true; }
+      get { return false; }
     }
     public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int noParameters) {
@@ -50,6 +50,6 @@
       double rmse, cvRmse;
       noParameters = pd.AllowedInputVariables.Count() + 1;
-      var res = PreconstructedLinearModel.CreateConfidenceLinearModel(pd, out rmse, out cvRmse);
-      return res;
+      var res = LinearRegression.CreateLinearRegressionSolution(pd, out rmse, out cvRmse);
+      return res.Model;
     }
 
Index: /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/M5Leaf.cs
===================================================================
--- /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/M5Leaf.cs	(revision 15966)
+++ /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/M5Leaf.cs	(revision 15967)
@@ -112,5 +112,5 @@
       pd2.TrainingPartition.Start = pd.TrainingPartition.Start;
 
-      return new PreconstructedLinearModel(means, variances, coeffs, intercept, pd.TargetVariable);
+      return new PreconstructedLinearModel(coeffs, intercept, pd.TargetVariable);
     }
 
@@ -124,5 +124,5 @@
       //
       //  double x1, x2;
-      //  var lm = PreconstructedLinearModel.CreateConfidenceLinearModel(pd2, out x1, out x2);
+      //  var lm = PreconstructedLinearModel.CreateLinearModel(pd2, out x1, out x2);
       //  intercept = lm.Intercept;
       //  return lm.Coefficients;
Index: /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/M5Regression.cs
===================================================================
--- /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/M5Regression.cs	(revision 15966)
+++ /branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/M5Regression.cs	(revision 15967)
@@ -220,8 +220,8 @@
       var pruningRows = (IntArray)stateScope.Variables[PruningSetVariableName].Value;
       if (1 > trainingRows.Length)
-        return new PreconstructedLinearModel(new Dictionary<string, double>(), new Dictionary<string, double>(), new Dictionary<string, double>(), 0, regressionTreeParams.TargetVariable);
+        return new PreconstructedLinearModel(new Dictionary<string, double>(), 0, regressionTreeParams.TargetVariable);
       if (regressionTreeParams.MinLeafSize > trainingRows.Length) {
         var targets = regressionTreeParams.Data.GetDoubleValues(regressionTreeParams.TargetVariable).ToArray();
-        return new PreconstructedLinearModel(new Dictionary<string, double>(), new Dictionary<string, double>(), new Dictionary<string, double>(), targets.Average(), regressionTreeParams.TargetVariable, targets.Variance(), targets.Length);
+        return new PreconstructedLinearModel(new Dictionary<string, double>(), targets.Average(), regressionTreeParams.TargetVariable);
       }
       model.Build(trainingRows.ToArray(), pruningRows.ToArray(), stateScope, results, cancellationToken);
