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