Free cookie consent management tool by TermsFeed Policy Generator

source: branches/M5Regression/HeuristicLab.Algorithms.DataAnalysis/3.4/M5Regression/LeafTypes/LogisticLeaf.cs @ 15830

Last change on this file since 15830 was 15830, checked in by bwerth, 6 years ago

#2847 adapted project to new rep structure; major changes to interfaces; restructures splitting and pruning

File size: 2.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2017 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
22using System;
23using System.Linq;
24using System.Threading;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30using HeuristicLab.Problems.DataAnalysis;
31
32namespace HeuristicLab.Algorithms.DataAnalysis {
33  [StorableClass]
34  [Item("LogisticLeaf", "A leaf type that uses linear models with a logistic dampening as leaf models. Dampening reduces prediction values far outside the observed target values.")]
35  public class LogisticLeaf : LeafBase {
36    private const string DampeningParameterName = "Dampening";
37    public IFixedValueParameter<DoubleValue> DampeningParameter {
38      get { return Parameters[DampeningParameterName] as IFixedValueParameter<DoubleValue>; }
39    }
40    public double Dampening {
41      get { return DampeningParameter.Value.Value; }
42    }
43
44    #region Constructors & Cloning
45    [StorableConstructor]
46    private LogisticLeaf(bool deserializing) : base(deserializing) { }
47    private LogisticLeaf(LogisticLeaf original, Cloner cloner) : base(original, cloner) { }
48    public LogisticLeaf() {
49      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)));
50    }
51    public override IDeepCloneable Clone(Cloner cloner) {
52      return new LogisticLeaf(this, cloner);
53    }
54    #endregion
55
56    #region IModelType
57    public override bool ProvidesConfidence {
58      get { return true; }
59    }
60    public override IRegressionModel Build(IRegressionProblemData pd, IRandom random, CancellationToken cancellationToken, out int noParameters) {
61      var res = (IConfidenceRegressionModel)new LinearLeaf().Build(pd, random, cancellationToken, out noParameters);
62      return new DampenedLinearModel(res, pd, Dampening);
63    }
64
65    public override int MinLeafSize(IRegressionProblemData pd) {
66      return pd.AllowedInputVariables.Count() + 2;
67    }
68    #endregion
69  }
70}
Note: See TracBrowser for help on using the repository browser.