Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/23/12 16:29:21 (12 years ago)
Author:
sforsten
Message:

#1942: merged r8690:8840 from trunk into branch

Location:
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis
Files:
1 deleted
17 edited
10 copied

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis

  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs

    r7921 r8842  
    193193      if (values == null) throw new ArgumentException("The varialbe " + variableName + " is not a double variable.");
    194194
    195       foreach (int index in rows)
    196         yield return values[index];
     195      return rows.Select(index => values[index]);
    197196    }
    198197
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r8715 r8842  
    156156  </ItemGroup>
    157157  <ItemGroup>
     158    <Compile Include="DatasetExtensions.cs" />
    158159    <Compile Include="DoubleLimit.cs" />
    159160    <Compile Include="Implementation\Classification\ClassificationEnsembleModel.cs">
     
    170171    <Compile Include="Implementation\Clustering\ClusteringProblemData.cs" />
    171172    <Compile Include="Implementation\Clustering\ClusteringSolution.cs" />
    172     <Compile Include="Implementation\FeatureCorrelation\FeatureCorrelationCalculator.cs" />
    173     <Compile Include="Implementation\FeatureCorrelation\FeatureCorrelationEnums.cs" />
    174173    <Compile Include="Implementation\Regression\ConstantRegressionModel.cs" />
    175174    <Compile Include="Implementation\Regression\ConstantRegressionSolution.cs" />
     
    179178    </Compile>
    180179    <Compile Include="Implementation\Regression\RegressionEnsembleSolution.cs" />
     180    <Compile Include="Implementation\TimeSeriesPrognosis\Models\ConstantTimeSeriesPrognosisModel.cs" />
     181    <Compile Include="Implementation\TimeSeriesPrognosis\Models\TimeSeriesPrognosisAutoRegressiveModel.cs" />
     182    <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisProblem.cs" />
     183    <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisProblemData.cs" />
     184    <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisResults.cs" />
     185    <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisSolution.cs" />
     186    <Compile Include="Implementation\TimeSeriesPrognosis\TimeSeriesPrognosisSolutionBase.cs" />
    181187    <Compile Include="Interfaces\Classification\IClassificationEnsembleModel.cs">
    182188      <SubType>Code</SubType>
     
    186192    </Compile>
    187193    <Compile Include="Interfaces\Classification\IDiscriminantFunctionThresholdCalculator.cs" />
     194    <Compile Include="Interfaces\IDependencyCalculator.cs" />
    188195    <Compile Include="Interfaces\Regression\IRegressionEnsembleModel.cs">
    189196      <SubType>Code</SubType>
     
    191198    <Compile Include="Interfaces\Regression\IRegressionEnsembleSolution.cs" />
    192199    <Compile Include="Implementation\Regression\RegressionSolutionBase.cs" />
     200    <Compile Include="Interfaces\TimeSeriesPrognosis\IOnlineTimeSeriesCalculator.cs" />
     201    <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisModel.cs" />
     202    <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisProblem.cs" />
     203    <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisProblemData.cs" />
     204    <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisSolution.cs" />
     205    <Compile Include="OnlineCalculators\AutoCorrelationCalculator.cs" />
    193206    <Compile Include="OnlineCalculators\OnlineBoundedMeanSquaredErrorCalculator.cs" />
    194207    <Compile Include="OnlineCalculators\HoeffdingsDependenceCalculator.cs" />
     208    <Compile Include="OnlineCalculators\OnlineDirectionalSymmetryCalculator.cs" />
    195209    <Compile Include="OnlineCalculators\OnlineMaxAbsoluteErrorCalculator.cs" />
    196210    <Compile Include="OnlineCalculators\OnlineMeanErrorCalculator.cs" />
     
    231245    <Compile Include="OnlineCalculators\OnlinePearsonsRSquaredCalculator.cs" />
    232246    <Compile Include="Implementation\Regression\RegressionSolution.cs" />
     247    <Compile Include="OnlineCalculators\OnlineTheilsUStatisticCalculator.cs" />
     248    <Compile Include="OnlineCalculators\OnlineWeightedDirectionalSymmetryCalculator.cs" />
     249    <Compile Include="OnlineCalculators\PearsonsRDependenceCalculator.cs" />
     250    <Compile Include="OnlineCalculators\PearsonsRSquaredDependenceCalculator.cs" />
    233251    <Compile Include="OnlineCalculators\SpearmansRankCorrelationCoefficientCalculator.cs" />
    234252    <Compile Include="Plugin.cs" />
     
    260278    </BootstrapperPackage>
    261279  </ItemGroup>
     280  <ItemGroup />
    262281  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    263282  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs

    r8528 r8842  
    3636  [Item("Classification Ensemble Solution", "A classification solution that contains an ensemble of multiple classification models")]
    3737  [Creatable("Data Analysis - Ensembles")]
    38   public sealed class ClassificationEnsembleSolution : ClassificationSolution, IClassificationEnsembleSolution {
     38  public sealed class ClassificationEnsembleSolution : ClassificationSolutionBase, IClassificationEnsembleSolution {
    3939    private readonly Dictionary<int, double> trainingEvaluationCache = new Dictionary<int, double>();
    4040    private readonly Dictionary<int, double> testEvaluationCache = new Dictionary<int, double>();
     41    private readonly Dictionary<int, double> evaluationCache = new Dictionary<int, double>();
    4142
    4243    public new IClassificationEnsembleModel Model {
     
    153154    }
    154155
    155     protected override void RecalculateResults() {
    156       CalculateResults();
    157     }
    158156
    159157    #region Evaluation
     158    public override IEnumerable<double> EstimatedClassValues {
     159      get { return GetEstimatedClassValues(Enumerable.Range(0, ProblemData.Dataset.Rows)); }
     160    }
     161
    160162    public override IEnumerable<double> EstimatedTrainingClassValues {
    161163      get {
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs

    r8715 r8842  
    280280      TestPartition.Start = classificationProblemData.TestPartition.Start;
    281281      TestPartition.End = classificationProblemData.TestPartition.End;
     282
     283      for (int i = 0; i < classificationProblemData.ClassNames.Count(); i++)
     284        ClassNamesParameter.Value[i, 0] = classificationProblemData.ClassNames.ElementAt(i);
     285
     286      for (int i = 0; i < Classes; i++) {
     287        for (int j = 0; j < Classes; j++) {
     288          ClassificationPenaltiesParameter.Value[i, j] = classificationProblemData.GetClassificationPenalty(ClassValuesCache[i], ClassValuesCache[j]);
     289        }
     290      }
    282291    }
    283292
     
    291300      Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, ""));
    292301
     302      RegisterParameterEvents();
    293303      ResetTargetVariableDependentMembers();
    294       RegisterParameterEvents();
    295304    }
    296305
     
    374383      TargetVariableParameter.ValueChanged += new EventHandler(TargetVariableParameter_ValueChanged);
    375384      ClassNamesParameter.Value.Reset += new EventHandler(Parameter_ValueChanged);
    376       ClassNamesParameter.Value.ItemChanged += new EventHandler<EventArgs<int, int>>(MatrixParameter_ItemChanged);
     385      ClassNamesParameter.Value.ItemChanged += new EventHandler<EventArgs<int, int>>(Parameter_ValueChanged);
     386      ClassificationPenaltiesParameter.Value.ItemChanged += new EventHandler<EventArgs<int, int>>(Parameter_ValueChanged);
     387      ClassificationPenaltiesParameter.Value.Reset += new EventHandler(Parameter_ValueChanged);
    377388    }
    378389    private void DeregisterParameterEvents() {
    379390      TargetVariableParameter.ValueChanged -= new EventHandler(TargetVariableParameter_ValueChanged);
    380391      ClassNamesParameter.Value.Reset -= new EventHandler(Parameter_ValueChanged);
    381       ClassNamesParameter.Value.ItemChanged -= new EventHandler<EventArgs<int, int>>(MatrixParameter_ItemChanged);
     392      ClassNamesParameter.Value.ItemChanged -= new EventHandler<EventArgs<int, int>>(Parameter_ValueChanged);
     393      ClassificationPenaltiesParameter.Value.ItemChanged -= new EventHandler<EventArgs<int, int>>(Parameter_ValueChanged);
     394      ClassificationPenaltiesParameter.Value.Reset -= new EventHandler(Parameter_ValueChanged);
    382395    }
    383396
     
    390403    private void Parameter_ValueChanged(object sender, EventArgs e) {
    391404      classNamesCache = null;
    392       OnChanged();
    393     }
    394     private void MatrixParameter_ItemChanged(object sender, EventArgs<int, int> e) {
    395       classNamesCache = null;
     405      ClassificationPenaltiesParameter.Value.RowNames = ClassNames.Select(name => "Actual " + name);
     406      ClassificationPenaltiesParameter.Value.ColumnNames = ClassNames.Select(name => "Estimated " + name);
    396407      OnChanged();
    397408    }
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs

    r8174 r8842  
    4545      : base(model, problemData) {
    4646      evaluationCache = new Dictionary<int, double>(problemData.Dataset.Rows);
     47      CalculateClassificationResults();
    4748    }
    4849
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs

    r8139 r8842  
    8585    }
    8686
    87     protected void CalculateResults() {
     87    protected void CalculateClassificationResults() {
    8888      double[] estimatedTrainingClassValues = EstimatedTrainingClassValues.ToArray(); // cache values
    8989      double[] originalTrainingClassValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToArray();
     
    114114
    115115    public abstract IEnumerable<double> GetEstimatedClassValues(IEnumerable<int> rows);
     116
     117    protected override void RecalculateResults() {
     118      CalculateClassificationResults();
     119    }
    116120  }
    117121}
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolution.cs

    r8684 r8842  
    5151      valueEvaluationCache = new Dictionary<int, double>();
    5252      classValueEvaluationCache = new Dictionary<int, double>();
    53       CalculateDiscriminantFunctionClassificationResults();
     53      CalculateRegressionResults();
     54      CalculateClassificationResults();
    5455    }
    5556
     
    117118      base.OnProblemDataChanged();
    118119    }
    119 
    120 
    121     private void CalculateDiscriminantFunctionClassificationResults() {
    122       CalculateResults();
    123       CalculateRegressionResults();
    124     }
    125 
    126     protected override void RecalculateResults() {
    127       CalculateDiscriminantFunctionClassificationResults();
    128     }
    129120  }
    130121}
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs

    r8552 r8842  
    8585      Add(new Result(TrainingRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue()));
    8686      Add(new Result(TestRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue()));
    87 
    8887      RegisterEventHandler();
    8988    }
     
    139138
    140139    public abstract IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows);
     140
     141    protected override void RecalculateResults() {
     142      base.RecalculateResults();
     143      CalculateRegressionResults();
     144    }
    141145  }
    142146}
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblem.cs

    r7823 r8842  
    6666    }
    6767
     68    protected DataAnalysisProblem(T problemData)
     69      : this() {
     70      ProblemData = problemData;
     71    }
     72
    6873    [StorableHook(HookType.AfterDeserialization)]
    6974    private void AfterDeserialization() {
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ConstantRegressionModel.cs

    r8528 r8842  
    3030  public class ConstantRegressionModel : NamedItem, IRegressionModel {
    3131    [Storable]
    32     private double constant;
     32    protected double constant;
    3333    public double Constant {
    3434      get { return constant; }
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleSolution.cs

    r8174 r8842  
    3636  [Item("Regression Ensemble Solution", "A regression solution that contains an ensemble of multiple regression models")]
    3737  [Creatable("Data Analysis - Ensembles")]
    38   public sealed class RegressionEnsembleSolution : RegressionSolution, IRegressionEnsembleSolution {
     38  public sealed class RegressionEnsembleSolution : RegressionSolutionBase, IRegressionEnsembleSolution {
    3939    private readonly Dictionary<int, double> trainingEvaluationCache = new Dictionary<int, double>();
    4040    private readonly Dictionary<int, double> testEvaluationCache = new Dictionary<int, double>();
     41    private readonly Dictionary<int, double> evaluationCache = new Dictionary<int, double>();
    4142
    4243    public new IRegressionEnsembleModel Model {
     
    155156    }
    156157
    157     protected override void RecalculateResults() {
    158       CalculateResults();
    159     }
    160 
    161158    #region Evaluation
     159    public override IEnumerable<double> EstimatedValues {
     160      get { return GetEstimatedValues(Enumerable.Range(0, ProblemData.Dataset.Rows)); }
     161    }
     162
    162163    public override IEnumerable<double> EstimatedTrainingValues {
    163164      get {
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblem.cs

    r7823 r8842  
    3636    public override IDeepCloneable Clone(Cloner cloner) { return new RegressionProblem(this, cloner); }
    3737
    38     public RegressionProblem()
    39       : base() {
    40       ProblemData = new RegressionProblemData();
    41     }
     38    public RegressionProblem() : base(new RegressionProblemData()) { }
     39
    4240  }
    4341}
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs

    r8139 r8842  
    4545      : base(model, problemData) {
    4646      evaluationCache = new Dictionary<int, double>(problemData.Dataset.Rows);
     47      CalculateRegressionResults();
    4748    }
    4849
    49     protected override void RecalculateResults() {
    50       CalculateResults();
    51     }
    5250
    5351    public override IEnumerable<double> EstimatedValues {
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs

    r8139 r8842  
    2929  [StorableClass]
    3030  public abstract class RegressionSolutionBase : DataAnalysisSolution, IRegressionSolution {
    31     private const string TrainingMeanSquaredErrorResultName = "Mean squared error (training)";
    32     private const string TestMeanSquaredErrorResultName = "Mean squared error (test)";
    33     private const string TrainingMeanAbsoluteErrorResultName = "Mean absolute error (training)";
    34     private const string TestMeanAbsoluteErrorResultName = "Mean absolute error (test)";
    35     private const string TrainingSquaredCorrelationResultName = "Pearson's R² (training)";
    36     private const string TestSquaredCorrelationResultName = "Pearson's R² (test)";
    37     private const string TrainingRelativeErrorResultName = "Average relative error (training)";
    38     private const string TestRelativeErrorResultName = "Average relative error (test)";
    39     private const string TrainingNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (training)";
    40     private const string TestNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (test)";
    41     private const string TrainingMeanErrorResultName = "Mean error (training)";
    42     private const string TestMeanErrorResultName = "Mean error (test)";
     31    protected const string TrainingMeanSquaredErrorResultName = "Mean squared error (training)";
     32    protected const string TestMeanSquaredErrorResultName = "Mean squared error (test)";
     33    protected const string TrainingMeanAbsoluteErrorResultName = "Mean absolute error (training)";
     34    protected const string TestMeanAbsoluteErrorResultName = "Mean absolute error (test)";
     35    protected const string TrainingSquaredCorrelationResultName = "Pearson's R² (training)";
     36    protected const string TestSquaredCorrelationResultName = "Pearson's R² (test)";
     37    protected const string TrainingRelativeErrorResultName = "Average relative error (training)";
     38    protected const string TestRelativeErrorResultName = "Average relative error (test)";
     39    protected const string TrainingNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (training)";
     40    protected const string TestNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (test)";
     41    protected const string TrainingMeanErrorResultName = "Mean error (training)";
     42    protected const string TestMeanErrorResultName = "Mean error (test)";
     43
     44    protected const string TrainingMeanSquaredErrorResultDescription = "Mean of squared errors of the model on the training partition";
     45    protected const string TestMeanSquaredErrorResultDescription = "Mean of squared errors of the model on the test partition";
     46    protected const string TrainingMeanAbsoluteErrorResultDescription = "Mean of absolute errors of the model on the training partition";
     47    protected const string TestMeanAbsoluteErrorResultDescription = "Mean of absolute errors of the model on the test partition";
     48    protected const string TrainingSquaredCorrelationResultDescription = "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition";
     49    protected const string TestSquaredCorrelationResultDescription = "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition";
     50    protected const string TrainingRelativeErrorResultDescription = "Average of the relative errors of the model output and the actual values on the training partition";
     51    protected const string TestRelativeErrorResultDescription = "Average of the relative errors of the model output and the actual values on the test partition";
     52    protected const string TrainingNormalizedMeanSquaredErrorResultDescription = "Normalized mean of squared errors of the model on the training partition";
     53    protected const string TestNormalizedMeanSquaredErrorResultDescription = "Normalized mean of squared errors of the model on the test partition";
     54    protected const string TrainingMeanErrorResultDescription = "Mean of errors of the model on the training partition";
     55    protected const string TestMeanErrorResultDescription = "Mean of errors of the model on the test partition";
    4356
    4457    public new IRegressionModel Model {
     
    115128    protected RegressionSolutionBase(IRegressionModel model, IRegressionProblemData problemData)
    116129      : base(model, problemData) {
    117       Add(new Result(TrainingMeanSquaredErrorResultName, "Mean of squared errors of the model on the training partition", new DoubleValue()));
    118       Add(new Result(TestMeanSquaredErrorResultName, "Mean of squared errors of the model on the test partition", new DoubleValue()));
    119       Add(new Result(TrainingMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the training partition", new DoubleValue()));
    120       Add(new Result(TestMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the test partition", new DoubleValue()));
    121       Add(new Result(TrainingSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue()));
    122       Add(new Result(TestSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue()));
    123       Add(new Result(TrainingRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the training partition", new PercentValue()));
    124       Add(new Result(TestRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the test partition", new PercentValue()));
    125       Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the training partition", new DoubleValue()));
    126       Add(new Result(TestNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the test partition", new DoubleValue()));
    127       Add(new Result(TrainingMeanErrorResultName, "Mean of errors of the model on the training partition", new DoubleValue()));
    128       Add(new Result(TestMeanErrorResultName, "Mean of errors of the model on the test partition", new DoubleValue()));
     130      Add(new Result(TrainingMeanSquaredErrorResultName, TrainingMeanSquaredErrorResultDescription, new DoubleValue()));
     131      Add(new Result(TestMeanSquaredErrorResultName, TestMeanSquaredErrorResultDescription, new DoubleValue()));
     132      Add(new Result(TrainingMeanAbsoluteErrorResultName, TrainingMeanAbsoluteErrorResultDescription, new DoubleValue()));
     133      Add(new Result(TestMeanAbsoluteErrorResultName, TestMeanAbsoluteErrorResultDescription, new DoubleValue()));
     134      Add(new Result(TrainingSquaredCorrelationResultName, TrainingSquaredCorrelationResultDescription, new DoubleValue()));
     135      Add(new Result(TestSquaredCorrelationResultName, TestSquaredCorrelationResultDescription, new DoubleValue()));
     136      Add(new Result(TrainingRelativeErrorResultName, TrainingRelativeErrorResultDescription, new PercentValue()));
     137      Add(new Result(TestRelativeErrorResultName, TestRelativeErrorResultDescription, new PercentValue()));
     138      Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, TrainingNormalizedMeanSquaredErrorResultDescription, new DoubleValue()));
     139      Add(new Result(TestNormalizedMeanSquaredErrorResultName, TestNormalizedMeanSquaredErrorResultDescription, new DoubleValue()));
     140      Add(new Result(TrainingMeanErrorResultName, TrainingMeanErrorResultDescription, new DoubleValue()));
     141      Add(new Result(TestMeanErrorResultName, TestMeanErrorResultDescription, new DoubleValue()));
    129142    }
    130143
     
    164177    }
    165178
    166     protected void CalculateResults() {
     179    protected override void RecalculateResults() {
     180      CalculateRegressionResults();
     181    }
     182
     183    protected void CalculateRegressionResults() {
    167184      IEnumerable<double> estimatedTrainingValues = EstimatedTrainingValues; // cache values
    168185      IEnumerable<double> originalTrainingValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices);
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/HoeffdingsDependenceCalculator.cs

    r8542 r8842  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Data;
    2526
    2627namespace HeuristicLab.Problems.DataAnalysis {
    27   public class HoeffdingsDependenceCalculator {
     28  public class HoeffdingsDependenceCalculator : IDependencyCalculator {
    2829
    29     public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
     30    public DoubleRange Interval { get { return new DoubleRange(1.0, -0.5); } }
     31
     32    public string Name { get { return "Hoeffdings Dependence"; } }
     33
     34    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
     35      return HoeffdingsDependenceCalculator.CalculateHoeffdings(originalValues, estimatedValues, out errorState);
     36    }
     37
     38    public static double CalculateHoeffdings(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
    3039      double d = HoeffD(originalValues, estimatedValues, out errorState);
    3140      if (errorState != OnlineCalculatorError.None) return double.NaN;
  • branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/SpearmansRankCorrelationCoefficientCalculator.cs

    r8689 r8842  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
     24using HeuristicLab.Data;
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis {
    27   public class SpearmansRankCorrelationCoefficientCalculator {
     27  public class SpearmansRankCorrelationCoefficientCalculator : IDependencyCalculator {
    2828
    29     public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
     29    public DoubleRange Interval { get { return new DoubleRange(1.0, -1.0); } }
     30
     31    public string Name { get { return "Spearmans Rank"; } }
     32
     33    public double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
     34      return SpearmansRankCorrelationCoefficientCalculator.CalculateSpearmansRank(originalValues, estimatedValues, out errorState);
     35    }
     36
     37    public static double CalculateSpearmansRank(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
    3038      double rs = double.NaN;
    3139      try {
    32         rs = alglib.basestat.spearmancorr2(originalValues.ToArray(), estimatedValues.ToArray(), originalValues.Count());
     40        var original = originalValues.ToArray();
     41        var estimated = estimatedValues.ToArray();
     42        rs = alglib.basestat.spearmancorr2(original, estimated, original.Length);
    3343        errorState = OnlineCalculatorError.None;
    3444      }
    35       catch (Exception ex) {
     45      catch (alglib.alglibexception) {
    3646        errorState = OnlineCalculatorError.InvalidValueAdded;
    3747      }
Note: See TracChangeset for help on using the changeset viewer.