Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16847 for branches


Ignore:
Timestamp:
04/19/19 13:06:11 (5 years ago)
Author:
gkronber
Message:

#2847: made some minor changes while reviewing

Location:
branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Interfaces/ILeafModel.cs

    r15830 r16847  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Problems.DataAnalysis;
     26using HEAL.Attic;
    2627
    2728namespace HeuristicLab.Algorithms.DataAnalysis {
     29  [StorableType("2A4CB43C-51EB-47AF-AEDD-9B84B27D318B")]
    2830  public interface ILeafModel : IParameterizedNamedItem {
    2931    bool ProvidesConfidence { get; }
    30     // IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int noParameters);
    3132    int MinLeafSize(IRegressionProblemData pd);
    3233
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Interfaces/IM5Model.cs

    r15830 r16847  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2525using HeuristicLab.Optimization;
    2626using HeuristicLab.Problems.DataAnalysis;
     27using HEAL.Attic;
    2728
    2829namespace HeuristicLab.Algorithms.DataAnalysis {
     30  [StorableType("A5399E6A-6A4D-4616-A1CD-CE12FE670F12")]
    2931  public interface IM5Model : IRegressionModel {
    3032    void Build(IReadOnlyList<int> trainingRows, IReadOnlyList<int> pruningRows, IScope stateScope, ResultCollection results, CancellationToken cancellationToken);
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Interfaces/IPruning.cs

    r15830 r16847  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Problems.DataAnalysis;
     25using HEAL.Attic;
    2526
    2627namespace HeuristicLab.Algorithms.DataAnalysis {
     28  [StorableType("5CAADC16-DCF2-4562-A4DF-C3D5BA1E02A5")]
    2729  public interface IPruning : IParameterizedNamedItem {
    2830    int MinLeafSize(IRegressionProblemData pd, ILeafModel leafModel);
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Interfaces/ISplitter.cs

    r15830 r16847  
    2222using System.Threading;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Problems.DataAnalysis;
     24using HEAL.Attic;
    2525
    2626namespace HeuristicLab.Algorithms.DataAnalysis {
     27  [StorableType("A6FB3D68-B298-4C89-9FD9-2D1415D131F5")]
    2728  public interface ISplitter : IParameterizedNamedItem {
    2829    void Initialize(IScope states);
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/ComponentReducedLinearModel.cs

    r15967 r16847  
    2323using System.Linq;
    2424using HeuristicLab.Common;
    25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2625using HeuristicLab.Problems.DataAnalysis;
     26using HEAL.Attic;
    2727
    2828namespace HeuristicLab.Algorithms.DataAnalysis {
    29   [StorableClass]
     29  [StorableType("4E5B8317-648D-4A5A-A3F7-A1A5BEB9AA69")]
    3030  public class ComponentReducedLinearModel : RegressionModel {
    3131    [Storable]
     
    3535
    3636    [StorableConstructor]
    37     private ComponentReducedLinearModel(bool deserializing) : base(deserializing) { }
     37    private ComponentReducedLinearModel(StorableConstructorFlag _) : base(_) { }
    3838    private ComponentReducedLinearModel(ComponentReducedLinearModel original, Cloner cloner) : base(original, cloner) {
    3939      Model = cloner.Clone(original.Model);
    4040      Pca = cloner.Clone(original.Pca);
    4141    }
     42
    4243    public ComponentReducedLinearModel(string targetVariable, IRegressionModel model, PrincipleComponentTransformation pca) : base(targetVariable) {
    4344      Model = model;
    4445      Pca = pca;
    4546    }
     47
    4648    public override IDeepCloneable Clone(Cloner cloner) {
    4749      return new ComponentReducedLinearModel(this, cloner);
     
    5153      get { return Model.VariablesUsedForPrediction; }
    5254    }
     55
    5356    public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
    5457      var data = ReduceDataset(dataset, rows.ToArray());
    5558      return Model.GetEstimatedValues(Pca.TransformDataset(data), Enumerable.Range(0, data.Rows));
    5659    }
     60
    5761    public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
    5862      return new RegressionSolution(this, problemData);
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/DampenedModel.cs

    r15967 r16847  
    2424using System.Linq;
    2525using HeuristicLab.Common;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2726using HeuristicLab.Problems.DataAnalysis;
     27using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Algorithms.DataAnalysis {
    3030  //mulitdimensional extension of http://www2.stat.duke.edu/~tjl13/s101/slides/unit6lec3H.pdf
    31   [StorableClass]
     31  [StorableType("42E9766F-207F-47B1-890C-D5DFCF469838")]
    3232  public class DampenedModel : RegressionModel {
    3333    [Storable]
     
    4141
    4242    [StorableConstructor]
    43     protected DampenedModel(bool deserializing) : base(deserializing) { }
     43    protected DampenedModel(StorableConstructorFlag _) : base(_) { }
    4444    protected DampenedModel(DampenedModel original, Cloner cloner) : base(original, cloner) {
    4545      Model = cloner.Clone(original.Model);
     
    6969      get { return Model.VariablesUsedForPrediction; }
    7070    }
     71
    7172    public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
    7273      var slow = Sigmoid(-Dampening);
     
    7980      }
    8081    }
     82
    8183    public override IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
    8284      return new RegressionSolution(this, problemData);
     
    9395      return ((x - oMin) / d) * nd + nMin;
    9496    }
     97
    9598    private static double Sigmoid(double x) {
    9699      return 1 / (1 + Math.Exp(-x));
     
    98101
    99102
    100     [StorableClass]
     103    [StorableType("CCC93BEC-8796-4D8E-AC58-DD175073A79B")]
    101104    private sealed class ConfidenceDampenedModel : DampenedModel, IConfidenceRegressionModel {
    102105      #region HLConstructors
    103106      [StorableConstructor]
    104       private ConfidenceDampenedModel(bool deserializing) : base(deserializing) { }
     107      private ConfidenceDampenedModel(StorableConstructorFlag _) : base(_) { }
    105108      private ConfidenceDampenedModel(ConfidenceDampenedModel original, Cloner cloner) : base(original, cloner) { }
    106109      public ConfidenceDampenedModel(IConfidenceRegressionModel model, IRegressionProblemData pd, double dampening) : base(model, pd, dampening) { }
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafModels/PreconstructedLinearModel.cs

    r15967 r16847  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Diagnostics;
    2524using System.Linq;
    2625using HeuristicLab.Common;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2826using HeuristicLab.Problems.DataAnalysis;
     27using HEAL.Attic;
    2928
    3029namespace HeuristicLab.Algorithms.DataAnalysis {
    3130  //mulitdimensional extension of http://www2.stat.duke.edu/~tjl13/s101/slides/unit6lec3H.pdf
    32   [StorableClass]
     31  [StorableType("15F2295C-28C1-48C3-8DCB-9470823C6734")]
    3332  internal sealed class PreconstructedLinearModel : RegressionModel {
    3433    [Storable]
     
    4039      get { return Coefficients.Keys; }
    4140    }
     41
    4242    #region HLConstructors
    4343    [StorableConstructor]
    44     private PreconstructedLinearModel(bool deserializing) : base(deserializing) { }
     44    private PreconstructedLinearModel(StorableConstructorFlag _) : base(_) { }
    4545    private PreconstructedLinearModel(PreconstructedLinearModel original, Cloner cloner) : base(original, cloner) {
    4646      if (original.Coefficients != null) Coefficients = original.Coefficients.ToDictionary(x => x.Key, x => x.Value);
     
    4848    }
    4949    public PreconstructedLinearModel(Dictionary<string, double> coefficients, double intercept, string targetvariable) : base(targetvariable) {
    50       Coefficients = coefficients;
     50      Coefficients = new Dictionary<string, double>(coefficients);
    5151      Intercept = intercept;
    5252    }
     
    117117      alglib.spdmatrixcholeskysolve(aTa, n + 1, true, aTyVector, out info, out report, out coefficients);
    118118
    119       //if cholesky calculation fails fall bakc to classic linear regresseion
     119      //if cholesky calculation fails fall back to classic linear regresseion
    120120      if (info != 1) {
    121121        alglib.linearmodel lm;
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/ComplexLeaf.cs

    r15830 r16847  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Parameters;
    28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928using HeuristicLab.Problems.DataAnalysis;
     29using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Algorithms.DataAnalysis {
    32   [StorableClass]
    33   [Item("ComplexLeaf", "A leaf type that uses an arbitriary RegressionAlgorithm to create leaf models")]
     32  [StorableType("F34A0ED9-2CF6-4DEE-850D-08790663B66D")]
     33  [Item("ComplexLeaf", "A leaf type that uses an arbitrary RegressionAlgorithm to create leaf models")]
    3434  public class ComplexLeaf : LeafBase {
    3535    public const string RegressionParameterName = "Regression";
    3636    public IValueParameter<IDataAnalysisAlgorithm<IRegressionProblem>> RegressionParameter {
    37       get { return Parameters[RegressionParameterName] as IValueParameter<IDataAnalysisAlgorithm<IRegressionProblem>>; }
     37      get { return (IValueParameter<IDataAnalysisAlgorithm<IRegressionProblem>>)Parameters[RegressionParameterName]; }
    3838    }
    3939    public IDataAnalysisAlgorithm<IRegressionProblem> Regression {
    4040      get { return RegressionParameter.Value; }
     41      set { RegressionParameter.Value = value; }
    4142    }
    4243
    4344    #region Constructors & Cloning
    4445    [StorableConstructor]
    45     private ComplexLeaf(bool deserializing) : base(deserializing) { }
     46    private ComplexLeaf(StorableConstructorFlag _) : base(_) { }
    4647    private ComplexLeaf(ComplexLeaf original, Cloner cloner) : base(original, cloner) { }
    4748    public ComplexLeaf() {
     
    6162      if (pd.Dataset.Rows < MinLeafSize(pd)) throw new ArgumentException("The number of training instances is too small to create a linear model");
    6263      noParameters = pd.Dataset.Rows + 1;
    63       Regression.Problem = new RegressionProblem {ProblemData = pd};
     64      Regression.Problem = new RegressionProblem { ProblemData = pd };
    6465      var res = RegressionTreeUtilities.RunSubAlgorithm(Regression, random.Next(), cancellationToken);
    6566      var t = res.Select(x => x.Value).OfType<IRegressionSolution>().FirstOrDefault();
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/ComponentReductionLinearLeaf.cs

    r15967 r16847  
    2828using HeuristicLab.Data;
    2929using HeuristicLab.Parameters;
    30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3130using HeuristicLab.Problems.DataAnalysis;
     31using HEAL.Attic;
    3232
    3333namespace HeuristicLab.Algorithms.DataAnalysis {
    34   [StorableClass]
     34  [StorableType("5730B54C-7A8B-4CA7-8F37-7FF3F9848CD2")]
    3535  [Item("ComponentReductionLinearLeaf", "A leaf type that uses principle component analysis to create smaller linear models as leaf models")]
    3636  public class ComponentReductionLinearLeaf : LeafBase {
    37     public const string NoComponentsParameterName = "NoComponents";
    38     public IFixedValueParameter<IntValue> NoComponentsParameter {
    39       get { return Parameters[NoComponentsParameterName] as IFixedValueParameter<IntValue>; }
     37    public const string NumberOfComponentsParameterName = "NoComponents";
     38    public IFixedValueParameter<IntValue> NumberOfCompontentsParameter {
     39      get { return (IFixedValueParameter<IntValue>)Parameters[NumberOfComponentsParameterName]; }
    4040    }
    41     public int NoComponents {
    42       get { return NoComponentsParameter.Value.Value; }
     41    public int NumberOfComponents {
     42      get { return NumberOfCompontentsParameter.Value.Value; }
     43      set { NumberOfCompontentsParameter.Value.Value = value; }
    4344    }
    4445
    4546    #region Constructors & Cloning
    4647    [StorableConstructor]
    47     protected ComponentReductionLinearLeaf(bool deserializing) : base(deserializing) { }
     48    protected ComponentReductionLinearLeaf(StorableConstructorFlag _) : base(_) { }
    4849    protected ComponentReductionLinearLeaf(ComponentReductionLinearLeaf original, Cloner cloner) : base(original, cloner) { }
    4950    public ComponentReductionLinearLeaf() {
    50       Parameters.Add(new FixedValueParameter<IntValue>(NoComponentsParameterName, "The maximum number of principle components used", new IntValue(10)));
     51      Parameters.Add(new FixedValueParameter<IntValue>(NumberOfComponentsParameterName, "The maximum number of principle components used (default=10)", new IntValue(10)));
    5152    }
    5253    public override IDeepCloneable Clone(Cloner cloner) {
     
    5960      get { return false; }
    6061    }
     62
    6163    public override IRegressionModel Build(IRegressionProblemData pd, IRandom random,
    62       CancellationToken cancellationToken, out int noParameters) {
    63       var pca = PrincipleComponentTransformation.CreateProjection(pd.Dataset, pd.TrainingIndices, pd.AllowedInputVariables, true);
     64      CancellationToken cancellationToken, out int numberOfParameters) {
     65      var pca = PrincipleComponentTransformation.CreateProjection(pd.Dataset, pd.TrainingIndices, pd.AllowedInputVariables, normalize: true);
    6466      var pcdata = pca.TransformProblemData(pd);
    6567      ComponentReducedLinearModel bestModel = null;
    6668      var bestCvrmse = double.MaxValue;
    67       noParameters = 1;
    68       for (var i = 1; i <= Math.Min(NoComponents, pd.AllowedInputVariables.Count()); i++) {
     69      numberOfParameters = 1;
     70      for (var i = 1; i <= Math.Min(NumberOfComponents, pd.AllowedInputVariables.Count()); i++) {
    6971        var pd2 = (IRegressionProblemData)pcdata.Clone();
    7072        var inputs = new HashSet<string>(pca.ComponentNames.Take(i));
     
    7577        if (rmse > bestCvrmse) continue;
    7678        bestModel = new ComponentReducedLinearModel(pd2.TargetVariable, model, pca);
    77         noParameters = i + 1;
     79        numberOfParameters = i + 1;
    7880        bestCvrmse = rmse;
    7981      }
     
    8284
    8385    public override int MinLeafSize(IRegressionProblemData pd) {
    84       return NoComponents + 2;
     86      return NumberOfComponents + 2;
    8587    }
    8688    #endregion
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/ConstantLeaf.cs

    r15830 r16847  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827using HeuristicLab.Problems.DataAnalysis;
     28using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Algorithms.DataAnalysis {
    31   [StorableClass]
     31  [StorableType("F3E94907-C5FF-4658-A870-8013C61DD2E1")]
    3232  [Item("ConstantLeaf", "A leaf type that uses constant models as leaf models")]
    3333  public class ConstantLeaf : LeafBase {
    3434    #region Constructors & Cloning
    3535    [StorableConstructor]
    36     protected ConstantLeaf(bool deserializing) : base(deserializing) { }
     36    protected ConstantLeaf(StorableConstructorFlag _) : base(_) { }
    3737    protected ConstantLeaf(ConstantLeaf original, Cloner cloner) : base(original, cloner) { }
    3838    public ConstantLeaf() { }
     
    4646      get { return false; }
    4747    }
    48     public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int noParameters) {
     48    public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int numberOfParameters) {
    4949      if (pd.Dataset.Rows < MinLeafSize(pd)) throw new ArgumentException("The number of training instances is too small to create a linear model");
    50       noParameters = 1;
     50      numberOfParameters = 1;
    5151      return new PreconstructedLinearModel(pd.Dataset.GetDoubleValues(pd.TargetVariable).Average(), pd.TargetVariable);
    5252    }
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/GaussianProcessLeaf.cs

    r15830 r16847  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Parameters;
    29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3029using HeuristicLab.Problems.DataAnalysis;
     30using HEAL.Attic;
    3131
    3232namespace HeuristicLab.Algorithms.DataAnalysis {
    33   [StorableClass]
    34   [Item("GaussianProcessLeaf", "A leaf type that uses gaussian process models as leaf models.")]
     33  [StorableType("852B9F7D-9C2B-4574-BB71-EE70106EA809")]
     34  [Item("GaussianProcessLeaf", "A leaf type that uses Gaussian process models as leaf models.")]
    3535  public class GaussianProcessLeaf : LeafBase {
    3636    #region ParameterNames
     
    4141    #region ParameterProperties
    4242    public IFixedValueParameter<IntValue> TriesParameter {
    43       get { return Parameters[TriesParameterName] as IFixedValueParameter<IntValue>; }
     43      get { return (IFixedValueParameter<IntValue>)Parameters[TriesParameterName]; }
    4444    }
    45     public IFixedValueParameter<GaussianProcessRegression> RegressionParameter {
    46       get { return Parameters[RegressionParameterName] as IFixedValueParameter<GaussianProcessRegression>; }
     45    public IValueParameter<GaussianProcessRegression> RegressionParameter {
     46      get { return (IValueParameter<GaussianProcessRegression>)Parameters[RegressionParameterName]; }
    4747    }
    4848    #endregion
     
    5151    public int Tries {
    5252      get { return TriesParameter.Value.Value; }
     53      set { TriesParameter.Value.Value = value; }
    5354    }
    5455    public GaussianProcessRegression Regression {
    5556      get { return RegressionParameter.Value; }
     57      set { RegressionParameter.Value = value; }
    5658    }
    5759    #endregion
     
    5961    #region Constructors & Cloning
    6062    [StorableConstructor]
    61     protected GaussianProcessLeaf(bool deserializing) : base(deserializing) { }
     63    protected GaussianProcessLeaf(StorableConstructorFlag _) : base(_) { }
    6264    protected GaussianProcessLeaf(GaussianProcessLeaf original, Cloner cloner) : base(original, cloner) { }
    6365    public GaussianProcessLeaf() {
     
    6668      gp.MeanFunctionParameter.Value = new MeanLinear();
    6769
    68       Parameters.Add(new FixedValueParameter<IntValue>(TriesParameterName, "Number of repetitions", new IntValue(10)));
    69       Parameters.Add(new FixedValueParameter<GaussianProcessRegression>(RegressionParameterName, "The algorithm creating GPmodels", gp));
     70      Parameters.Add(new FixedValueParameter<IntValue>(TriesParameterName, "Number of restarts (default = 10)", new IntValue(10)));
     71      Parameters.Add(new ValueParameter<GaussianProcessRegression>(RegressionParameterName, "The algorithm creating Gaussian process models", gp));
    7072    }
    7173    public override IDeepCloneable Clone(Cloner cloner) {
     
    7880      get { return true; }
    7981    }
    80     public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int noParameters) {
    81       if (pd.Dataset.Rows < MinLeafSize(pd)) throw new ArgumentException("The number of training instances is too small to create a gaussian process model");
    82       Regression.Problem = new RegressionProblem {ProblemData = pd};
     82
     83    public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int numberOfParameters) {
     84      if (pd.Dataset.Rows < MinLeafSize(pd)) throw new ArgumentException("The number of training instances is too small to create a Gaussian process model");
     85      Regression.Problem = new RegressionProblem { ProblemData = pd };
    8386      var cvscore = double.MaxValue;
    8487      GaussianProcessRegressionSolution sol = null;
     
    9396      }
    9497      Regression.Runs.Clear();
    95       if (sol == null) throw new ArgumentException("Could not create Gaussian Process model");
     98      if (sol == null) throw new ArgumentException("Could not create Gaussian process model");
    9699
    97       noParameters = pd.Dataset.Rows + 1
    98                      + Regression.CovarianceFunction.GetNumberOfParameters(pd.AllowedInputVariables.Count())
    99                      + Regression.MeanFunction.GetNumberOfParameters(pd.AllowedInputVariables.Count());
     100      numberOfParameters = pd.Dataset.Rows + 1
     101                           + Regression.CovarianceFunction.GetNumberOfParameters(pd.AllowedInputVariables.Count())
     102                           + Regression.MeanFunction.GetNumberOfParameters(pd.AllowedInputVariables.Count());
    100103      return sol.Model;
    101104    }
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/LeafBase.cs

    r15967 r16847  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
     
    2827using HeuristicLab.Data;
    2928using HeuristicLab.Parameters;
    30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3129using HeuristicLab.Problems.DataAnalysis;
     30using HEAL.Attic;
    3231
    3332namespace HeuristicLab.Algorithms.DataAnalysis {
    34   [StorableClass]
     33  [StorableType("F3A9CCD4-975F-4F55-BE24-3A3E932591F6")]
    3534  public abstract class LeafBase : ParameterizedNamedItem, ILeafModel {
    3635    public const string LeafBuildingStateVariableName = "LeafBuildingState";
    3736    public const string UseDampeningParameterName = "UseDampening";
    38     private const string DampeningParameterName = "DampeningStrenght";
     37    public const string DampeningParameterName = "DampeningStrength";
    3938
    4039    public IFixedValueParameter<DoubleValue> DampeningParameter {
    41       get { return Parameters[DampeningParameterName] as IFixedValueParameter<DoubleValue>; }
     40      get { return (IFixedValueParameter<DoubleValue>)Parameters[DampeningParameterName]; }
    4241    }
    4342    public IFixedValueParameter<BoolValue> UseDampeningParameter {
     
    4746    public bool UseDampening {
    4847      get { return UseDampeningParameter.Value.Value; }
     48      set { UseDampeningParameter.Value.Value = value; }
    4949    }
    5050    public double Dampening {
    5151      get { return DampeningParameter.Value.Value; }
     52      set { DampeningParameter.Value.Value = value; }
    5253    }
    5354
    5455    #region Constructors & Cloning
    5556    [StorableConstructor]
    56     protected LeafBase(bool deserializing) : base(deserializing) { }
     57    protected LeafBase(StorableConstructorFlag _) : base(_) { }
    5758    protected LeafBase(LeafBase original, Cloner cloner) : base(original, cloner) { }
    5859    protected LeafBase() {
    59       Parameters.Add(new FixedValueParameter<BoolValue>(UseDampeningParameterName, "Whether logistic dampening should be used to prevent extreme extrapolation", new BoolValue(false)));
    60       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)));
     60      Parameters.Add(new FixedValueParameter<BoolValue>(UseDampeningParameterName, "Whether logistic dampening should be used to prevent extreme extrapolation (default=false)", new BoolValue(false)));
     61      Parameters.Add(new FixedValueParameter<DoubleValue>(DampeningParameterName, "Determines the strength of logistic dampening. Must be > 0.0. Larger numbers lead to more conservative predictions. (default=1.5)", new DoubleValue(1.5)));
    6162    }
    6263    #endregion
     
    6566    public abstract bool ProvidesConfidence { get; }
    6667    public abstract int MinLeafSize(IRegressionProblemData pd);
     68
    6769    public void Initialize(IScope states) {
    6870      states.Variables.Add(new Variable(LeafBuildingStateVariableName, new LeafBuildingState()));
    6971    }
     72
    7073    public void Build(RegressionNodeTreeModel tree, IReadOnlyList<int> trainingRows, IScope stateScope, CancellationToken cancellationToken) {
    7174      var parameters = (RegressionTreeParameters)stateScope.Variables[M5Regression.RegressionTreeParameterVariableName].Value;
     
    8689    }
    8790
    88     public IRegressionModel BuildModel(IReadOnlyList<int> rows, RegressionTreeParameters parameters, CancellationToken cancellation, out int numParams) {
     91    public IRegressionModel BuildModel(IReadOnlyList<int> rows, RegressionTreeParameters parameters, CancellationToken cancellation, out int numberOfParameters) {
    8992      var reducedData = RegressionTreeUtilities.ReduceDataset(parameters.Data, rows, parameters.AllowedInputVariables.ToArray(), parameters.TargetVariable);
    9093      var pd = new RegressionProblemData(reducedData, parameters.AllowedInputVariables.ToArray(), parameters.TargetVariable);
     
    98101      }
    99102
    100       numParams = numP;
     103      numberOfParameters = numP;
    101104      cancellation.ThrowIfCancellationRequested();
    102105      return model;
    103106    }
    104107
    105     public abstract IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int noParameters);
     108    public abstract IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int numberOfParameters);
    106109    #endregion
    107110
    108     [StorableClass]
     111    [StorableType("495243C0-6C15-4328-B30D-FFBFA0F54DCB")]
    109112    public class LeafBuildingState : Item {
    110113      [Storable]
     
    115118      //State.Code values denote the current action (for pausing)
    116119      //0...nothing has been done;
    117       //1...building Models;
     120      //1...building models;
    118121      [Storable]
    119122      public int Code = 0;
     
    121124      #region HLConstructors & Cloning
    122125      [StorableConstructor]
    123       protected LeafBuildingState(bool deserializing) : base(deserializing) { }
     126      protected LeafBuildingState(StorableConstructorFlag _) : base(_) { }
    124127      protected LeafBuildingState(LeafBuildingState original, Cloner cloner) : base(original, cloner) {
    125128        nodeQueue = new Queue<RegressionNodeModel>(original.nodeQueue.Select(cloner.Clone));
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/LinearLeaf.cs

    r15967 r16847  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827using HeuristicLab.Problems.DataAnalysis;
     28using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Algorithms.DataAnalysis {
    31   [StorableClass]
     31  [StorableType("347CA25D-FB37-4C4F-9B61-9D79288B2B28")]
    3232  [Item("LinearLeaf", "A leaf type that uses linear models as leaf models. This is the standard for M5' regression")]
    3333  public class LinearLeaf : LeafBase {
    3434    #region Constructors & Cloning
    3535    [StorableConstructor]
    36     protected LinearLeaf(bool deserializing) : base(deserializing) { }
     36    protected LinearLeaf(StorableConstructorFlag _) : base(_) { }
    3737    protected LinearLeaf(LinearLeaf original, Cloner cloner) : base(original, cloner) { }
    3838    public LinearLeaf() { }
     
    4646      get { return false; }
    4747    }
    48     public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int noParameters) {
     48    public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int numberOfParameters) {
    4949      if (pd.Dataset.Rows < MinLeafSize(pd)) throw new ArgumentException("The number of training instances is too small to create a linear model");
    5050      double rmse, cvRmse;
    51       noParameters = pd.AllowedInputVariables.Count() + 1;
    52       var res = LinearRegression.CreateLinearRegressionSolution(pd, out rmse, out cvRmse);
     51      numberOfParameters = pd.AllowedInputVariables.Count() + 1;
     52      var res = LinearRegression.CreateSolution(pd, out rmse, out cvRmse);
    5353      return res.Model;
    5454    }
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/M5Leaf.cs

    r15967 r16847  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
    28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928using HeuristicLab.Problems.DataAnalysis;
     29using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Algorithms.DataAnalysis {
    32   [StorableClass]
    33   [Item("M5Leaf", "A leaf type that uses linear models as leaf models. This is the standard for M5' regression")]
     32  [StorableType("58517042-5318-4087-B098-AC75F0208BA0")]
     33  [Item("M5Leaf", "A leaf type that uses regularized linear models with feature selection as leaf models.")]
    3434  public class M5Leaf : LeafBase {
    3535    #region Constructors & Cloning
    3636    [StorableConstructor]
    37     private M5Leaf(bool deserializing) : base(deserializing) { }
     37    private M5Leaf(StorableConstructorFlag _) : base(_) { }
    3838    private M5Leaf(M5Leaf original, Cloner cloner) : base(original, cloner) { }
    3939    public M5Leaf() { }
     
    4747      get { return false; }
    4848    }
    49     public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int noParameters) {
     49    public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int numberOfParameters) {
    5050      if (pd.Dataset.Rows == 0) throw new ArgumentException("The number of training instances is too small to create an M5 leaf model");
    5151
    5252      if (pd.Dataset.Rows == 1)
    53         return new ConstantLeaf().Build(pd, random, cancellationToken, out noParameters);
     53        return new ConstantLeaf().Build(pd, random, cancellationToken, out numberOfParameters);
    5454
    5555      var means = pd.AllowedInputVariables.ToDictionary(n => n, n => pd.Dataset.GetDoubleValues(n, pd.TrainingIndices).Average());
     
    5757      var used = pd.AllowedInputVariables.Where(v => !variances[v].IsAlmost(0.0)).ToList();
    5858
    59       var classMean = pd.TargetVariableTrainingValues.Average();
    60       var classVar = pd.TargetVariableTrainingValues.Variance();
     59      var targetMean = pd.TargetVariableTrainingValues.Average();
     60      var targetVariance = pd.TargetVariableTrainingValues.Variance();
    6161
    62       var model = FindBestModel(variances, means, classMean, classVar, pd, used);
    63       noParameters = 1 + model.Coefficients.Count;
     62      var model = FindBestModel(variances, means, targetMean, targetVariance, pd, used);
     63      numberOfParameters = 1 + model.Coefficients.Count;
    6464      return model;
    6565    }
     
    6969    #endregion
    7070
    71     private static PreconstructedLinearModel FindBestModel(Dictionary<string, double> variances, Dictionary<string, double> means, double cMean, double cVar, IRegressionProblemData pd, IList<string> variables) {
     71    private static PreconstructedLinearModel FindBestModel(Dictionary<string, double> variances, Dictionary<string, double> means, double yMean, double yVariance, IRegressionProblemData pd, IList<string> variables) {
    7272      Dictionary<string, double> coeffs;
    7373      double intercept;
    7474      do {
    75         coeffs = DoRegression(pd, variables, variances, means, cMean, 1.0e-8, out intercept);
    76         variables = DeselectColinear(variances, coeffs, cVar, pd, variables);
     75        coeffs = DoRegression(pd, variables, variances, means, yMean, 1.0e-8, out intercept);
     76        variables = DeselectColinear(variances, coeffs, yVariance, pd, variables);
    7777      }
    7878      while (coeffs.Count != variables.Count);
     
    8888        improved = false;
    8989        currentNumAttributes--;
    90         // Find attribute with smallest SC
    91         var candidate = variables.ToDictionary(v => v, v => Math.Abs(coeffs[v] * Math.Sqrt(variances[v] / cVar)))
     90        // Find attribute with smallest SC (variance-scaled coefficient)
     91        var candidate = variables.ToDictionary(v => v, v => Math.Abs(coeffs[v] * Math.Sqrt(variances[v] / yVariance)))
    9292          .OrderBy(x => x.Value).Select(x => x.Key).First();
    9393
    9494        var currVariables = variables.Where(v => !v.Equals(candidate)).ToList();
    9595        var currentIntercept = 0.0;
    96         var currentCoeffs = DoRegression(pd, currVariables, variances, means, cMean, 1.0e-8, out currentIntercept);
     96        var currentCoeffs = DoRegression(pd, currVariables, variances, means, yMean, 1.0e-8, out currentIntercept);
    9797        var currentMse = CalculateSE(currentCoeffs, currentIntercept, pd, currVariables);
    9898        var currentAkaike = currentMse / fullMse * (numInst - numAtts) + 2 * currentNumAttributes;
     
    115115    }
    116116
    117     private static Dictionary<string, double> DoRegression(IRegressionProblemData pd, IList<string> variables, Dictionary<string, double> variances, Dictionary<string, double> means, double cmean, double ridge, out double intercept) {
    118       //if (pd.TrainingIndices.Count() > variables.Count) {
    119       //  var pd2 = new RegressionProblemData(pd.Dataset, variables, pd.TargetVariable);
    120       //  pd2.TestPartition.End = pd.TestPartition.End;
    121       //  pd2.TestPartition.Start = pd.TestPartition.Start;
    122       //  pd2.TrainingPartition.End = pd.TrainingPartition.End;
    123       //  pd2.TrainingPartition.Start = pd.TrainingPartition.Start;
    124       //
    125       //  double x1, x2;
    126       //  var lm = PreconstructedLinearModel.CreateLinearModel(pd2, out x1, out x2);
    127       //  intercept = lm.Intercept;
    128       //  return lm.Coefficients;
     117    private static Dictionary<string, double> DoRegression(IRegressionProblemData pd, IList<string> variables, Dictionary<string, double> variances, Dictionary<string, double> means, double yMean, double ridge, out double intercept) {
    129118
    130119      var n = variables.Count;
     
    182171      if (coefficients == null) throw new ArgumentException("No linear model could be built");
    183172
    184       intercept = cmean;
     173      intercept = yMean;
    185174      var res = new Dictionary<string, double>();
    186175      for (var i = 0; i < n; i++) {
     
    193182    }
    194183
    195     private static IList<string> DeselectColinear(Dictionary<string, double> variances, Dictionary<string, double> coeffs, double cVar, IRegressionProblemData pd, IList<string> variables) {
    196       var candidates = variables.ToDictionary(v => v, v => Math.Abs(coeffs[v] * Math.Sqrt(variances[v] / cVar))).Where(x => x.Value > 1.5).OrderBy(x => -x.Value).ToList();
     184    private static IList<string> DeselectColinear(Dictionary<string, double> variances, Dictionary<string, double> coeffs, double yVariance, IRegressionProblemData pd, IList<string> variables) {
     185      var candidates = variables.ToDictionary(v => v, v => Math.Abs(coeffs[v] * Math.Sqrt(variances[v] / yVariance))).Where(x => x.Value > 1.5).OrderBy(x => -x.Value).ToList();
    197186      if (candidates.Count == 0) return variables;
    198187      var c = candidates.First().Key;
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/M5regLeaf.cs

    r15830 r16847  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
    28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928using HeuristicLab.Problems.DataAnalysis;
     29using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Algorithms.DataAnalysis {
    32   [StorableClass]
    33   [Item("M5regLeaf", "A leaf type that uses linear models as leaf models. This is the standard for M5' regression")]
     32  [StorableType("0AED959D-78C3-4927-BDCF-473D0AEE32AA")]
     33  [Item("M5regLeaf", "A leaf type that uses regularized linear models as leaf models.")]
    3434  public class M5regLeaf : LeafBase {
    3535    #region Constructors & Cloning
    3636    [StorableConstructor]
    37     private M5regLeaf(bool deserializing) : base(deserializing) { }
     37    private M5regLeaf(StorableConstructorFlag _) : base(_) { }
    3838    private M5regLeaf(M5regLeaf original, Cloner cloner) : base(original, cloner) { }
    3939    public M5regLeaf() { }
     
    4747      get { return true; }
    4848    }
    49     public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int noParameters) {
     49
     50    public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int numberOfParameters) {
    5051      if (pd.Dataset.Rows < MinLeafSize(pd)) throw new ArgumentException("The number of training instances is too small to create a linear model");
    51       noParameters = pd.AllowedInputVariables.Count() + 1;
     52      numberOfParameters = pd.AllowedInputVariables.Count() + 1;
    5253
    5354      double x1, x2;
    5455      var coeffs = ElasticNetLinearRegression.CalculateModelCoefficients(pd, 1, 0.2, out x1, out x2);
    55       noParameters = coeffs.Length;
     56      numberOfParameters = coeffs.Length;
    5657      return ElasticNetLinearRegression.CreateSymbolicSolution(coeffs, pd).Model;
    5758    }
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/M5Regression.cs

    r15967 r16847  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22 using System;
    223using System.Collections.Generic;
    324using System.Linq;
     
    930using HeuristicLab.Optimization;
    1031using HeuristicLab.Parameters;
    11 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    1232using HeuristicLab.PluginInfrastructure;
    1333using HeuristicLab.Problems.DataAnalysis;
    1434using HeuristicLab.Random;
     35using HEAL.Attic;
    1536
    1637namespace HeuristicLab.Algorithms.DataAnalysis {
    17   [StorableClass]
     38  [StorableType("FC8D8E5A-D16D-41BB-91CF-B2B35D17ADD7")]
    1839  [Creatable(CreatableAttribute.Categories.DataAnalysisRegression, Priority = 95)]
    1940  [Item("M5RegressionTree", "A M5 regression tree / rule set")]
     
    2849    public const string TrainingSetVariableName = "TrainingSet";
    2950
    30     #region Parametername
     51    #region Parameter names
    3152    private const string GenerateRulesParameterName = "GenerateRules";
    3253    private const string HoldoutSizeParameterName = "HoldoutSize";
    33     private const string SpliterParameterName = "Splitter";
     54    private const string SplitterParameterName = "Splitter";
    3455    private const string MinimalNodeSizeParameterName = "MinimalNodeSize";
    3556    private const string LeafModelParameterName = "LeafModel";
     
    4768      get { return (IFixedValueParameter<PercentValue>)Parameters[HoldoutSizeParameterName]; }
    4869    }
    49     public IConstrainedValueParameter<ISplitter> ImpurityParameter {
    50       get { return (IConstrainedValueParameter<ISplitter>)Parameters[SpliterParameterName]; }
     70    public IConstrainedValueParameter<ISplitter> SplitterParameter {
     71      get { return (IConstrainedValueParameter<ISplitter>)Parameters[SplitterParameterName]; }
    5172    }
    5273    public IFixedValueParameter<IntValue> MinimalNodeSizeParameter {
     
    7394    public bool GenerateRules {
    7495      get { return GenerateRulesParameter.Value.Value; }
     96      set { GenerateRulesParameter.Value.Value = value; }
    7597    }
    7698    public double HoldoutSize {
    7799      get { return HoldoutSizeParameter.Value.Value; }
     100      set { HoldoutSizeParameter.Value.Value = value; }
    78101    }
    79102    public ISplitter Splitter {
    80       get { return ImpurityParameter.Value; }
     103      get { return SplitterParameter.Value; }
     104      // no setter because this is a constrained parameter
    81105    }
    82106    public int MinimalNodeSize {
    83107      get { return MinimalNodeSizeParameter.Value.Value; }
     108      set { MinimalNodeSizeParameter.Value.Value = value; }
    84109    }
    85110    public ILeafModel LeafModel {
     
    91116    public int Seed {
    92117      get { return SeedParameter.Value.Value; }
     118      set { SeedParameter.Value.Value = value; }
    93119    }
    94120    public bool SetSeedRandomly {
    95121      get { return SetSeedRandomlyParameter.Value.Value; }
     122      set { SetSeedRandomlyParameter.Value.Value = value; }
    96123    }
    97124    public bool UseHoldout {
    98125      get { return UseHoldoutParameter.Value.Value; }
     126      set { UseHoldoutParameter.Value.Value = value; }
    99127    }
    100128    #endregion
     
    107135    #region Constructors and Cloning
    108136    [StorableConstructor]
    109     private M5Regression(bool deserializing) : base(deserializing) { }
     137    private M5Regression(StorableConstructorFlag _) : base(_) { }
    110138    private M5Regression(M5Regression original, Cloner cloner) : base(original, cloner) {
    111139      stateScope = cloner.Clone(stateScope);
     
    114142      var modelSet = new ItemSet<ILeafModel>(ApplicationManager.Manager.GetInstances<ILeafModel>());
    115143      var pruningSet = new ItemSet<IPruning>(ApplicationManager.Manager.GetInstances<IPruning>());
    116       var impuritySet = new ItemSet<ISplitter>(ApplicationManager.Manager.GetInstances<ISplitter>());
    117       Parameters.Add(new FixedValueParameter<BoolValue>(GenerateRulesParameterName, "Whether a set of rules or a decision tree shall be created", new BoolValue(false)));
    118       Parameters.Add(new FixedValueParameter<PercentValue>(HoldoutSizeParameterName, "How much of the training set shall be reserved for pruning", new PercentValue(0.2)));
    119       Parameters.Add(new ConstrainedValueParameter<ISplitter>(SpliterParameterName, "The type of split function used to create node splits", impuritySet, impuritySet.OfType<M5Splitter>().First()));
    120       Parameters.Add(new FixedValueParameter<IntValue>(MinimalNodeSizeParameterName, "The minimal number of samples in a leaf node", new IntValue(1)));
    121       Parameters.Add(new ConstrainedValueParameter<ILeafModel>(LeafModelParameterName, "The type of model used for the nodes", modelSet, modelSet.OfType<LinearLeaf>().First()));
    122       Parameters.Add(new ConstrainedValueParameter<IPruning>(PruningTypeParameterName, "The type of pruning used", pruningSet, pruningSet.OfType<ComplexityPruning>().First()));
     144      var splitterSet = new ItemSet<ISplitter>(ApplicationManager.Manager.GetInstances<ISplitter>());
     145      Parameters.Add(new FixedValueParameter<BoolValue>(GenerateRulesParameterName, "Whether a set of rules or a decision tree shall be created (default=false)", new BoolValue(false)));
     146      Parameters.Add(new FixedValueParameter<PercentValue>(HoldoutSizeParameterName, "How much of the training set shall be reserved for pruning (default=20%).", new PercentValue(0.2)));
     147      Parameters.Add(new ConstrainedValueParameter<ISplitter>(SplitterParameterName, "The type of split function used to create node splits (default='M5Splitter').", splitterSet, splitterSet.OfType<M5Splitter>().First()));
     148      Parameters.Add(new FixedValueParameter<IntValue>(MinimalNodeSizeParameterName, "The minimal number of samples in a leaf node (default=1).", new IntValue(1)));
     149      Parameters.Add(new ConstrainedValueParameter<ILeafModel>(LeafModelParameterName, "The type of model used for the nodes (default='LinearLeaf').", modelSet, modelSet.OfType<LinearLeaf>().First()));
     150      Parameters.Add(new ConstrainedValueParameter<IPruning>(PruningTypeParameterName, "The type of pruning used (default='ComplexityPruning').", pruningSet, pruningSet.OfType<ComplexityPruning>().First()));
    123151      Parameters.Add(new FixedValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
    124152      Parameters.Add(new FixedValueParameter<BoolValue>(SetSeedRandomlyParameterName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
    125       Parameters.Add(new FixedValueParameter<BoolValue>(UseHoldoutParameterName, "True if a holdout set should be generated, false if splitting and pruning shall be performed on the same data ", new BoolValue(false)));
     153      Parameters.Add(new FixedValueParameter<BoolValue>(UseHoldoutParameterName, "True if a holdout set should be generated, false if splitting and pruning shall be performed on the same data (default=false).", new BoolValue(false)));
    126154      Problem = new RegressionProblem();
    127155    }
     
    134162      base.Initialize(cancellationToken);
    135163      var random = new MersenneTwister();
    136       if (SetSeedRandomly) SeedParameter.Value.Value = new System.Random().Next();
     164      if (SetSeedRandomly) Seed = RandomSeedGenerator.GetSeed();
    137165      random.Reset(Seed);
    138166      stateScope = InitializeScope(random, Problem.ProblemData, Pruning, MinimalNodeSize, LeafModel, Splitter, GenerateRules, UseHoldout, HoldoutSize);
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/M5Utilities/PrincipleComponentTransformation.cs

    r15470 r16847  
    2424using System.Linq;
    2525using HeuristicLab.Common;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2726using HeuristicLab.Problems.DataAnalysis;
     27using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Algorithms.DataAnalysis {
    30   [StorableClass]
     30  [StorableType("A2DDC528-BAA7-445F-98E1-5F895CE2FD5C")]
    3131  public class PrincipleComponentTransformation : IDeepCloneable {
    3232    #region Properties
     
    4848    #region HLConstructors
    4949    [StorableConstructor]
    50     protected PrincipleComponentTransformation(bool deserializing) { }
     50    protected PrincipleComponentTransformation(StorableConstructorFlag _) { }
    5151    protected PrincipleComponentTransformation(PrincipleComponentTransformation original, Cloner cloner) {
    5252      if (original.Variances != null) Variances = original.Variances.ToArray();
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/M5Utilities/RegressionTreeAnalyzer.cs

    r15830 r16847  
    2828using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2929using HeuristicLab.Optimization;
    30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3130using HeuristicLab.Problems.DataAnalysis;
     31using HEAL.Attic;
    3232
    3333namespace HeuristicLab.Algorithms.DataAnalysis {
     
    243243
    244244
    245     [StorableClass]
     245    [StorableType("D5540C63-310B-4D6F-8A3D-6C1A08DE7F80")]
    246246    private class TextSymbol : Symbol {
    247247      [StorableConstructor]
    248       private TextSymbol(bool deserializing) : base(deserializing) { }
     248      private TextSymbol(StorableConstructorFlag _) : base(_) { }
    249249      private TextSymbol(Symbol original, Cloner cloner) : base(original, cloner) { }
    250250      public TextSymbol(string name) : base(name, "") {
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/M5Utilities/RegressionTreeParameters.cs

    r15830 r16847  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
    26 using HeuristicLab.Optimization;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2826using HeuristicLab.Problems.DataAnalysis;
     27using HEAL.Attic;
    2928
    3029namespace HeuristicLab.Algorithms.DataAnalysis {
     30  [StorableType("A6293516-C146-469D-B248-31B866A1D94F")]
    3131  public class RegressionTreeParameters : Item {
    3232    private readonly ISplitter splitter;
     
    6666    #region Constructors & Cloning
    6767    [StorableConstructor]
    68     private RegressionTreeParameters(bool deserializing) : base(deserializing) { }
     68    private RegressionTreeParameters(StorableConstructorFlag _) : base(_) { }
    6969    private RegressionTreeParameters(RegressionTreeParameters original, Cloner cloner) : base(original, cloner) {
    7070      problemData = cloner.Clone(original.problemData);
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/MetaModels/RegressionNodeModel.cs

    r16069 r16847  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using HeuristicLab.Common;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Common;                                                 
    2726using HeuristicLab.Problems.DataAnalysis;
     27using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Algorithms.DataAnalysis {
    30   [StorableClass]
     30  [StorableType("C20C7DF1-CE33-4CCD-88D3-E145CFE239AC")]
    3131  public class RegressionNodeModel : RegressionModel {
    3232    #region Properties
     
    6565    #region HLConstructors
    6666    [StorableConstructor]
    67     protected RegressionNodeModel(bool deserializing) : base(deserializing) { }
     67    protected RegressionNodeModel(StorableConstructorFlag _) : base(_) { }
    6868    protected RegressionNodeModel(RegressionNodeModel original, Cloner cloner) : base(original, cloner) {
    6969      IsLeaf = original.IsLeaf;
     
    147147    #endregion
    148148
    149     [StorableClass]
     149    [StorableType("1FF9E216-6AF1-4282-A7EF-3FA0C1DB29C8")]
    150150    private sealed class ConfidenceRegressionNodeModel : RegressionNodeModel, IConfidenceRegressionModel {
    151151      #region HLConstructors
    152152      [StorableConstructor]
    153       private ConfidenceRegressionNodeModel(bool deserializing) : base(deserializing) { }
     153      private ConfidenceRegressionNodeModel(StorableConstructorFlag _) : base(_) { }
    154154      private ConfidenceRegressionNodeModel(ConfidenceRegressionNodeModel original, Cloner cloner) : base(original, cloner) { }
    155155      public ConfidenceRegressionNodeModel(string targetAttr) : base(targetAttr) { }
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/MetaModels/RegressionNodeTreeModel.cs

    r16069 r16847  
    2727using HeuristicLab.Core;
    2828using HeuristicLab.Optimization;
    29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3029using HeuristicLab.Problems.DataAnalysis;
     30using HEAL.Attic;
    3131
    3232namespace HeuristicLab.Algorithms.DataAnalysis {
    33   [StorableClass]
     33  [StorableType("FAF1F955-82F3-4824-9759-9D2846E831AE")]
    3434  public class RegressionNodeTreeModel : RegressionModel, IM5Model {
    3535    public const string NumCurrentLeafsResultName = "Number of current leafs";
     
    4242    #region HLConstructors & Cloning
    4343    [StorableConstructor]
    44     protected RegressionNodeTreeModel(bool deserializing) : base(deserializing) { }
     44    protected RegressionNodeTreeModel(StorableConstructorFlag _) : base(_) { }
    4545    protected RegressionNodeTreeModel(RegressionNodeTreeModel original, Cloner cloner) : base(original, cloner) {
    4646      Root = cloner.Clone(original.Root);
     
    9797    #endregion
    9898
    99     public void BuildModelless(IReadOnlyList<int> trainingRows, IReadOnlyList<int> pruningRows, IScope statescope, ResultCollection results, CancellationToken cancellationToken) {
     99    public void BuildModel(IReadOnlyList<int> trainingRows, IReadOnlyList<int> pruningRows, IScope statescope, ResultCollection results, CancellationToken cancellationToken) {
    100100      var regressionTreeParams = (RegressionTreeParameters)statescope.Variables[M5Regression.RegressionTreeParameterVariableName].Value;
    101101      //start with one node
     
    109109    }
    110110
    111     [StorableClass]
     111    [StorableType("E84ACC40-5694-4E40-A947-190673643206")]
    112112    private sealed class ConfidenceRegressionNodeTreeModel : RegressionNodeTreeModel, IConfidenceRegressionModel {
    113113      #region HLConstructors & Cloning
    114114      [StorableConstructor]
    115       private ConfidenceRegressionNodeTreeModel(bool deserializing) : base(deserializing) { }
     115      private ConfidenceRegressionNodeTreeModel(StorableConstructorFlag _) : base(_) { }
    116116      private ConfidenceRegressionNodeTreeModel(ConfidenceRegressionNodeTreeModel original, Cloner cloner) : base(original, cloner) { }
    117117      public ConfidenceRegressionNodeTreeModel(string targetVariable) : base(targetVariable) { }
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/MetaModels/RegressionRuleModel.cs

    r15830 r16847  
    2828using HeuristicLab.Core;
    2929using HeuristicLab.Optimization;
    30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3130using HeuristicLab.Problems.DataAnalysis;
     31using HEAL.Attic;
    3232
    3333namespace HeuristicLab.Algorithms.DataAnalysis {
    34   [StorableClass]
     34  [StorableType("425AF262-A756-4E9A-B76F-4D2480BEA4FD")]
    3535  public class RegressionRuleModel : RegressionModel, IM5Model {
    3636    #region Properties
     
    4949    #region HLConstructors
    5050    [StorableConstructor]
    51     protected RegressionRuleModel(bool deserializing) : base(deserializing) { }
     51    protected RegressionRuleModel(StorableConstructorFlag _) : base(_) { }
    5252    protected RegressionRuleModel(RegressionRuleModel original, Cloner cloner) : base(original, cloner) {
    5353      if (original.SplitAttributes != null) SplitAttributes = original.SplitAttributes.ToArray();
     
    8888      //build tree and select node with maximum coverage
    8989      var tree = RegressionNodeTreeModel.CreateTreeModel(regressionTreeParams.TargetVariable, regressionTreeParams);
    90       tree.BuildModelless(trainingRows, pruningRows, statescope, results, cancellationToken);
     90      tree.BuildModel(trainingRows, pruningRows, statescope, results, cancellationToken);
    9191      var nodeModel = tree.Root.EnumerateNodes().Where(x => x.IsLeaf).MaxItems(x => x.NumSamples).First();
    9292
     
    9595      var reops = new List<Comparison>();
    9696
    97       //extract Splits
     97      //extract splits
    9898      for (var temp = nodeModel; temp.Parent != null; temp = temp.Parent) {
    9999        satts.Add(temp.Parent.SplitAttribute);
     
    137137    }
    138138
    139     [StorableClass]
     139    [StorableType("7302AA30-9F58-42F3-BF6A-ECF1536508AB")]
    140140    private sealed class ConfidenceRegressionRuleModel : RegressionRuleModel, IConfidenceRegressionModel {
    141141      #region HLConstructors
    142142      [StorableConstructor]
    143       private ConfidenceRegressionRuleModel(bool deserializing) : base(deserializing) { }
     143      private ConfidenceRegressionRuleModel(StorableConstructorFlag _) : base(_) { }
    144144      private ConfidenceRegressionRuleModel(ConfidenceRegressionRuleModel original, Cloner cloner) : base(original, cloner) { }
    145145      public ConfidenceRegressionRuleModel(string targetAttr) : base(targetAttr) { }
     
    159159  }
    160160
     161  [StorableType("152DECE4-2692-4D53-B290-974806ADCD72")]
    161162  internal enum Comparison {
    162163    LessEqual,
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/MetaModels/RegressionRuleSetModel.cs

    r15830 r16847  
    2828using HeuristicLab.Data;
    2929using HeuristicLab.Optimization;
    30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3130using HeuristicLab.Problems.DataAnalysis;
     31using HEAL.Attic;
    3232
    3333namespace HeuristicLab.Algorithms.DataAnalysis {
    34   [StorableClass]
     34  [StorableType("7B4D9AE9-0456-4029-80A6-CCB5E33CE356")]
    3535  public class RegressionRuleSetModel : RegressionModel, IM5Model {
    3636    private const string NumRulesResultName = "Number of rules";
     
    4545    #region HLConstructors & Cloning
    4646    [StorableConstructor]
    47     protected RegressionRuleSetModel(bool deserializing) : base(deserializing) { }
     47    protected RegressionRuleSetModel(StorableConstructorFlag _) : base(_) { }
    4848    protected RegressionRuleSetModel(RegressionRuleSetModel original, Cloner cloner) : base(original, cloner) {
    4949      if (original.Rules != null) Rules = original.Rules.Select(cloner.Clone).ToList();
     
    123123    #endregion
    124124
    125     [StorableClass]
     125    [StorableType("E114F3C9-3C1F-443D-8270-0E10CE12F2A0")]
    126126    public class RuleSetState : Item {
    127127      [Storable]
     
    140140      #region HLConstructors & Cloning
    141141      [StorableConstructor]
    142       protected RuleSetState(bool deserializing) : base(deserializing) { }
     142      protected RuleSetState(StorableConstructorFlag _) : base(_) { }
    143143      protected RuleSetState(RuleSetState original, Cloner cloner) : base(original, cloner) {
    144144        Rules = original.Rules.Select(cloner.Clone).ToList();
     
    155155    }
    156156
    157     [StorableClass]
     157    [StorableType("52E7992B-94CC-4960-AA82-1A399BE735C6")]
    158158    private sealed class ConfidenceRegressionRuleSetModel : RegressionRuleSetModel, IConfidenceRegressionModel {
    159159      #region HLConstructors & Cloning
    160160      [StorableConstructor]
    161       private ConfidenceRegressionRuleSetModel(bool deserializing) : base(deserializing) { }
     161      private ConfidenceRegressionRuleSetModel(StorableConstructorFlag _) : base(_) { }
    162162      private ConfidenceRegressionRuleSetModel(ConfidenceRegressionRuleSetModel original, Cloner cloner) : base(original, cloner) { }
    163163      public ConfidenceRegressionRuleSetModel(string targetVariable) : base(targetVariable) { }
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Pruning/ComplexityPruning.cs

    r15830 r16847  
    2828using HeuristicLab.Data;
    2929using HeuristicLab.Parameters;
    30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3130using HeuristicLab.Problems.DataAnalysis;
     31using HEAL.Attic;
    3232
    3333namespace HeuristicLab.Algorithms.DataAnalysis {
     34  [StorableType("B643D965-D13F-415D-8589-3F3527460347")]
    3435  public class ComplexityPruning : ParameterizedNamedItem, IPruning {
    3536    public const string PruningStateVariableName = "PruningState";
    3637
    37     private const string PruningStrengthParameterName = "PruningStrength";
    38     private const string PruningDecayParameterName = "PruningDecay";
    39     private const string FastPruningParameterName = "FastPruning";
     38    public const string PruningStrengthParameterName = "PruningStrength";
     39    public const string PruningDecayParameterName = "PruningDecay";
     40    public const string FastPruningParameterName = "FastPruning";
    4041
    4142    public IFixedValueParameter<DoubleValue> PruningStrengthParameter {
     
    5152    public double PruningStrength {
    5253      get { return PruningStrengthParameter.Value.Value; }
     54      set { PruningStrengthParameter.Value.Value = value; }
    5355    }
    5456    public double PruningDecay {
    5557      get { return PruningDecayParameter.Value.Value; }
     58      set { PruningDecayParameter.Value.Value = value; }
    5659    }
    5760    public bool FastPruning {
    5861      get { return FastPruningParameter.Value.Value; }
     62      set { FastPruningParameter.Value.Value = value; }
    5963    }
    6064
    6165    #region Constructors & Cloning
    6266    [StorableConstructor]
    63     protected ComplexityPruning(bool deserializing) : base(deserializing) { }
     67    protected ComplexityPruning(StorableConstructorFlag _) : base(_) { }
    6468    protected ComplexityPruning(ComplexityPruning original, Cloner cloner) : base(original, cloner) { }
    6569    public ComplexityPruning() {
    66       Parameters.Add(new FixedValueParameter<DoubleValue>(PruningStrengthParameterName, "The strength of the pruning. Higher values force the algorithm to create simpler models", new DoubleValue(2.0)));
    67       Parameters.Add(new FixedValueParameter<DoubleValue>(PruningDecayParameterName, "Pruning decay allows nodes higher up in the tree to be more stable.", new DoubleValue(1.0)));
    68       Parameters.Add(new FixedValueParameter<BoolValue>(FastPruningParameterName, "Accelerate Pruning by using linear models instead of leaf models", new BoolValue(true)));
     70      Parameters.Add(new FixedValueParameter<DoubleValue>(PruningStrengthParameterName, "The strength of the pruning. Higher values force the algorithm to create simpler models (default=2.0).", new DoubleValue(2.0)));
     71      Parameters.Add(new FixedValueParameter<DoubleValue>(PruningDecayParameterName, "Pruning decay allows nodes higher up in the tree to be more stable (default=1.0).", new DoubleValue(1.0)));
     72      Parameters.Add(new FixedValueParameter<BoolValue>(FastPruningParameterName, "Accelerate pruning by using linear models instead of leaf models (default=true).", new BoolValue(true)));
    6973    }
    7074    public override IDeepCloneable Clone(Cloner cloner) {
     
    136140    }
    137141
    138 
    139142    private static void UpdateThreshold(RegressionNodeTreeModel tree, PruningState state) {
    140143      if (state.Code == 2) {
     
    161164    }
    162165
    163 
    164166    private static void BuildPruningModel(RegressionNodeModel regressionNode, ILeafModel leaf, IReadOnlyList<int> trainingRows, IReadOnlyList<int> pruningRows, PruningState state, RegressionTreeParameters regressionTreeParams, CancellationToken cancellationToken) {
    165167      //create regressionProblemdata from pruning data
    166       var vars = regressionTreeParams.AllowedInputVariables.Concat(new[] {regressionTreeParams.TargetVariable}).ToArray();
     168      var vars = regressionTreeParams.AllowedInputVariables.Concat(new[] { regressionTreeParams.TargetVariable }).ToArray();
    167169      var reducedData = new Dataset(vars, vars.Select(x => regressionTreeParams.Data.GetDoubleValues(x, pruningRows).ToList()));
    168170      var pd = new RegressionProblemData(reducedData, regressionTreeParams.AllowedInputVariables, regressionTreeParams.TargetVariable);
     
    179181      state.modelErrors.Add(regressionNode, rmsModel);
    180182      state.modelComplexities.Add(regressionNode, numModelParams);
    181       if (regressionNode.IsLeaf) { state.nodeComplexities[regressionNode] = state.modelComplexities[regressionNode]; }
    182       else { state.nodeComplexities.Add(regressionNode, state.nodeComplexities[regressionNode.Left] + state.nodeComplexities[regressionNode.Right] + 1); }
     183      if (regressionNode.IsLeaf) { state.nodeComplexities[regressionNode] = state.modelComplexities[regressionNode]; } else { state.nodeComplexities.Add(regressionNode, state.nodeComplexities[regressionNode.Left] + state.nodeComplexities[regressionNode.Right] + 1); }
    183184    }
    184185
     
    200201    }
    201202
    202     [StorableClass]
     203    [StorableType("EAD60C7E-2C58-45C4-9697-6F735F518CFD")]
    203204    public class PruningState : Item {
    204205      [Storable]
     
    230231      #region HLConstructors & Cloning
    231232      [StorableConstructor]
    232       protected PruningState(bool deserializing) : base(deserializing) { }
     233      protected PruningState(StorableConstructorFlag _) : base(_) { }
    233234      protected PruningState(PruningState original, Cloner cloner) : base(original, cloner) {
    234235        modelComplexities = original.modelComplexities.ToDictionary(x => cloner.Clone(x.Key), x => x.Value);
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Pruning/NoPruning.cs

    r15830 r16847  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2726using HeuristicLab.Problems.DataAnalysis;
     27using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Algorithms.DataAnalysis {
    30   [StorableClass]
     30  [StorableType("D67152AA-3533-45D2-B77B-4A0742FB4B92")]
    3131  [Item("NoPruning", "No pruning")]
    3232  public class NoPruning : ParameterizedNamedItem, IPruning {
    3333    #region Constructors & Cloning
    3434    [StorableConstructor]
    35     private NoPruning(bool deserializing) : base(deserializing) { }
     35    private NoPruning(StorableConstructorFlag _) : base(_) { }
    3636    private NoPruning(NoPruning original, Cloner cloner) : base(original, cloner) { }
    3737    public NoPruning() { }
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Spliting/CorrelationImpuritiyCalculator.cs

    r15830 r16847  
    2828  /// <summary>
    2929  /// Helper class for incremental split calculation.
    30   /// Used while moving a potential Spliter along the ordered training Instances
     30  /// Used while moving a potential splitter along the ordered training instances
    3131  /// </summary>
    32   internal class CorrelationImpuritiyCalculator {
     32  internal class CorreleationImpurityCalculator {
    3333    #region state
    3434    //Data
     
    5858
    5959    #region Constructors
    60     public CorrelationImpuritiyCalculator(int partition, IEnumerable<double> atts, IEnumerable<double> targets, double order) {
     60    public CorreleationImpurityCalculator(int partition, IEnumerable<double> atts, IEnumerable<double> targets, double order) {
    6161      if (order <= 0) throw new ArgumentException("Splitter order must be larger than 0");
    6262      this.order = order;
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Spliting/CorrelationSplitter.cs

    r15830 r16847  
    2525using HeuristicLab.Data;
    2626using HeuristicLab.Parameters;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Algorithms.DataAnalysis {
    30   [StorableClass]
     30  [StorableType("EC3A5009-EE84-4E1A-A537-20F6F1224842")]
    3131  [Item("CorrelationSplitter", "An experimental split selector that uses correlation coefficients")]
    3232  public class CorrelationSplitter : SplitterBase {
     
    3737    public double Order {
    3838      get { return OrderParameter.Value.Value; }
     39      set { OrderParameter.Value.Value = value; }
    3940    }
    4041
    4142    #region Constructors & Cloning
    4243    [StorableConstructor]
    43     private CorrelationSplitter(bool deserializing) { }
     44    private CorrelationSplitter(StorableConstructorFlag _) { }
    4445    private CorrelationSplitter(CorrelationSplitter original, Cloner cloner) : base(original, cloner) { }
    4546    public CorrelationSplitter() {
    46       Parameters.Add(new FixedValueParameter<DoubleValue>(OrderParameterName, "The exponent in the split calculation ssrLeft^(1/Order)+ssrRight^(1/Order).", new DoubleValue(1)));
     47      Parameters.Add(new FixedValueParameter<DoubleValue>(OrderParameterName, "The exponent in the split calculation ssrLeft^(1/Order)+ssrRight^(1/Order) (default=1.0).", new DoubleValue(1)));
    4748    }
    4849    public override IDeepCloneable Clone(Cloner cloner) {
     
    6566      if (start >= length) return;
    6667
    67       var imp = new CorrelationImpuritiyCalculator(minLeafSize, attValues, targetValues, Order);
     68      var imp = new CorreleationImpurityCalculator(minLeafSize, attValues, targetValues, Order);
    6869      maxImpurity = imp.Impurity;
    6970      splitValues.Add(imp.SplitValue);
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Spliting/M5Splitter.cs

    r15830 r16847  
    2626using HeuristicLab.Data;
    2727using HeuristicLab.Parameters;
    28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Algorithms.DataAnalysis {
    31   [StorableClass]
    32   [Item("M5Splitter", "A split selector that uses the ratio between Variances^(1/Order) to determine good splits")]
     31  [StorableType("502B1429-7A28-45C1-A60A-93E72CB3AF4A")]
     32  [Item("M5Splitter", "A split selector that uses the ratio between Variances^(1/Order) to determine good splits.")]
    3333  public class M5Splitter : SplitterBase {
    3434    public const string OrderParameterName = "Order";
     
    3838    public double Order {
    3939      get { return OrderParameter.Value.Value; }
     40      set { OrderParameter.Value.Value = value; }
    4041    }
    4142
    4243    #region Constructors & Cloning
    4344    [StorableConstructor]
    44     private M5Splitter(bool deserializing) { }
     45    private M5Splitter(StorableConstructorFlag _) { }
    4546    private M5Splitter(M5Splitter original, Cloner cloner) : base(original, cloner) { }
    4647    public M5Splitter() {
    47       Parameters.Add(new FixedValueParameter<DoubleValue>(OrderParameterName, "The exponent in the split calculation sum (x_i - x_avg)^Order.", new DoubleValue(5)));
     48      Parameters.Add(new FixedValueParameter<DoubleValue>(OrderParameterName, "The exponent in the split calculation sum (x_i - x_avg)^Order (default=5).", new DoubleValue(5)));
    4849    }
    4950    public override IDeepCloneable Clone(Cloner cloner) {
     
    6768      var imp = new OrderImpurityCalculator(part + 1, targetValues, Order);
    6869
    69       //if (imp.Impurity > maxImpurity && !attValues[part - 1].IsAlmost(attValues[part])) {
    70       //  maxImpurity = imp.Impurity;
    71       //  splitValue = (attValues[part - 1] + attValues[part]) / 2;
    72       //  position = part;
    73       //}
    74 
    7570      for (var i = low + len; i < high - len; i++) {
    7671        imp.Increment(targetValues[i], OrderImpurityCalculator.IncrementType.Left);
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Spliting/OrderImpurityCalculator.cs

    r15830 r16847  
    2828  /// <summary>
    2929  /// Helper class for incremental split calculation.
    30   /// Used while moving a potential Splitter along the ordered training Instances
     30  /// Used while moving a potential splitter along the ordered training instances
    3131  /// </summary>
    3232  internal class OrderImpurityCalculator {
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Spliting/SplitterBase.cs

    r15830 r16847  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
    28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928using HeuristicLab.Problems.DataAnalysis;
     29using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Algorithms.DataAnalysis {
    32   [StorableClass]
    33   [Item("SplitterBase", "A split selector that uses the ratio between Variances^(1/Order) to determine good splits")]
     32  [StorableType("22DCCF28-8943-4622-BBD3-B2AB04F28C36")]
     33  [Item("SplitterBase", "Abstract base class for splitters")]
    3434  public abstract class SplitterBase : ParameterizedNamedItem, ISplitter {
    3535    public const string SplittingStateVariableName = "RuleSetState";
     
    3737    #region Constructors & Cloning
    3838    [StorableConstructor]
    39     protected SplitterBase(bool deserializing) { }
     39    protected SplitterBase(StorableConstructorFlag _) { }
    4040    protected SplitterBase(SplitterBase original, Cloner cloner) : base(original, cloner) { }
    4141    public SplitterBase() { }
     
    4646      states.Variables.Add(new Variable(SplittingStateVariableName, new SplittingState()));
    4747    }
     48
    4849    public void Split(RegressionNodeTreeModel tree, IReadOnlyList<int> trainingRows, IScope stateScope, CancellationToken cancellationToken) {
    4950      var regressionTreeParams = (RegressionTreeParameters)stateScope.Variables[M5Regression.RegressionTreeParameterVariableName].Value;
     
    8788      if (splitData.Dataset.Rows < minLeafSize) return false;
    8889
    89       //find best Attribute for the Splitter
     90      // find best attribute for the splitter
    9091      foreach (var attr in splitData.AllowedInputVariables) {
    9192        int pos;
     
    109110    #endregion
    110111
    111     [StorableClass]
     112    [StorableType("BC1149FD-370E-4F3A-92F5-6E519736D09A")]
    112113    public class SplittingState : Item {
    113114      [Storable]
     
    124125      #region HLConstructors & Cloning
    125126      [StorableConstructor]
    126       protected SplittingState(bool deserializing) : base(deserializing) { }
     127      protected SplittingState(StorableConstructorFlag _) : base(_) { }
    127128      protected SplittingState(SplittingState original, Cloner cloner) : base(original, cloner) {
    128129        nodeQueue = new Queue<RegressionNodeModel>(original.nodeQueue.Select(cloner.Clone));
  • branches/2847_M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/Spliting/UnivariateOnlineLR.cs

    r15830 r16847  
    2828  /// <summary>
    2929  /// Helper class for incremental split calculation.
    30   /// Used while moving a potential Spliter along the ordered training Instances
     30  /// Used while moving a potential splitter along the ordered training instances
    3131  /// </summary>
    3232  internal class UnivariateOnlineLR {
Note: See TracChangeset for help on using the changeset viewer.