[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 |
|
---|
| 22 | using System.Linq;
|
---|
| 23 | using HeuristicLab.Core;
|
---|
| 24 | using HeuristicLab.Data;
|
---|
| 25 | using HeuristicLab.DataPreprocessing.Transformations;
|
---|
| 26 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
| 27 | using HeuristicLab.Parameters;
|
---|
| 28 |
|
---|
| 29 | namespace 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 | }
|
---|