- Timestamp:
- 10/23/12 16:29:21 (12 years ago)
- Location:
- branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis
- Files:
-
- 1 deleted
- 17 edited
- 10 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
-
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs
r7921 r8842 193 193 if (values == null) throw new ArgumentException("The varialbe " + variableName + " is not a double variable."); 194 194 195 foreach (int index in rows) 196 yield return values[index]; 195 return rows.Select(index => values[index]); 197 196 } 198 197 -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r8715 r8842 156 156 </ItemGroup> 157 157 <ItemGroup> 158 <Compile Include="DatasetExtensions.cs" /> 158 159 <Compile Include="DoubleLimit.cs" /> 159 160 <Compile Include="Implementation\Classification\ClassificationEnsembleModel.cs"> … … 170 171 <Compile Include="Implementation\Clustering\ClusteringProblemData.cs" /> 171 172 <Compile Include="Implementation\Clustering\ClusteringSolution.cs" /> 172 <Compile Include="Implementation\FeatureCorrelation\FeatureCorrelationCalculator.cs" />173 <Compile Include="Implementation\FeatureCorrelation\FeatureCorrelationEnums.cs" />174 173 <Compile Include="Implementation\Regression\ConstantRegressionModel.cs" /> 175 174 <Compile Include="Implementation\Regression\ConstantRegressionSolution.cs" /> … … 179 178 </Compile> 180 179 <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" /> 181 187 <Compile Include="Interfaces\Classification\IClassificationEnsembleModel.cs"> 182 188 <SubType>Code</SubType> … … 186 192 </Compile> 187 193 <Compile Include="Interfaces\Classification\IDiscriminantFunctionThresholdCalculator.cs" /> 194 <Compile Include="Interfaces\IDependencyCalculator.cs" /> 188 195 <Compile Include="Interfaces\Regression\IRegressionEnsembleModel.cs"> 189 196 <SubType>Code</SubType> … … 191 198 <Compile Include="Interfaces\Regression\IRegressionEnsembleSolution.cs" /> 192 199 <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" /> 193 206 <Compile Include="OnlineCalculators\OnlineBoundedMeanSquaredErrorCalculator.cs" /> 194 207 <Compile Include="OnlineCalculators\HoeffdingsDependenceCalculator.cs" /> 208 <Compile Include="OnlineCalculators\OnlineDirectionalSymmetryCalculator.cs" /> 195 209 <Compile Include="OnlineCalculators\OnlineMaxAbsoluteErrorCalculator.cs" /> 196 210 <Compile Include="OnlineCalculators\OnlineMeanErrorCalculator.cs" /> … … 231 245 <Compile Include="OnlineCalculators\OnlinePearsonsRSquaredCalculator.cs" /> 232 246 <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" /> 233 251 <Compile Include="OnlineCalculators\SpearmansRankCorrelationCoefficientCalculator.cs" /> 234 252 <Compile Include="Plugin.cs" /> … … 260 278 </BootstrapperPackage> 261 279 </ItemGroup> 280 <ItemGroup /> 262 281 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 263 282 <!-- 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 36 36 [Item("Classification Ensemble Solution", "A classification solution that contains an ensemble of multiple classification models")] 37 37 [Creatable("Data Analysis - Ensembles")] 38 public sealed class ClassificationEnsembleSolution : ClassificationSolution , IClassificationEnsembleSolution {38 public sealed class ClassificationEnsembleSolution : ClassificationSolutionBase, IClassificationEnsembleSolution { 39 39 private readonly Dictionary<int, double> trainingEvaluationCache = new Dictionary<int, double>(); 40 40 private readonly Dictionary<int, double> testEvaluationCache = new Dictionary<int, double>(); 41 private readonly Dictionary<int, double> evaluationCache = new Dictionary<int, double>(); 41 42 42 43 public new IClassificationEnsembleModel Model { … … 153 154 } 154 155 155 protected override void RecalculateResults() {156 CalculateResults();157 }158 156 159 157 #region Evaluation 158 public override IEnumerable<double> EstimatedClassValues { 159 get { return GetEstimatedClassValues(Enumerable.Range(0, ProblemData.Dataset.Rows)); } 160 } 161 160 162 public override IEnumerable<double> EstimatedTrainingClassValues { 161 163 get { -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs
r8715 r8842 280 280 TestPartition.Start = classificationProblemData.TestPartition.Start; 281 281 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 } 282 291 } 283 292 … … 291 300 Parameters.Add(new FixedValueParameter<DoubleMatrix>(ClassificationPenaltiesParameterName, "")); 292 301 302 RegisterParameterEvents(); 293 303 ResetTargetVariableDependentMembers(); 294 RegisterParameterEvents();295 304 } 296 305 … … 374 383 TargetVariableParameter.ValueChanged += new EventHandler(TargetVariableParameter_ValueChanged); 375 384 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); 377 388 } 378 389 private void DeregisterParameterEvents() { 379 390 TargetVariableParameter.ValueChanged -= new EventHandler(TargetVariableParameter_ValueChanged); 380 391 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); 382 395 } 383 396 … … 390 403 private void Parameter_ValueChanged(object sender, EventArgs e) { 391 404 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); 396 407 OnChanged(); 397 408 } -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs
r8174 r8842 45 45 : base(model, problemData) { 46 46 evaluationCache = new Dictionary<int, double>(problemData.Dataset.Rows); 47 CalculateClassificationResults(); 47 48 } 48 49 -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionBase.cs
r8139 r8842 85 85 } 86 86 87 protected void Calculate Results() {87 protected void CalculateClassificationResults() { 88 88 double[] estimatedTrainingClassValues = EstimatedTrainingClassValues.ToArray(); // cache values 89 89 double[] originalTrainingClassValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToArray(); … … 114 114 115 115 public abstract IEnumerable<double> GetEstimatedClassValues(IEnumerable<int> rows); 116 117 protected override void RecalculateResults() { 118 CalculateClassificationResults(); 119 } 116 120 } 117 121 } -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolution.cs
r8684 r8842 51 51 valueEvaluationCache = new Dictionary<int, double>(); 52 52 classValueEvaluationCache = new Dictionary<int, double>(); 53 CalculateDiscriminantFunctionClassificationResults(); 53 CalculateRegressionResults(); 54 CalculateClassificationResults(); 54 55 } 55 56 … … 117 118 base.OnProblemDataChanged(); 118 119 } 119 120 121 private void CalculateDiscriminantFunctionClassificationResults() {122 CalculateResults();123 CalculateRegressionResults();124 }125 126 protected override void RecalculateResults() {127 CalculateDiscriminantFunctionClassificationResults();128 }129 120 } 130 121 } -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolutionBase.cs
r8552 r8842 85 85 Add(new Result(TrainingRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue())); 86 86 Add(new Result(TestRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue())); 87 88 87 RegisterEventHandler(); 89 88 } … … 139 138 140 139 public abstract IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows); 140 141 protected override void RecalculateResults() { 142 base.RecalculateResults(); 143 CalculateRegressionResults(); 144 } 141 145 } 142 146 } -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblem.cs
r7823 r8842 66 66 } 67 67 68 protected DataAnalysisProblem(T problemData) 69 : this() { 70 ProblemData = problemData; 71 } 72 68 73 [StorableHook(HookType.AfterDeserialization)] 69 74 private void AfterDeserialization() { -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ConstantRegressionModel.cs
r8528 r8842 30 30 public class ConstantRegressionModel : NamedItem, IRegressionModel { 31 31 [Storable] 32 pr ivatedouble constant;32 protected double constant; 33 33 public double Constant { 34 34 get { return constant; } -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleSolution.cs
r8174 r8842 36 36 [Item("Regression Ensemble Solution", "A regression solution that contains an ensemble of multiple regression models")] 37 37 [Creatable("Data Analysis - Ensembles")] 38 public sealed class RegressionEnsembleSolution : RegressionSolution , IRegressionEnsembleSolution {38 public sealed class RegressionEnsembleSolution : RegressionSolutionBase, IRegressionEnsembleSolution { 39 39 private readonly Dictionary<int, double> trainingEvaluationCache = new Dictionary<int, double>(); 40 40 private readonly Dictionary<int, double> testEvaluationCache = new Dictionary<int, double>(); 41 private readonly Dictionary<int, double> evaluationCache = new Dictionary<int, double>(); 41 42 42 43 public new IRegressionEnsembleModel Model { … … 155 156 } 156 157 157 protected override void RecalculateResults() {158 CalculateResults();159 }160 161 158 #region Evaluation 159 public override IEnumerable<double> EstimatedValues { 160 get { return GetEstimatedValues(Enumerable.Range(0, ProblemData.Dataset.Rows)); } 161 } 162 162 163 public override IEnumerable<double> EstimatedTrainingValues { 163 164 get { -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblem.cs
r7823 r8842 36 36 public override IDeepCloneable Clone(Cloner cloner) { return new RegressionProblem(this, cloner); } 37 37 38 public RegressionProblem() 39 : base() { 40 ProblemData = new RegressionProblemData(); 41 } 38 public RegressionProblem() : base(new RegressionProblemData()) { } 39 42 40 } 43 41 } -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs
r8139 r8842 45 45 : base(model, problemData) { 46 46 evaluationCache = new Dictionary<int, double>(problemData.Dataset.Rows); 47 CalculateRegressionResults(); 47 48 } 48 49 49 protected override void RecalculateResults() {50 CalculateResults();51 }52 50 53 51 public override IEnumerable<double> EstimatedValues { -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionBase.cs
r8139 r8842 29 29 [StorableClass] 30 30 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"; 43 56 44 57 public new IRegressionModel Model { … … 115 128 protected RegressionSolutionBase(IRegressionModel model, IRegressionProblemData problemData) 116 129 : 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())); 129 142 } 130 143 … … 164 177 } 165 178 166 protected void CalculateResults() { 179 protected override void RecalculateResults() { 180 CalculateRegressionResults(); 181 } 182 183 protected void CalculateRegressionResults() { 167 184 IEnumerable<double> estimatedTrainingValues = EstimatedTrainingValues; // cache values 168 185 IEnumerable<double> originalTrainingValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices); -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/HoeffdingsDependenceCalculator.cs
r8542 r8842 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Data; 25 26 26 27 namespace HeuristicLab.Problems.DataAnalysis { 27 public class HoeffdingsDependenceCalculator {28 public class HoeffdingsDependenceCalculator : IDependencyCalculator { 28 29 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) { 30 39 double d = HoeffD(originalValues, estimatedValues, out errorState); 31 40 if (errorState != OnlineCalculatorError.None) return double.NaN; -
branches/DataAnalysisCSVImport/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/SpearmansRankCorrelationCoefficientCalculator.cs
r8689 r8842 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; 24 using HeuristicLab.Data; 25 25 26 26 namespace HeuristicLab.Problems.DataAnalysis { 27 public class SpearmansRankCorrelationCoefficientCalculator {27 public class SpearmansRankCorrelationCoefficientCalculator : IDependencyCalculator { 28 28 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) { 30 38 double rs = double.NaN; 31 39 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); 33 43 errorState = OnlineCalculatorError.None; 34 44 } 35 catch ( Exception ex) {45 catch (alglib.alglibexception) { 36 46 errorState = OnlineCalculatorError.InvalidValueAdded; 37 47 }
Note: See TracChangeset
for help on using the changeset viewer.