Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 6666 was 6666, checked in by mkommend, 13 years ago

#1592: Enabled creation of empty ensemble solutions and problem data changes.

File size: 4.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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 System.Linq;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Data;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Problems.DataAnalysis {
31  [StorableClass]
32  [Item("ClassificationEnsembleProblemData", "Represents an item containing all data defining a classification problem.")]
33  public class ClassificationEnsembleProblemData : ClassificationProblemData {
34
35    public override IEnumerable<int> TrainingIndizes {
36      get { return Enumerable.Range(TrainingPartition.Start, TrainingPartition.End - TrainingPartition.Start); }
37    }
38    public override IEnumerable<int> TestIndizes {
39      get { return Enumerable.Range(TestPartition.Start, TestPartition.End - TestPartition.Start); }
40    }
41
42    private static ClassificationEnsembleProblemData emptyProblemData;
43    public static ClassificationEnsembleProblemData EmptyProblemData {
44      get { return emptyProblemData; }
45    }
46
47    static ClassificationEnsembleProblemData() {
48      var problemData = new ClassificationEnsembleProblemData();
49      problemData.Parameters.Clear();
50      problemData.Name = "Empty Classification ProblemData";
51      problemData.Description = "This ProblemData acts as place holder before the correct problem data is loaded.";
52      problemData.isEmpty = true;
53
54      problemData.Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", new Dataset()));
55      problemData.Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, ""));
56      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
57      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
58      problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>()));
59      problemData.Parameters.Add(new FixedValueParameter<StringMatrix>(ClassNamesParameterName, "", new StringMatrix(0, 0).AsReadOnly()));
60      problemData.Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, "", (DoubleMatrix)new DoubleMatrix(0, 0).AsReadOnly()));
61      emptyProblemData = problemData;
62    }
63
64    [StorableConstructor]
65    protected ClassificationEnsembleProblemData(bool deserializing) : base(deserializing) { }
66    protected ClassificationEnsembleProblemData(ClassificationEnsembleProblemData original, Cloner cloner) : base(original, cloner) { }
67    public override IDeepCloneable Clone(Cloner cloner) {
68      if (this == emptyProblemData) return emptyProblemData;
69      return new ClassificationEnsembleProblemData(this, cloner);
70    }
71
72    public ClassificationEnsembleProblemData() : base() { }
73    public ClassificationEnsembleProblemData(IClassificationProblemData classificationProblemData)
74      : base(classificationProblemData.Dataset, classificationProblemData.AllowedInputVariables, classificationProblemData.TargetVariable) {
75      this.TrainingPartition.Start = classificationProblemData.TrainingPartition.Start;
76      this.TrainingPartition.End = classificationProblemData.TrainingPartition.End;
77      this.TestPartition.Start = classificationProblemData.TestPartition.Start;
78      this.TestPartition.End = classificationProblemData.TestPartition.End;
79    }
80
81    public ClassificationEnsembleProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable)
82      : base(dataset, allowedInputVariables, targetVariable) {
83    }
84  }
85}
Note: See TracBrowser for help on using the repository browser.