Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleProblemData.cs @ 17956

Last change on this file since 17956 was 17835, checked in by bburlacu, 4 years ago

#3102: Add ClassificationProblemData constructor that explicitly takes class names and positive class value arguments, adapt code.

File size: 4.4 KB
RevLine 
[6239]1#region License Information
2/* HeuristicLab
[17180]3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[6239]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;
[16565]27using HEAL.Attic;
[6239]28
29namespace HeuristicLab.Problems.DataAnalysis {
[16565]30  [StorableType("58768587-0920-4B52-95E4-66B54E8E837C")]
[6239]31  [Item("ClassificationEnsembleProblemData", "Represents an item containing all data defining a classification problem.")]
32  public class ClassificationEnsembleProblemData : ClassificationProblemData {
33
[6672]34    public override bool IsTrainingSample(int index) {
35      return index >= 0 && index < Dataset.Rows &&
36             TrainingPartition.Start <= index && index < TrainingPartition.End;
[6239]37    }
[6672]38
39    public override bool IsTestSample(int index) {
40      return index >= 0 && index < Dataset.Rows &&
41             TestPartition.Start <= index && index < TestPartition.End;
[6239]42    }
43
[6672]44    private static readonly ClassificationEnsembleProblemData emptyProblemData;
[7043]45    public static new ClassificationEnsembleProblemData EmptyProblemData {
[6666]46      get { return emptyProblemData; }
47    }
48
49    static ClassificationEnsembleProblemData() {
50      var problemData = new ClassificationEnsembleProblemData();
51      problemData.Parameters.Clear();
52      problemData.Name = "Empty Classification 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      problemData.Parameters.Add(new FixedValueParameter<StringMatrix>(ClassNamesParameterName, "", new StringMatrix(0, 0).AsReadOnly()));
62      problemData.Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, "", (DoubleMatrix)new DoubleMatrix(0, 0).AsReadOnly()));
63      emptyProblemData = problemData;
64    }
65
[6239]66    [StorableConstructor]
[16565]67    protected ClassificationEnsembleProblemData(StorableConstructorFlag _) : base(_) { }
[6666]68    protected ClassificationEnsembleProblemData(ClassificationEnsembleProblemData original, Cloner cloner) : base(original, cloner) { }
69    public override IDeepCloneable Clone(Cloner cloner) {
70      if (this == emptyProblemData) return emptyProblemData;
71      return new ClassificationEnsembleProblemData(this, cloner);
[6239]72    }
73
[6666]74    public ClassificationEnsembleProblemData() : base() { }
[17835]75
[6239]76    public ClassificationEnsembleProblemData(IClassificationProblemData classificationProblemData)
[17835]77      : base(classificationProblemData) {
[6239]78    }
[6666]79
80    public ClassificationEnsembleProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
81      : base(dataset, allowedInputVariables, targetVariable) {
82    }
[17835]83
84    public ClassificationEnsembleProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, IEnumerable<string> classNames, string positiveClass = null)
85      : base(dataset, allowedInputVariables, targetVariable, classNames, positiveClass) {
86    }
[6239]87  }
88}
Note: See TracBrowser for help on using the repository browser.