Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleProblemData.cs @ 16640

Last change on this file since 16640 was 16640, checked in by gkronber, 5 years ago

#2971: merged r16565:16631 from trunk/HeuristicLab.Problems.DataAnalysis to branch/HeuristicLab.Problems.DataAnalysis (resolving all conflicts)

File size: 4.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2019 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.Collections.Generic;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Parameters;
27using HEAL.Attic;
28using HEAL.Attic;
29
30namespace HeuristicLab.Problems.DataAnalysis {
31  [StorableType("CB105C71-FA47-4FFC-BF56-57B6BB2E0BC7")]
32  [Item("RegressionEnsembleProblemData", "Represents an item containing all data defining a regression problem.")]
33  public sealed class RegressionEnsembleProblemData : RegressionProblemData {
34
35    public override bool IsTrainingSample(int index) {
36      return index >= 0 && index < Dataset.Rows &&
37             TrainingPartition.Start <= index && index < TrainingPartition.End;
38    }
39
40    public override bool IsTestSample(int index) {
41      return index >= 0 && index < Dataset.Rows &&
42             TestPartition.Start <= index && index < TestPartition.End;
43    }
44
45    private static readonly RegressionEnsembleProblemData emptyProblemData;
46    public new static RegressionEnsembleProblemData EmptyProblemData {
47      get { return emptyProblemData; }
48    }
49    static RegressionEnsembleProblemData() {
50      var problemData = new RegressionEnsembleProblemData();
51      problemData.Parameters.Clear();
52      problemData.Name = "Empty Regression ProblemData";
53      problemData.Description = "This ProblemData acts as place holder before the correct problem data is loaded.";
54      problemData.isEmpty = true;
55
56      problemData.Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", new Dataset()));
57      problemData.Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, ""));
58      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
59      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
60      problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>()));
61      emptyProblemData = problemData;
62    }
63
64    [StorableConstructor]
65    private RegressionEnsembleProblemData(StorableConstructorFlag _) : base(_) { }
66    private RegressionEnsembleProblemData(RegressionEnsembleProblemData original, Cloner cloner) : base(original, cloner) { }
67    public override IDeepCloneable Clone(Cloner cloner) {
68      if (this == emptyProblemData) return emptyProblemData;
69      return new RegressionEnsembleProblemData(this, cloner);
70    }
71
72    public RegressionEnsembleProblemData() : base() { }
73    public RegressionEnsembleProblemData(IRegressionProblemData regressionProblemData)
74      : base(regressionProblemData.Dataset, regressionProblemData.AllowedInputVariables, regressionProblemData.TargetVariable) {
75      TrainingPartition.Start = regressionProblemData.TrainingPartition.Start;
76      TrainingPartition.End = regressionProblemData.TrainingPartition.End;
77      TestPartition.Start = regressionProblemData.TestPartition.Start;
78      TestPartition.End = regressionProblemData.TestPartition.End;
79    }
80    public RegressionEnsembleProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
81      : base(dataset, allowedInputVariables, targetVariable) {
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.