Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleProblemData.cs @ 16628

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

#2971: made branch compile with current version of trunk

File size: 4.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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 HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28using HEAL.Attic;
29
30namespace HeuristicLab.Problems.DataAnalysis {
31  [StorableType("90243689-01F7-4FA2-9317-68B9CFEFC05C")]
32  [Item("ClassificationEnsembleProblemData", "Represents an item containing all data defining a classification problem.")]
33  public class ClassificationEnsembleProblemData : ClassificationProblemData {
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 ClassificationEnsembleProblemData emptyProblemData;
46    public static new ClassificationEnsembleProblemData EmptyProblemData {
47      get { return emptyProblemData; }
48    }
49
50    static ClassificationEnsembleProblemData() {
51      var problemData = new ClassificationEnsembleProblemData();
52      problemData.Parameters.Clear();
53      problemData.Name = "Empty Classification ProblemData";
54      problemData.Description = "This ProblemData acts as place holder before the correct problem data is loaded.";
55      problemData.isEmpty = true;
56
57      problemData.Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", new Dataset()));
58      problemData.Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, ""));
59      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
60      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
61      problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>()));
62      problemData.Parameters.Add(new FixedValueParameter<StringMatrix>(ClassNamesParameterName, "", new StringMatrix(0, 0).AsReadOnly()));
63      problemData.Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, "", (DoubleMatrix)new DoubleMatrix(0, 0).AsReadOnly()));
64      emptyProblemData = problemData;
65    }
66
67    [StorableConstructor]
68    protected ClassificationEnsembleProblemData(StorableConstructorFlag _) : base(_) { }
69    protected ClassificationEnsembleProblemData(ClassificationEnsembleProblemData original, Cloner cloner) : base(original, cloner) { }
70    public override IDeepCloneable Clone(Cloner cloner) {
71      if (this == emptyProblemData) return emptyProblemData;
72      return new ClassificationEnsembleProblemData(this, cloner);
73    }
74
75    public ClassificationEnsembleProblemData() : base() { }
76    public ClassificationEnsembleProblemData(IClassificationProblemData classificationProblemData)
77      : base(classificationProblemData.Dataset, classificationProblemData.AllowedInputVariables, classificationProblemData.TargetVariable) {
78      this.TrainingPartition.Start = classificationProblemData.TrainingPartition.Start;
79      this.TrainingPartition.End = classificationProblemData.TrainingPartition.End;
80      this.TestPartition.Start = classificationProblemData.TestPartition.Start;
81      this.TestPartition.End = classificationProblemData.TestPartition.End;
82      this.PositiveClass = classificationProblemData.PositiveClass;
83    }
84
85    public ClassificationEnsembleProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
86      : base(dataset, allowedInputVariables, targetVariable) {
87    }
88  }
89}
Note: See TracBrowser for help on using the repository browser.