Free cookie consent management tool by TermsFeed Policy Generator

# Changeset 12612

Ignore:
Timestamp:
07/06/15 15:58:16 (8 years ago)
Message:

#2415: added StorableClass attribute to transformation functions (+code improvements)

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations
Files:
9 edited

Unmodified
Removed
• ## trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/CopyColumnTransformation.cs

 r12012 namespace HeuristicLab.Problems.DataAnalysis { [StorableClass] [Item("CopyColumnTransformation", "Represents a transformation which represents a copied Column.")] public class CopyColumnTransformation : Transformation {
• ## trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ExponentialTransformation.cs

 r11114 ﻿using System; using System.Collections.Generic; using System.Linq; using HeuristicLab.Common; using HeuristicLab.Core; namespace HeuristicLab.Problems.DataAnalysis { [StorableClass] [Item("Exponential Transformation", "f(x) = b ^ x | Represents a exponential transformation.")] public class ExponentialTransformation : Transformation { public override IEnumerable Apply(IEnumerable data) { foreach (double d in data) { yield return Math.Pow(Base, d); } return data.Select(d => Math.Pow(Base, d)); }
• ## trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LinearTransformation.cs

 r12012 namespace HeuristicLab.Problems.DataAnalysis { [StorableClass] [Item("Linear Transformation", "f(x) = k * x + d | Represents a linear transformation with multiplication and addition.")] public class LinearTransformation : Transformation { public override IEnumerable Apply(IEnumerable data) { return data.Select(e => e * Multiplier + Addend); var m = Multiplier; var a = Addend; return data.Select(e => e * m + a); } public override bool Check(IEnumerable data, out string errorMsg) { errorMsg = null; if (Multiplier == 0.0) { if (Multiplier.IsAlmost(0.0)) { errorMsg = String.Format("Multiplicand is 0, all {0} entries will be set to {1}. Inverse apply will not be possible (division by 0).", data.Count(), Addend); return false;
• ## trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LogarithmicTransformation.cs

 r11114 namespace HeuristicLab.Problems.DataAnalysis { [StorableClass] [Item("Logarithmic Transformation", "f(x) = log(x, b) | Represents a logarithmic transformation.")] public class LogarithmicTransformation : Transformation { public override IEnumerable Apply(IEnumerable data) { foreach (double i in data) { if (i > 0.0) yield return Math.Log(i, Base); else yield return i; } var b = Base; return data.Select(d => d > 0.0 ? Math.Log(d, b) : d); }
• ## trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/PowerTransformation.cs

 r11114 ﻿using System; using System.Collections.Generic; using System.Linq; using HeuristicLab.Common; using HeuristicLab.Core; namespace HeuristicLab.Problems.DataAnalysis { [StorableClass] [Item("Power Transformation", "f(x) = x ^ exp | Represents a power transformation.")] public class PowerTransformation : Transformation { public override IEnumerable Apply(IEnumerable data) { foreach (double i in data) { yield return Math.Pow(i, Exponent); } return data.Select(i => Math.Pow(i, Exponent)); }
• ## trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ReciprocalTransformation.cs

 r11114 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Problems.DataAnalysis { [StorableClass] [Item("Reciprocal Transformation", "f(x) = 1 / x | Represents a reciprocal transformation.")] public class ReciprocalTransformation : Transformation { #endregion //TODO: is a special case of Linear [StorableConstructor] protected ReciprocalTransformation(bool deserializing) : base(deserializing) { } public override IEnumerable Apply(IEnumerable data) { foreach (double i in data) { if (i > 0.0) yield return 1.0 / i; else yield return i; } return data.Select(d => d > 0 ? 1.0 / d : d); }
• ## trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ShiftStandardDistributionTransformation.cs

 r11114 namespace HeuristicLab.Problems.DataAnalysis { [StorableClass] [Item("Shift Standard Distribution Transformation", "f(x) = ((x - m_org) / s_org ) * s_tar + m_tar | Represents Transformation to unit standard deviation and additional linear transformation to a target Mean and Standard deviation")] public class ShiftStandardDistributionTransformation : Transformation { } // http://en.wikipedia.org/wiki/Standard_deviation // http://www.statistics4u.info/fundstat_germ/ee_ztransform.html // https://www.uni-due.de/~bm0061/vorl12.pdf p5 public override IEnumerable Apply(IEnumerable data) { ConfigureParameters(data); if (OriginalStandardDeviation == 0.0) { foreach (var e in data) { yield return e; } yield break; if (OriginalStandardDeviation.IsAlmost(0.0)) { return data; } foreach (var e in data) { double unitNormalDistributedValue = (e - OriginalMean) / OriginalStandardDeviation; yield return unitNormalDistributedValue * StandardDeviation + Mean; } var old_m = OriginalMean; var old_s = OriginalStandardDeviation; var m = Mean; var s = StandardDeviation; return data .Select(d => (d - old_m) / old_s) // standardized .Select(d => d * s + m); } ConfigureParameters(data); errorMsg = ""; if (OriginalStandardDeviation == 0.0) { if (OriginalStandardDeviation.IsAlmost(0.0)) { errorMsg = "Standard deviaton for the original data is 0.0, Transformation cannot be applied onto these values."; return false;
• ## trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ShiftToRangeTransformation.cs

 r11114 namespace HeuristicLab.Problems.DataAnalysis { [StorableClass] [Item("Shift to Range Transformation", "f(x) = k * x + d, start <= f(x) <= end | Represents a linear Transformation using Parameters defining a target range")] public class ShiftToRangeTransformation : LinearTransformation {
• ## trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/Transformation.cs

 r12012 [Item("Transformation", "Represents the base class for a transformation.")] [StorableClass] public abstract class Transformation : ParameterizedNamedItem, ITransformation { protected const string ColumnParameterName = "Column";
Note: See TracChangeset for help on using the changeset viewer.