Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/PowerTransformation.cs @ 16628

Last change on this file since 16628 was 16628, checked in by gkronber, 5 years ago

#2971: made branch compile with current version of trunk

File size: 1.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using HeuristicLab.Common;
5using HeuristicLab.Core;
6using HeuristicLab.Data;
7using HeuristicLab.Parameters;
8using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
9using HEAL.Attic;
10
11namespace HeuristicLab.Problems.DataAnalysis {
12  [StorableType("E0F646B4-57C1-4802-B133-88B27D5B5C95")]
13  [Item("Power Transformation", "f(x) = x ^ exp | Represents a power transformation.")]
14  public class PowerTransformation : Transformation<double> {
15    protected const string ExponentParameterName = "Exponent";
16
17    #region Parameters
18    public IValueParameter<DoubleValue> ExponentParameter {
19      get { return (IValueParameter<DoubleValue>)Parameters[ExponentParameterName]; }
20    }
21    #endregion
22
23    #region properties
24    public override string ShortName {
25      get { return "Pow"; }
26    }
27    public double Exponent {
28      get { return ExponentParameter.Value.Value; }
29    }
30    #endregion
31
32    [StorableConstructor]
33    protected PowerTransformation(StorableConstructorFlag _) : base(_) { }
34    protected PowerTransformation(PowerTransformation original, Cloner cloner)
35      : base(original, cloner) {
36    }
37    public PowerTransformation(IEnumerable<string> allowedColumns)
38      : base(allowedColumns) {
39      Parameters.Add(new ValueParameter<DoubleValue>(ExponentParameterName, "exp | Exponent for Exponentation", new DoubleValue(2.0)));
40    }
41
42    public override IDeepCloneable Clone(Cloner cloner) {
43      return new PowerTransformation(this, cloner);
44    }
45
46    public override IEnumerable<double> Apply(IEnumerable<double> data) {
47      return data.Select(i => Math.Pow(i, Exponent));
48    }
49
50    public override bool Check(IEnumerable<double> data, out string errorMsg) {
51      errorMsg = "";
52      return true;
53    }
54
55  }
56}
Note: See TracBrowser for help on using the repository browser.