Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Transformations/3.3/ExponentiationTransformation.cs @ 10784

Last change on this file since 10784 was 10782, checked in by tsteinre, 11 years ago

Added ExponentiationTransformation

File size: 1.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using HeuristicLab.Common;
4using HeuristicLab.Core;
5using HeuristicLab.Data;
6using HeuristicLab.Parameters;
7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8
9namespace HeuristicLab.Problems.DataAnalysis.Transformations {
10  [Item("ExponentationTransformation", "Represents a exponentation transformation.")]
11  public class ExponentiationTransformation : Transformation<double> {
12    protected const string BaseParameterName = "Base";
13
14    #region Parameters
15    public IValueParameter<DoubleValue> BaseParameter {
16      get { return (IValueParameter<DoubleValue>)Parameters[BaseParameterName]; }
17    }
18    #endregion
19
20    #region properties
21    public double Base {
22      get { return BaseParameter.Value.Value; }
23    }
24    #endregion
25
26    [StorableConstructor]
27    protected ExponentiationTransformation(bool deserializing) : base(deserializing) { }
28    protected ExponentiationTransformation(Transformation<double> original, Cloner cloner)
29      : base(original, cloner) {
30    }
31    public ExponentiationTransformation(IEnumerable<string> allowedColumns)
32      : base(allowedColumns) {
33      Parameters.Add(new ValueParameter<DoubleValue>(BaseParameterName, "Base for Exponentation", new DoubleValue(Math.E)));
34    }
35
36    public override IDeepCloneable Clone(Cloner cloner) {
37      return new ExponentiationTransformation(this, cloner);
38    }
39
40    public override IEnumerable<double> Apply(IEnumerable<double> data) {
41      foreach (double i in data) {
42        yield return Math.Pow(Base, i);
43      }
44    }
45
46    public override bool Check(IEnumerable<double> data, out string errorMsg) {
47      errorMsg = "";
48      return true;
49    }
50
51  }
52}
Note: See TracBrowser for help on using the repository browser.