Changeset 15939 for branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation
- Timestamp:
- 05/21/18 15:24:15 (7 years ago)
- Location:
- branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LinearTransformation.cs
r15938 r15939 74 74 : base(deserializing) { 75 75 } 76 77 [StorableHook(HookType.AfterDeserialization)] 78 private void AfterDeserialization() { 79 if (Parameters.TryGetValue("Slope", out IParameter slopeParameter)) { 80 Parameters.Add(new FixedValueParameter<DoubleValue>("Scale", "Multiplicative factor (Slope)", ((IValueParameter<DoubleValue>)slopeParameter).Value)); 81 Parameters.Remove("Slope"); 82 } 83 if (Parameters.TryGetValue("Intercept", out IParameter interceptParameter)) { 84 Parameters.Add(new FixedValueParameter<DoubleValue>("Offset", "Additive factor (Intercept)", ((IValueParameter<DoubleValue>)interceptParameter).Value)); 85 Parameters.Remove("Intercept"); 86 } 87 } 76 88 #endregion 89 77 90 78 91 public override IEnumerable<double> Apply(IEnumerable<double> data) { -
branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LogarithmTransformation.cs
r15938 r15939 71 71 : base(deserializing) { 72 72 } 73 [StorableHook(HookType.AfterDeserialization)] 74 private void AfterDeserialization() { 75 if (!Parameters.ContainsKey("Offset")) 76 Parameters.Add(new FixedValueParameter<DoubleValue>("Offset", "Offset before the logarithm", new DoubleValue(0.0))); 77 } 73 78 #endregion 79 74 80 75 81 public override bool Check(IEnumerable<double> data, out string errorMessage) { … … 95 101 96 102 public static IEnumerable<double> InverseApply(IEnumerable<double> data, double @base = Math.E, double offset = 0.0) { 97 return ExponentialTransformation. InverseApply(data, @base).Select(x => x - offset);103 return ExponentialTransformation.Apply(data, @base).Select(x => x - offset); 98 104 } 99 105 } -
branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/RescaleTransformation.cs
r15938 r15939 121 121 if (double.IsNaN(originalMax)) originalMax = data.Max(); 122 122 123 GetLinearTransformationParameters(targetMin, targetMax, originalMin, originalMax, out double scale, out double offset); 123 var originalRange = originalMax - originalMin; 124 var targetRange = targetMax - targetMin; 124 125 125 return LinearTransformation.Apply(data, scale, offset); 126 return data 127 .Select(x => (x - originalMin) / originalRange) // scale to [0-1] 128 .Select(x => x * targetRange + targetMin); 126 129 } 127 130 128 131 public static IEnumerable<double> InverseApply(IEnumerable<double> data, double targetMin, double targetMax, double originalMin, double originalMax) { 129 GetLinearTransformationParameters(targetMin, targetMax, originalMin, originalMax, out double scale, out double offset); 130 131 return LinearTransformation.InverseApply(data, scale, offset); 132 } 133 134 private static void GetLinearTransformationParameters(double targetMin, double targetMax, double originalMin, double originalMax, 135 out double scale, out double offset) { 136 var originalRange = originalMax - originalMin; 137 var targetRange = targetMax - targetMin; 138 139 scale = targetRange / originalRange; 140 offset = targetMin - originalMin * scale; 132 return Apply(data, originalMin, originalMax, targetMin, targetMax); 141 133 } 142 134 }
Note: See TracChangeset
for help on using the changeset viewer.