1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using HeuristicLab.Common;
|
---|
4 | using HeuristicLab.Core;
|
---|
5 | using HeuristicLab.Data;
|
---|
6 | using HeuristicLab.Parameters;
|
---|
7 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
8 |
|
---|
9 | namespace 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 |
|
---|
32 | protected ExponentialTransformation(ExponentialTransformation original, Cloner cloner)
|
---|
33 | : base(original, cloner) {
|
---|
34 | }
|
---|
35 |
|
---|
36 | public ExponentialTransformation(IEnumerable<string> allowedColumns)
|
---|
37 | : base(allowedColumns) {
|
---|
38 | Parameters.Add(new ValueParameter<DoubleValue>(BaseParameterName, "b | Base of exp-function", new DoubleValue(Math.E)));
|
---|
39 | }
|
---|
40 |
|
---|
41 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
42 | return new ExponentialTransformation(this, cloner);
|
---|
43 | }
|
---|
44 |
|
---|
45 | public override IEnumerable<double> Apply(IEnumerable<double> data) {
|
---|
46 | foreach (double d in data) {
|
---|
47 | yield return Math.Pow(Base, d);
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | public override bool Check(IEnumerable<double> data, out string errorMsg) {
|
---|
52 | errorMsg = "";
|
---|
53 | return true;
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|