Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/15 15:32:12 (9 years ago)
Author:
dglaser
Message:

#2388: Merged trunk into HiveStatistics branch

Location:
branches/HiveStatistics/sources
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveStatistics/sources

  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis

  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs

    r12012 r12689  
    105105      TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMSE : double.NaN;
    106106
    107       double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    108       TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
    109       double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    110       TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
     107      double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     108      TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR*trainingR : double.NaN;
     109      double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     110      TestRSquared = errorState == OnlineCalculatorError.None ? testR*testR : double.NaN;
    111111
    112112      double trainingNormalizedGini = NormalizedGiniCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs

    r12586 r12689  
    229229      TestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN;
    230230
    231       double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    232       TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
    233       double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    234       TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
     231      double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     232      TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR*trainingR : double.NaN;
     233      double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     234      TestRSquared = errorState == OnlineCalculatorError.None ? testR*testR : double.NaN;
    235235
    236236      double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisResults.cs

    r12012 r12689  
    394394      double trainingMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    395395      PrognosisTrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMAE : double.NaN;
    396       double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    397       PrognosisTrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
     396      double trainingR = OnlinePearsonsRCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
     397      PrognosisTrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR*trainingR : double.NaN;
    398398      double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    399399      PrognosisTrainingRelativeError = errorState == OnlineCalculatorError.None ? trainingRelError : double.NaN;
     
    430430      double testMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    431431      PrognosisTestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN;
    432       double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    433       PrognosisTestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
     432      double testR = OnlinePearsonsRCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
     433      PrognosisTestRSquared = errorState == OnlineCalculatorError.None ? testR*testR : double.NaN;
    434434      double testRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    435435      PrognosisTestRelativeError = errorState == OnlineCalculatorError.None ? testRelError : double.NaN;
  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/CopyColumnTransformation.cs

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

    r11114 r12689  
    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
  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LinearTransformation.cs

    r12012 r12689  
    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;
  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LogarithmicTransformation.cs

    r11114 r12689  
    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
  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/PowerTransformation.cs

    r11114 r12689  
    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
  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ReciprocalTransformation.cs

    r11114 r12689  
    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
  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ShiftStandardDistributionTransformation.cs

    r11114 r12689  
    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;
  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/ShiftToRangeTransformation.cs

    r11114 r12689  
    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 {
  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/Transformation.cs

    r12012 r12689  
    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";
  • branches/HiveStatistics/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/DependencyCalculator/PearsonsRSquaredDependenceCalculator.cs

    r12012 r12689  
    3232
    3333    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
    34       return OnlinePearsonsRSquaredCalculator.Calculate(originalValues, estimatedValues, out errorState);
     34      var r = OnlinePearsonsRCalculator.Calculate(originalValues, estimatedValues, out errorState);
     35      return r * r;
    3536    }
    3637  }
Note: See TracChangeset for help on using the changeset viewer.