Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisTransformation.cs @ 15870

Last change on this file since 15870 was 15870, checked in by pfleck, 5 years ago

#2906

  • Implemented for classification, clustering, etc.
  • Simplified Transformation interfaces (read-only, ...).
  • Started moving transformation logic out of ProblemData.
File size: 3.3 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 HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Parameters;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Problems.DataAnalysis {
29  [Item("Transformation", "A transformation applied to a DataAnalysisProblemData")]
30  [StorableClass]
31  public class DataAnalysisTransformation : ParameterizedNamedItem, IDataAnalysisTransformation {
32    #region Parameter Properties
33    private IFixedValueParameter<StringValue> OriginalVariableParameter {
34      get { return (IFixedValueParameter<StringValue>)Parameters["Original Variable"]; }
35    }
36
37    private IFixedValueParameter<StringValue> TransformedVariableParameter {
38      get { return (IFixedValueParameter<StringValue>)Parameters["Transformed Variable"]; }
39    }
40
41    private ValueParameter<ITransformation> TransformationParameter {
42      get { return (ValueParameter<ITransformation>)Parameters["Transformation"]; }
43    }
44    #endregion
45
46    #region Properties
47    public string OriginalVariable {
48      get { return OriginalVariableParameter.Value.Value; }
49    }
50
51    public string TransformedVariable {
52      get { return TransformedVariableParameter.Value.Value; }
53    }
54
55    public ITransformation Transformation {
56      get { return TransformationParameter.Value; }
57    }
58    #endregion
59
60    #region Constructor, Cloning & Persistence
61    public DataAnalysisTransformation(string originalVariable, string transformedVariable, ITransformation transformation)
62      : base() {
63      Parameters.Add(new FixedValueParameter<StringValue>("Original Variable", new StringValue(originalVariable).AsReadOnly()));
64      Parameters.Add(new FixedValueParameter<StringValue>("Transformed Variable", new StringValue(transformedVariable).AsReadOnly()));
65      Parameters.Add(new ValueParameter<ITransformation>("Transformation", transformation)); // TODO: should be readonly/fixed
66    }
67
68    protected DataAnalysisTransformation(DataAnalysisTransformation original, Cloner cloner)
69      : base(original, cloner) {
70    }
71
72    public override IDeepCloneable Clone(Cloner cloner) {
73      return new DataAnalysisTransformation(this, cloner);
74    }
75
76    [StorableConstructor]
77    protected DataAnalysisTransformation(bool deserializing)
78      : base(deserializing) { }
79
80    [StorableHook(HookType.AfterDeserialization)]
81    #endregion
82
83    public override string ToString() {
84      return $"{Transformation} ({OriginalVariable} -> {TransformedVariable})";
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.