[15830] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[17180] | 3 | * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[15830] | 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;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using HeuristicLab.Common;
|
---|
| 25 | using HeuristicLab.Core;
|
---|
| 26 | using HeuristicLab.Problems.DataAnalysis;
|
---|
[16847] | 27 | using HEAL.Attic;
|
---|
[15830] | 28 |
|
---|
| 29 | namespace HeuristicLab.Algorithms.DataAnalysis {
|
---|
[16847] | 30 | [StorableType("A6293516-C146-469D-B248-31B866A1D94F")]
|
---|
[16855] | 31 | public sealed class RegressionTreeParameters : Item {
|
---|
[17085] | 32 | [Storable]
|
---|
[15830] | 33 | private readonly ISplitter splitter;
|
---|
[17085] | 34 | [Storable]
|
---|
[15830] | 35 | private readonly IPruning pruning;
|
---|
[17085] | 36 | [Storable]
|
---|
[15830] | 37 | private readonly ILeafModel leafModel;
|
---|
[17085] | 38 | [Storable]
|
---|
[15830] | 39 | private readonly int minLeafSize;
|
---|
[17085] | 40 | [Storable]
|
---|
[15830] | 41 | private readonly IRegressionProblemData problemData;
|
---|
[17085] | 42 | [Storable]
|
---|
[15830] | 43 | private readonly IRandom random;
|
---|
[17085] | 44 |
|
---|
[15830] | 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]
|
---|
[16847] | 75 | private RegressionTreeParameters(StorableConstructorFlag _) : base(_) { }
|
---|
[15830] | 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 | } |
---|