Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Transformations/3.3/DeviationTransformation.cs @ 10809

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

Added DeviationTransformation (not ready implemented)

File size: 2.7 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;
9
10namespace HeuristicLab.Problems.DataAnalysis.Transformations {
11  [Item("DeviationTransformation", "Represents a linear Transformation using deviation Parameters")]
12  public class DeviationTransformation : LinearTransformation {
13    protected const string MeanParameterName = "Mean";
14    protected const string VarianceParameterName = "Variance";
15
16    #region Parameters
17    public IValueParameter<DoubleValue> MeanParameter {
18      get { return (IValueParameter<DoubleValue>)Parameters[MeanParameterName]; }
19    }
20    public IValueParameter<DoubleValue> VarianceParameter {
21      get { return (IValueParameter<DoubleValue>)Parameters[VarianceParameterName]; }
22    }
23    #endregion
24
25    #region properties
26    public double Mean {
27      get { return MeanParameter.Value.Value; }
28    }
29    public double Variance {
30      get { return VarianceParameter.Value.Value; }
31    }
32    #endregion
33
34    [StorableConstructor]
35    protected DeviationTransformation(bool deserializing) : base(deserializing) { }
36    protected DeviationTransformation(Transformation<double> original, Cloner cloner)
37      : base(original, cloner) {
38    }
39    public DeviationTransformation(IEnumerable<string> allowedColumns)
40      : base(allowedColumns) {
41      MultiplierParameter.Hidden = true;
42      AddendParameter.Hidden = true;
43      Parameters.Add(new ValueParameter<DoubleValue>(MeanParameterName, "Mean value for the target deviation.", new DoubleValue(0.0)));
44      Parameters.Add(new ValueParameter<DoubleValue>(VarianceParameterName, "Variance for the target deviation.", new DoubleValue(1.0)));
45    }
46
47    public override IDeepCloneable Clone(Cloner cloner) {
48      return new DeviationTransformation(this, cloner);
49    }
50
51    public override IEnumerable<double> Apply(IEnumerable<double> data) {
52      ConfigureParameters(data);
53      return base.Apply(data);
54    }
55
56    public override bool Check(IEnumerable<double> data, out string errorMsg) {
57      ConfigureParameters(data);
58      return base.Check(data, out errorMsg);
59    }
60
61    protected void ConfigureParameters(IEnumerable<double> data) {
62      double standardDeviation = data.StandardDeviation();
63      double middle = data.Average();
64      // TODO:
65      // http://en.wikipedia.org/wiki/Standard_deviation
66      // http://www.statistics4u.info/fundstat_germ/ee_ztransform.html
67      // https://www.uni-due.de/~bm0061/vorl12.pdf p5
68      throw new NotImplementedException();
69    }
70
71  }
72}
Note: See TracBrowser for help on using the repository browser.