Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ExponentialTransformation.cs @ 11068

Last change on this file since 11068 was 11068, checked in by mkommend, 10 years ago

#2206: Removed seperate plugin for transformations and integrated them in HeuristicLab.Problems.DataAnalysis.

File size: 1.8 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 {
10  [Item("Exponential Transformation", "f(x) = b ^ x | Represents a exponential transformation.")]
11  public class ExponentialTransformation : 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 override string ShortName {
22      get { return "Exp"; }
23    }
24    public double Base {
25      get { return BaseParameter.Value.Value; }
26    }
27    #endregion
28
29    [StorableConstructor]
30    protected ExponentialTransformation(bool deserializing) : base(deserializing) { }
31    protected ExponentialTransformation(Transformation<double> original, Cloner cloner)
32      : base(original, cloner) {
33    }
34    public ExponentialTransformation(IEnumerable<string> allowedColumns)
35      : base(allowedColumns) {
36      Parameters.Add(new ValueParameter<DoubleValue>(BaseParameterName, "b | Base of exp-function", new DoubleValue(Math.E)));
37    }
38
39    public override IDeepCloneable Clone(Cloner cloner) {
40      return new ExponentialTransformation(this, cloner);
41    }
42
43    public override IEnumerable<double> Apply(IEnumerable<double> data) {
44      foreach (double d in data) {
45        yield return Math.Pow(Base, d);
46      }
47    }
48
49    public override bool Check(IEnumerable<double> data, out string errorMsg) {
50      errorMsg = "";
51      return true;
52    }
53  }
54}
Note: See TracBrowser for help on using the repository browser.