- Timestamp:
- 07/06/15 15:58:16 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/CopyColumnTransformation.cs
r12012 r12612 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis { 31 [StorableClass] 31 32 [Item("CopyColumnTransformation", "Represents a transformation which represents a copied Column.")] 32 33 public class CopyColumnTransformation : Transformation { -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ExponentialTransformation.cs
r11114 r12612 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Linq; 3 4 using HeuristicLab.Common; 4 5 using HeuristicLab.Core; … … 8 9 9 10 namespace HeuristicLab.Problems.DataAnalysis { 11 [StorableClass] 10 12 [Item("Exponential Transformation", "f(x) = b ^ x | Represents a exponential transformation.")] 11 13 public class ExponentialTransformation : Transformation<double> { … … 44 46 45 47 public override IEnumerable<double> Apply(IEnumerable<double> data) { 46 foreach (double d in data) { 47 yield return Math.Pow(Base, d); 48 } 48 return data.Select(d => Math.Pow(Base, d)); 49 49 } 50 50 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LinearTransformation.cs
r12012 r12612 31 31 32 32 namespace HeuristicLab.Problems.DataAnalysis { 33 [StorableClass] 33 34 [Item("Linear Transformation", "f(x) = k * x + d | Represents a linear transformation with multiplication and addition.")] 34 35 public class LinearTransformation : Transformation<double> { … … 80 81 81 82 public override IEnumerable<double> Apply(IEnumerable<double> data) { 82 return data.Select(e => e * Multiplier + Addend); 83 var m = Multiplier; 84 var a = Addend; 85 return data.Select(e => e * m + a); 83 86 } 84 87 85 88 public override bool Check(IEnumerable<double> data, out string errorMsg) { 86 89 errorMsg = null; 87 if (Multiplier == 0.0) {90 if (Multiplier.IsAlmost(0.0)) { 88 91 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); 89 92 return false; -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LogarithmicTransformation.cs
r11114 r12612 9 9 10 10 namespace HeuristicLab.Problems.DataAnalysis { 11 [StorableClass] 11 12 [Item("Logarithmic Transformation", "f(x) = log(x, b) | Represents a logarithmic transformation.")] 12 13 public class LogarithmicTransformation : Transformation<double> { … … 43 44 44 45 public override IEnumerable<double> Apply(IEnumerable<double> data) { 45 foreach (double i in data) { 46 if (i > 0.0) 47 yield return Math.Log(i, Base); 48 else 49 yield return i; 50 } 46 var b = Base; 47 return data.Select(d => d > 0.0 ? Math.Log(d, b) : d); 51 48 } 52 49 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/PowerTransformation.cs
r11114 r12612 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Linq; 3 4 using HeuristicLab.Common; 4 5 using HeuristicLab.Core; … … 8 9 9 10 namespace HeuristicLab.Problems.DataAnalysis { 11 [StorableClass] 10 12 [Item("Power Transformation", "f(x) = x ^ exp | Represents a power transformation.")] 11 13 public class PowerTransformation : Transformation<double> { … … 42 44 43 45 public override IEnumerable<double> Apply(IEnumerable<double> data) { 44 foreach (double i in data) { 45 yield return Math.Pow(i, Exponent); 46 } 46 return data.Select(i => Math.Pow(i, Exponent)); 47 47 } 48 48 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ReciprocalTransformation.cs
r11114 r12612 7 7 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 8 8 namespace HeuristicLab.Problems.DataAnalysis { 9 [StorableClass] 9 10 [Item("Reciprocal Transformation", "f(x) = 1 / x | Represents a reciprocal transformation.")] 10 11 public class ReciprocalTransformation : Transformation<double> { … … 16 17 #endregion 17 18 18 //TODO: is a special case of Linear19 19 [StorableConstructor] 20 20 protected ReciprocalTransformation(bool deserializing) : base(deserializing) { } … … 31 31 32 32 public override IEnumerable<double> Apply(IEnumerable<double> data) { 33 foreach (double i in data) { 34 if (i > 0.0) 35 yield return 1.0 / i; 36 else 37 yield return i; 38 } 33 return data.Select(d => d > 0 ? 1.0 / d : d); 39 34 } 40 35 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ShiftStandardDistributionTransformation.cs
r11114 r12612 8 8 9 9 namespace HeuristicLab.Problems.DataAnalysis { 10 [StorableClass] 10 11 [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")] 11 12 public class ShiftStandardDistributionTransformation : Transformation<double> { … … 69 70 } 70 71 71 // http://en.wikipedia.org/wiki/Standard_deviation72 // http://www.statistics4u.info/fundstat_germ/ee_ztransform.html73 // https://www.uni-due.de/~bm0061/vorl12.pdf p574 72 public override IEnumerable<double> Apply(IEnumerable<double> data) { 75 73 ConfigureParameters(data); 76 if (OriginalStandardDeviation == 0.0) { 77 foreach (var e in data) { 78 yield return e; 79 } 80 yield break; 74 if (OriginalStandardDeviation.IsAlmost(0.0)) { 75 return data; 81 76 } 82 83 foreach (var e in data) { 84 double unitNormalDistributedValue = (e - OriginalMean) / OriginalStandardDeviation; 85 yield return unitNormalDistributedValue * StandardDeviation + Mean; 86 } 77 var old_m = OriginalMean; 78 var old_s = OriginalStandardDeviation; 79 var m = Mean; 80 var s = StandardDeviation; 81 return data 82 .Select(d => (d - old_m) / old_s) // standardized 83 .Select(d => d * s + m); 87 84 } 88 85 … … 90 87 ConfigureParameters(data); 91 88 errorMsg = ""; 92 if (OriginalStandardDeviation == 0.0) {89 if (OriginalStandardDeviation.IsAlmost(0.0)) { 93 90 errorMsg = "Standard deviaton for the original data is 0.0, Transformation cannot be applied onto these values."; 94 91 return false; -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ShiftToRangeTransformation.cs
r11114 r12612 8 8 9 9 namespace HeuristicLab.Problems.DataAnalysis { 10 [StorableClass] 10 11 [Item("Shift to Range Transformation", "f(x) = k * x + d, start <= f(x) <= end | Represents a linear Transformation using Parameters defining a target range")] 11 12 public class ShiftToRangeTransformation : LinearTransformation { -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/Transformation.cs
r12012 r12612 31 31 32 32 [Item("Transformation", "Represents the base class for a transformation.")] 33 [StorableClass]34 33 public abstract class Transformation : ParameterizedNamedItem, ITransformation { 35 34 protected const string ColumnParameterName = "Column";
Note: See TracChangeset
for help on using the changeset viewer.