Changeset 8483
- Timestamp:
- 08/14/12 13:05:48 (12 years ago)
- Location:
- branches/DatasetFeatureCorrelation
- Files:
-
- 3 added
- 4 deleted
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r8276 r8483 172 172 <DependentUpon>ClassificationEnsembleSolutionModelView.cs</DependentUpon> 173 173 </Compile> 174 <Compile Include=" CorrelationHeatMapView.cs">175 <SubType>UserControl</SubType> 176 </Compile> 177 <Compile Include=" CorrelationHeatMapView.Designer.cs">178 <DependentUpon> CorrelationHeatMapView.cs</DependentUpon>174 <Compile Include="FeatureCorrelationView.cs"> 175 <SubType>UserControl</SubType> 176 </Compile> 177 <Compile Include="FeatureCorrelationView.Designer.cs"> 178 <DependentUpon>FeatureCorrelationView.cs</DependentUpon> 179 179 </Compile> 180 180 <Compile Include="DataAnalysisSolutionEvaluationView.cs"> … … 183 183 <Compile Include="DataAnalysisSolutionEvaluationView.Designer.cs"> 184 184 <DependentUpon>DataAnalysisSolutionEvaluationView.cs</DependentUpon> 185 </Compile>186 <Compile Include="ExtendedHeatMapView.cs">187 <SubType>UserControl</SubType>188 </Compile>189 <Compile Include="ExtendedHeatMapView.Designer.cs">190 <DependentUpon>ExtendedHeatMapView.cs</DependentUpon>191 185 </Compile> 192 186 <Compile Include="Plugin.cs" /> … … 350 344 <ItemGroup> 351 345 <Folder Include="obj\" /> 346 </ItemGroup> 347 <ItemGroup> 348 <EmbeddedResource Include="FeatureCorrelationView.resx"> 349 <DependentUpon>FeatureCorrelationView.cs</DependentUpon> 350 </EmbeddedResource> 352 351 </ItemGroup> 353 352 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r8294 r8483 158 158 <Compile Include="Implementation\Clustering\ClusteringProblemData.cs" /> 159 159 <Compile Include="Implementation\Clustering\ClusteringSolution.cs" /> 160 <Compile Include="Implementation\ ExtendedHeatMap.cs" />160 <Compile Include="Implementation\FeatureCorrelation.cs" /> 161 161 <Compile Include="Implementation\Regression\ConstantRegressionModel.cs" /> 162 162 <Compile Include="Implementation\Regression\ConstantRegressionSolution.cs" /> … … 215 215 <Compile Include="OnlineCalculators\OnlineMeanSquaredErrorCalculator.cs" /> 216 216 <Compile Include="OnlineCalculators\OnlineNormalizedMeanSquaredErrorCalculator.cs" /> 217 <Compile Include="Implementation\Regression\RegressionSolution.cs" /> 217 218 <Compile Include="OnlineCalculators\OnlinePearsonsRSquaredCalculator.cs" /> 218 <Compile Include="Implementation\Regression\RegressionSolution.cs" />219 219 <Compile Include="OnlineCalculators\SpearmansRankCorrelationCoefficientCalculator.cs" /> 220 220 <Compile Include="Plugin.cs" /> -
branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs
r8318 r8483 52 52 get { return (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName]; } 53 53 } 54 public IFixedValueParameter< ExtendedHeatMap> DatasetHeatMapParameter {55 get { return (IFixedValueParameter< ExtendedHeatMap>)Parameters[DatasetHeatMapParameterName]; }54 public IFixedValueParameter<FeatureCorrelation> DatasetHeatMapParameter { 55 get { return (IFixedValueParameter<FeatureCorrelation>)Parameters[DatasetHeatMapParameterName]; } 56 56 } 57 57 #endregion … … 78 78 get { return TestPartitionParameter.Value; } 79 79 } 80 public ExtendedHeatMapDatasetHeatMap {80 public FeatureCorrelation DatasetHeatMap { 81 81 get { return DatasetHeatMapParameter.Value; } 82 82 } … … 120 120 #region Backwards compatible code, remove with 3.4 121 121 if (!Parameters.ContainsKey(DatasetHeatMapParameterName)) { 122 Parameters.Add(new FixedValueParameter< ExtendedHeatMap>(DatasetHeatMapParameterName, "", new ExtendedHeatMap()));122 Parameters.Add(new FixedValueParameter<FeatureCorrelation>(DatasetHeatMapParameterName, "", new FeatureCorrelation())); 123 123 } 124 124 #endregion … … 147 147 Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", new IntRange(trainingPartitionStart, trainingPartitionEnd))); 148 148 Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd))); 149 Parameters.Add(new FixedValueParameter< ExtendedHeatMap>(DatasetHeatMapParameterName, "", new ExtendedHeatMap(this)));149 Parameters.Add(new FixedValueParameter<FeatureCorrelation>(DatasetHeatMapParameterName, "", new FeatureCorrelation(this))); 150 150 151 151 ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; -
branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/FeatureCorrelation.cs
r8481 r8483 33 33 namespace HeuristicLab.Problems.DataAnalysis { 34 34 [StorableClass] 35 [Item("HeatMap", "Represents a heat map of double values.")] 36 public class ExtendedHeatMap : HeatMap { 37 38 private const string PrearsonsRSquared = "Pearsons R Squared"; 35 [Item("FeatureCorrelation", "Represents the correlation of features in a data set.")] 36 public class FeatureCorrelation : HeatMap { 37 38 private const string PearsonsR = "Pearsons R"; 39 private const string PearsonsRSquared = "Pearsons R Squared"; 39 40 private const string HoeffdingsDependence = "Hoeffdings Dependence"; 40 41 private const string SpearmansRank = "Spearmans Rank"; 41 42 public IEnumerable<string> CorrelationCalculators { 42 get { return new List<string>() { P rearsonsRSquared, HoeffdingsDependence, SpearmansRank }; }43 get { return new List<string>() { PearsonsR, PearsonsRSquared, HoeffdingsDependence, SpearmansRank }; } 43 44 } 44 45 … … 65 66 private BackgroundWorker bw; 66 67 67 public ExtendedHeatMap()68 public FeatureCorrelation() 68 69 : base() { 69 70 this.Title = "Feature Correlation"; 70 71 this.columnNames = Enumerable.Range(1, 2).Select(x => x.ToString()).ToList(); 71 72 this.rowNames = Enumerable.Range(1, 2).Select(x => x.ToString()).ToList(); 72 } 73 74 public ExtendedHeatMap(IDataAnalysisProblemData problemData) { 73 sortableView = true; 74 } 75 76 public FeatureCorrelation(IDataAnalysisProblemData problemData) { 75 77 this.problemData = problemData; 76 78 this.Title = "Feature Correlation"; 77 79 this.columnNames = problemData.Dataset.DoubleVariables.ToList(); 78 80 this.rowNames = problemData.Dataset.DoubleVariables.ToList(); 81 sortableView = true; 79 82 80 83 CalculateElements(problemData.Dataset); 81 84 } 82 protected ExtendedHeatMap(ExtendedHeatMaporiginal, Cloner cloner)85 protected FeatureCorrelation(FeatureCorrelation original, Cloner cloner) 83 86 : base(original, cloner) { 84 87 this.Title = "Feature Correlation"; … … 88 91 } 89 92 public override IDeepCloneable Clone(Cloner cloner) { 90 return new ExtendedHeatMap(this, cloner);93 return new FeatureCorrelation(this, cloner); 91 94 } 92 95 … … 112 115 } 113 116 bw.RunWorkerAsync(new BackgroundWorkerInfo { Dataset = dataset, Calculator = calc, Partition = partition }); 117 if (calc.Equals(PearsonsR) || calc.Equals(SpearmansRank)) { 118 Maximum = 1.0; 119 Minimum = -1.0; 120 } else if (calc.Equals(HoeffdingsDependence)) { 121 Maximum = 1.0; 122 Minimum = -0.5; 123 } else { 124 Maximum = 1.0; 125 Minimum = 0.0; 126 } 114 127 } 115 128 … … 128 141 129 142 double calculations = (Math.Pow(length, 2) + length) / 2; 143 144 worker.ReportProgress(0); 130 145 131 146 for (int i = 0; i < length; i++) { … … 150 165 } else if (calc.Equals(SpearmansRank)) { 151 166 elements[i, j] = SpearmansRankCorrelationCoefficientCalculator.Calculate(var1, var2, out error); 167 } else if (calc.Equals(PearsonsRSquared)) { 168 elements[i, j] = OnlinePearsonsRSquaredCalculator.Calculate(var1, var2, out error); 152 169 } else { 153 elements[i, j] = OnlinePearsonsRSquaredCalculator.Calculate (var1, var2, out error);170 elements[i, j] = OnlinePearsonsRSquaredCalculator.CalculateR(var1, var2, out error); 154 171 } 155 172 elements[j, i] = elements[i, j]; 156 173 if (!error.Equals(OnlineCalculatorError.None)) { 157 throw new ArgumentException("Calculator returned " + error); 174 worker.ReportProgress(100); 175 throw new ArgumentException("Calculator returned " + error + Environment.NewLine + "Maybe try another calculator."); 158 176 } 159 177 worker.ReportProgress((int)Math.Round((((Math.Pow(i, 2) + i) / 2 + j + 1.0) / calculations) * 100)); … … 172 190 OnReset(); 173 191 } 174 } else {175 Console.WriteLine("Backgroundworker canceled");176 192 } 177 193 } … … 189 205 public event EventHandler ProblemDataChanged; 190 206 protected virtual void OnProblemDataChanged() { 191 var handler = ProblemDataChanged; 192 if (handler != null) handler(this, EventArgs.Empty); 207 EventHandler handler = ProblemDataChanged; 208 if (handler != null) 209 handler(this, EventArgs.Empty); 193 210 } 194 211 #endregion -
branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlinePearsonsRSquaredCalculator.cs
r7259 r8483 30 30 private OnlineMeanAndVarianceCalculator syCalculator = new OnlineMeanAndVarianceCalculator(); 31 31 32 public double RSquared{32 public double PearsonsR { 33 33 get { 34 34 double xVar = sxCalculator.PopulationVariance; … … 38 38 } else { 39 39 double r = covCalculator.Covariance / (Math.Sqrt(xVar) * Math.Sqrt(yVar)); 40 return r * r;40 return r; 41 41 } 42 } 43 } 44 45 public double RSquared { 46 get { 47 return Math.Pow(PearsonsR, 2); 42 48 } 43 49 } … … 67 73 #endregion 68 74 69 public static double Calculate (IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {75 public static double CalculateR(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) { 70 76 IEnumerator<double> firstEnumerator = first.GetEnumerator(); 71 77 IEnumerator<double> secondEnumerator = second.GetEnumerator(); … … 86 92 } else { 87 93 errorState = rSquaredCalculator.ErrorState; 88 return rSquaredCalculator. RSquared;94 return rSquaredCalculator.PearsonsR; 89 95 } 96 } 97 98 public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) { 99 return Math.Pow(CalculateR(first, second, out errorState), 2); 90 100 } 91 101 } -
branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/SpearmansRankCorrelationCoefficientCalculator.cs
r8294 r8483 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; … … 28 27 29 28 public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) { 30 double rs = Math.Abs(alglib.basestat.spearmancorr2(originalValues.ToArray(), estimatedValues.ToArray(), originalValues.Count()));29 double rs = alglib.basestat.spearmancorr2(originalValues.ToArray(), estimatedValues.ToArray(), originalValues.Count()); 31 30 errorState = OnlineCalculatorError.None; 32 31 return rs;
Note: See TracChangeset
for help on using the changeset viewer.