Ignore:
Timestamp:
04/19/19 13:06:11 (4 months ago)
Author:
gkronber
Message:

#2847: made some minor changes while reviewing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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));
Note: See TracChangeset for help on using the changeset viewer.