Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/15 09:50:00 (9 years ago)
Author:
gkronber
Message:

#2415: merged r12612 from trunk to stable

Location:
stable
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis

  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/CopyColumnTransformation.cs

    r12009 r12667  
    2929
    3030namespace HeuristicLab.Problems.DataAnalysis {
     31  [StorableClass]
    3132  [Item("CopyColumnTransformation", "Represents a transformation which represents a copied Column.")]
    3233  public class CopyColumnTransformation : Transformation {
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ExponentialTransformation.cs

    r11114 r12667  
    11using System;
    22using System.Collections.Generic;
     3using System.Linq;
    34using HeuristicLab.Common;
    45using HeuristicLab.Core;
     
    89
    910namespace HeuristicLab.Problems.DataAnalysis {
     11  [StorableClass]
    1012  [Item("Exponential Transformation", "f(x) = b ^ x | Represents a exponential transformation.")]
    1113  public class ExponentialTransformation : Transformation<double> {
     
    4446
    4547    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));
    4949    }
    5050
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LinearTransformation.cs

    r12009 r12667  
    3131
    3232namespace HeuristicLab.Problems.DataAnalysis {
     33  [StorableClass]
    3334  [Item("Linear Transformation", "f(x) = k * x + d | Represents a linear transformation with multiplication and addition.")]
    3435  public class LinearTransformation : Transformation<double> {
     
    8081
    8182    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);
    8386    }
    8487
    8588    public override bool Check(IEnumerable<double> data, out string errorMsg) {
    8689      errorMsg = null;
    87       if (Multiplier == 0.0) {
     90      if (Multiplier.IsAlmost(0.0)) {
    8891        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);
    8992        return false;
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LogarithmicTransformation.cs

    r11114 r12667  
    99
    1010namespace HeuristicLab.Problems.DataAnalysis {
     11  [StorableClass]
    1112  [Item("Logarithmic Transformation", "f(x) = log(x, b) | Represents a logarithmic transformation.")]
    1213  public class LogarithmicTransformation : Transformation<double> {
     
    4344
    4445    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);
    5148    }
    5249
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/PowerTransformation.cs

    r11114 r12667  
    11using System;
    22using System.Collections.Generic;
     3using System.Linq;
    34using HeuristicLab.Common;
    45using HeuristicLab.Core;
     
    89
    910namespace HeuristicLab.Problems.DataAnalysis {
     11  [StorableClass]
    1012  [Item("Power Transformation", "f(x) = x ^ exp | Represents a power transformation.")]
    1113  public class PowerTransformation : Transformation<double> {
     
    4244
    4345    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));
    4747    }
    4848
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ReciprocalTransformation.cs

    r11114 r12667  
    77using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    88namespace HeuristicLab.Problems.DataAnalysis {
     9  [StorableClass]
    910  [Item("Reciprocal Transformation", "f(x) = 1 / x | Represents a reciprocal transformation.")]
    1011  public class ReciprocalTransformation : Transformation<double> {
     
    1617    #endregion
    1718
    18     //TODO: is a special case of Linear
    1919    [StorableConstructor]
    2020    protected ReciprocalTransformation(bool deserializing) : base(deserializing) { }
     
    3131
    3232    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);
    3934    }
    4035
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ShiftStandardDistributionTransformation.cs

    r11114 r12667  
    88
    99namespace HeuristicLab.Problems.DataAnalysis {
     10  [StorableClass]
    1011  [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")]
    1112  public class ShiftStandardDistributionTransformation : Transformation<double> {
     
    6970    }
    7071
    71     // http://en.wikipedia.org/wiki/Standard_deviation
    72     // http://www.statistics4u.info/fundstat_germ/ee_ztransform.html
    73     // https://www.uni-due.de/~bm0061/vorl12.pdf p5
    7472    public override IEnumerable<double> Apply(IEnumerable<double> data) {
    7573      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;
    8176      }
    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);
    8784    }
    8885
     
    9087      ConfigureParameters(data);
    9188      errorMsg = "";
    92       if (OriginalStandardDeviation == 0.0) {
     89      if (OriginalStandardDeviation.IsAlmost(0.0)) {
    9390        errorMsg = "Standard deviaton for the original data is 0.0, Transformation cannot be applied onto these values.";
    9491        return false;
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ShiftToRangeTransformation.cs

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

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