[15830] | 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 |
|
---|
| 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")]
|
---|
[15830] | 31 | public class RegressionTreeParameters : Item {
|
---|
| 32 | private readonly ISplitter splitter;
|
---|
| 33 | private readonly IPruning pruning;
|
---|
| 34 | private readonly ILeafModel leafModel;
|
---|
| 35 | private readonly int minLeafSize;
|
---|
| 36 | private readonly IRegressionProblemData problemData;
|
---|
| 37 | private readonly IRandom random;
|
---|
| 38 | public ISplitter Splitter {
|
---|
| 39 | get { return splitter; }
|
---|
| 40 | }
|
---|
| 41 | public IPruning Pruning {
|
---|
| 42 | get { return pruning; }
|
---|
| 43 | }
|
---|
| 44 | public ILeafModel LeafModel {
|
---|
| 45 | get { return leafModel; }
|
---|
| 46 | }
|
---|
| 47 | public int MinLeafSize {
|
---|
| 48 | get { return minLeafSize; }
|
---|
| 49 | }
|
---|
| 50 | private IRegressionProblemData ProblemData {
|
---|
| 51 | get { return problemData; }
|
---|
| 52 | }
|
---|
| 53 | public IRandom Random {
|
---|
| 54 | get { return random; }
|
---|
| 55 | }
|
---|
| 56 | public IEnumerable<string> AllowedInputVariables {
|
---|
| 57 | get { return ProblemData.AllowedInputVariables; }
|
---|
| 58 | }
|
---|
| 59 | public string TargetVariable {
|
---|
| 60 | get { return ProblemData.TargetVariable; }
|
---|
| 61 | }
|
---|
| 62 | public IDataset Data {
|
---|
| 63 | get { return ProblemData.Dataset; }
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | #region Constructors & Cloning
|
---|
| 67 | [StorableConstructor]
|
---|
[16847] | 68 | private RegressionTreeParameters(StorableConstructorFlag _) : base(_) { }
|
---|
[15830] | 69 | private RegressionTreeParameters(RegressionTreeParameters original, Cloner cloner) : base(original, cloner) {
|
---|
| 70 | problemData = cloner.Clone(original.problemData);
|
---|
| 71 | random = cloner.Clone(original.random);
|
---|
| 72 | leafModel = cloner.Clone(original.leafModel);
|
---|
| 73 | splitter = cloner.Clone(original.splitter);
|
---|
| 74 | pruning = cloner.Clone(original.pruning);
|
---|
| 75 | minLeafSize = original.minLeafSize;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | public RegressionTreeParameters(IPruning pruning, int minleafSize, ILeafModel leafModel,
|
---|
| 79 | IRegressionProblemData problemData, IRandom random, ISplitter splitter) {
|
---|
| 80 | this.problemData = problemData;
|
---|
| 81 | this.random = random;
|
---|
| 82 | this.leafModel = leafModel;
|
---|
| 83 | this.splitter = splitter;
|
---|
| 84 | this.pruning = pruning;
|
---|
| 85 | minLeafSize = Math.Max(pruning.MinLeafSize(problemData, leafModel), Math.Max(minleafSize, leafModel.MinLeafSize(problemData)));
|
---|
| 86 | }
|
---|
| 87 | public RegressionTreeParameters(ILeafModel modeltype, IRegressionProblemData problemData, IRandom random) {
|
---|
| 88 | this.problemData = problemData;
|
---|
| 89 | this.random = random;
|
---|
| 90 | leafModel = modeltype;
|
---|
| 91 | }
|
---|
| 92 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 93 | return new RegressionTreeParameters(this, cloner);
|
---|
| 94 | }
|
---|
| 95 | #endregion
|
---|
| 96 | }
|
---|
| 97 | } |
---|