Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/Transformations/LinearTransformation.cs @ 10671

Last change on this file since 10671 was 10671, checked in by tsteinre, 10 years ago

created LinearTransformation (not ready yet)

File size: 2.8 KB
RevLine 
[10671]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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.Linq;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.DataPreprocessing.Transformations;
26using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
27using HeuristicLab.Parameters;
28
29namespace HeuristicLab.DataPreprocessing.Implementations.Transformations {
30  [Item("LinearTransformation", "Represents a linear transformation with multiplication and addition.")]
31  public class LinearTransformation : Transformation {
32
33    #region Parameters
34    public IValueParameter<DoubleValue> MultiplicandParameter {
35      get { return (IValueParameter<DoubleValue>)Parameters["Multiplicand"]; }
36    }
37    public IValueParameter<DoubleValue> SummandParameter {
38      get { return (IValueParameter<DoubleValue>)Parameters["Summand"]; }
39    }
40    #endregion
41
42    public LinearTransformation()
43      : base() {
44      Parameters.Add(new ValueParameter<DoubleValue>("Multiplicand", "Multiplicand for linear transformation", new DoubleValue(1.0)));
45      Parameters.Add(new ValueParameter<DoubleValue>("Summand", "Summand for linear transformation", new DoubleValue(0.0)));
46    }
47
48    public override void Transform() {
49      PreprocessingData.InTransaction(() => {
50        int idx = PreprocessingData.GetColumnIndex(Column);
51        if (PreprocessingData.IsType<double>(idx)) {
52          var column = PreprocessingData.GetValues<double>(idx);
53          var transformedColumn = column.Select(e => e * MultiplicandParameter.Value.Value + SummandParameter.Value.Value).ToList();
54          PreprocessingData.SetValues<double>(idx, transformedColumn);
55        }
56      },
57      DataPreprocessingChangedEventType.Transformation);
58    }
59
60    public override ISymbolicExpressionTree GenerateInverseTransformation() {
61      throw new System.NotImplementedException();
62    }
63
64    public override void Check() {
65      throw new System.NotImplementedException();
66    }
67
68    public override Common.IDeepCloneable Clone(Common.Cloner cloner) {
69      throw new System.NotImplementedException();
70    }
71  }
72}
Note: See TracBrowser for help on using the repository browser.