Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/Utilities/RegressionTreeParameters.cs @ 17591

Last change on this file since 17591 was 17181, checked in by swagner, 5 years ago

#2875: Merged r17180 from trunk to stable

File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 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.Collections.Generic;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Problems.DataAnalysis;
27using HEAL.Attic;
28
29namespace HeuristicLab.Algorithms.DataAnalysis {
30  [StorableType("A6293516-C146-469D-B248-31B866A1D94F")]
31  public sealed class RegressionTreeParameters : Item {
32    [Storable]
33    private readonly ISplitter splitter;
34    [Storable]
35    private readonly IPruning pruning;
36    [Storable]
37    private readonly ILeafModel leafModel;
38    [Storable]
39    private readonly int minLeafSize;
40    [Storable]
41    private readonly IRegressionProblemData problemData;
42    [Storable]
43    private readonly IRandom random;
44
45    public ISplitter Splitter {
46      get { return splitter; }
47    }
48    public IPruning Pruning {
49      get { return pruning; }
50    }
51    public ILeafModel LeafModel {
52      get { return leafModel; }
53    }
54    public int MinLeafSize {
55      get { return minLeafSize; }
56    }
57    private IRegressionProblemData ProblemData {
58      get { return problemData; }
59    }
60    public IRandom Random {
61      get { return random; }
62    }
63    public IEnumerable<string> AllowedInputVariables {
64      get { return ProblemData.AllowedInputVariables; }
65    }
66    public string TargetVariable {
67      get { return ProblemData.TargetVariable; }
68    }
69    public IDataset Data {
70      get { return ProblemData.Dataset; }
71    }
72
73    #region Constructors & Cloning
74    [StorableConstructor]
75    private RegressionTreeParameters(StorableConstructorFlag _) : base(_) { }
76    private RegressionTreeParameters(RegressionTreeParameters original, Cloner cloner) : base(original, cloner) {
77      problemData = cloner.Clone(original.problemData);
78      random = cloner.Clone(original.random);
79      leafModel = cloner.Clone(original.leafModel);
80      splitter = cloner.Clone(original.splitter);
81      pruning = cloner.Clone(original.pruning);
82      minLeafSize = original.minLeafSize;
83    }
84
85    public RegressionTreeParameters(IPruning pruning, int minleafSize, ILeafModel leafModel,
86      IRegressionProblemData problemData, IRandom random, ISplitter splitter) {
87      this.problemData = problemData;
88      this.random = random;
89      this.leafModel = leafModel;
90      this.splitter = splitter;
91      this.pruning = pruning;
92      minLeafSize = Math.Max(pruning.MinLeafSize(problemData, leafModel), Math.Max(minleafSize, leafModel.MinLeafSize(problemData)));
93    }
94    public RegressionTreeParameters(ILeafModel modeltype, IRegressionProblemData problemData, IRandom random) {
95      this.problemData = problemData;
96      this.random = random;
97      leafModel = modeltype;
98    }
99    public override IDeepCloneable Clone(Cloner cloner) {
100      return new RegressionTreeParameters(this, cloner);
101    }
102    #endregion
103  }
104}
Note: See TracBrowser for help on using the repository browser.