- Timestamp:
- 10/04/12 11:43:16 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4
- Files:
-
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.cs
r8689 r8729 33 33 using HeuristicLab.MainForm; 34 34 using HeuristicLab.MainForm.WindowsForms; 35 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;36 35 37 36 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 53 52 } 54 53 55 p ublicAbstractFeatureCorrelationView() {54 protected AbstractFeatureCorrelationView() { 56 55 InitializeComponent(); 57 56 sortedColumnIndices = new List<KeyValuePair<int, SortOrder>>(); 58 57 rowComparer = new StringConvertibleMatrixView.RowComparer(); 59 58 fcc = new FeatureCorrelationCalculator(); 60 var calculatorList = F CE.EnumToList<FCE.CorrelationCalculators>().Select(x => new KeyValuePair<FCE.CorrelationCalculators, string>(x, FCE.GetEnumDescription(x))).ToList();59 var calculatorList = FeatureCorrelationEnums.EnumToList<FeatureCorrelationEnums.CorrelationCalculators>().Select(x => new KeyValuePair<FeatureCorrelationEnums.CorrelationCalculators, string>(x, FeatureCorrelationEnums.GetEnumDescription(x))).ToList(); 61 60 CorrelationCalcComboBox.ValueMember = "Key"; 62 61 CorrelationCalcComboBox.DisplayMember = "Value"; 63 CorrelationCalcComboBox.DataSource = new BindingList<KeyValuePair<F CE.CorrelationCalculators, string>>(calculatorList);64 var partitionList = F CE.EnumToList<FCE.Partitions>().Select(x => new KeyValuePair<FCE.Partitions, string>(x, FCE.GetEnumDescription(x))).ToList();62 CorrelationCalcComboBox.DataSource = new BindingList<KeyValuePair<FeatureCorrelationEnums.CorrelationCalculators, string>>(calculatorList); 63 var partitionList = FeatureCorrelationEnums.EnumToList<FeatureCorrelationEnums.Partitions>().Select(x => new KeyValuePair<FeatureCorrelationEnums.Partitions, string>(x, FeatureCorrelationEnums.GetEnumDescription(x))).ToList(); 65 64 PartitionComboBox.ValueMember = "Key"; 66 65 PartitionComboBox.DisplayMember = "Value"; 67 PartitionComboBox.DataSource = new BindingList<KeyValuePair<F CE.Partitions, string>>(partitionList);66 PartitionComboBox.DataSource = new BindingList<KeyValuePair<FeatureCorrelationEnums.Partitions, string>>(partitionList); 68 67 } 69 68 70 69 protected override void RegisterContentEvents() { 71 70 base.RegisterContentEvents(); 72 fcc.ProgressCalculation += new DataAnalysis.FeatureCorrelationCalculator.ProgressCalculationHandler(Content_ProgressCalculation);73 fcc.CorrelationCalculationFinished += new DataAnalysis.FeatureCorrelationCalculator.CorrelationCalculationFinishedHandler(Content_CorrelationCalculationFinished);71 fcc.ProgressCalculation += new FeatureCorrelationCalculator.ProgressCalculationHandler(Content_ProgressCalculation); 72 fcc.CorrelationCalculationFinished += new FeatureCorrelationCalculator.CorrelationCalculationFinishedHandler(Content_CorrelationCalculationFinished); 74 73 } 75 74 76 75 protected override void DeregisterContentEvents() { 77 fcc.CorrelationCalculationFinished += new DataAnalysis.FeatureCorrelationCalculator.CorrelationCalculationFinishedHandler(Content_CorrelationCalculationFinished);78 fcc.ProgressCalculation += new DataAnalysis.FeatureCorrelationCalculator.ProgressCalculationHandler(Content_ProgressCalculation);76 fcc.CorrelationCalculationFinished += new FeatureCorrelationCalculator.CorrelationCalculationFinishedHandler(Content_CorrelationCalculationFinished); 77 fcc.ProgressCalculation += new FeatureCorrelationCalculator.ProgressCalculationHandler(Content_ProgressCalculation); 79 78 base.DeregisterContentEvents(); 80 79 } … … 115 114 116 115 protected abstract void CalculateCorrelation(); 116 protected abstract void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e); 117 117 118 118 protected void UpdateDataGrid() { … … 163 163 HeatMapProgressBar.Value = e.ProgressPercentage; 164 164 } 165 166 protected abstract void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e);167 165 168 166 protected void DataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationCache.cs
r8578 r8729 24 24 using System.Collections.Generic; 25 25 using HeuristicLab.PluginInfrastructure; 26 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;27 26 28 27 namespace HeuristicLab.Problems.DataAnalysis.Views { 29 28 [NonDiscoverableType] 30 29 internal class FeatureCorrelationCache : Object { 31 private Dictionary<F CE.CorrelationCalculators, Dictionary<FCE.Partitions, double[,]>> correlationsCache;30 private Dictionary<FeatureCorrelationEnums.CorrelationCalculators, Dictionary<FeatureCorrelationEnums.Partitions, double[,]>> correlationsCache; 32 31 33 32 public FeatureCorrelationCache() … … 37 36 38 37 private void InitializeCaches() { 39 correlationsCache = new Dictionary<F CE.CorrelationCalculators, Dictionary<FCE.Partitions, double[,]>>();40 foreach (var calc in F CE.EnumToList<FCE.CorrelationCalculators>()) {41 correlationsCache.Add(calc, new Dictionary<F CE.Partitions, double[,]>());38 correlationsCache = new Dictionary<FeatureCorrelationEnums.CorrelationCalculators, Dictionary<FeatureCorrelationEnums.Partitions, double[,]>>(); 39 foreach (var calc in FeatureCorrelationEnums.EnumToList<FeatureCorrelationEnums.CorrelationCalculators>()) { 40 correlationsCache.Add(calc, new Dictionary<FeatureCorrelationEnums.Partitions, double[,]>()); 42 41 } 43 42 } … … 47 46 } 48 47 49 public double[,] GetCorrelation(F CE.CorrelationCalculators calc, FCE.Partitions partition) {48 public double[,] GetCorrelation(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition) { 50 49 double[,] corr; 51 50 correlationsCache[calc].TryGetValue(partition, out corr); … … 53 52 } 54 53 55 public void SetCorrelation(F CE.CorrelationCalculators calc, FCE.Partitions partition, double[,] correlation) {54 public void SetCorrelation(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition, double[,] correlation) { 56 55 correlationsCache[calc][partition] = correlation; 57 56 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationCalculator.cs
r8725 r8729 25 25 using System.Linq; 26 26 using HeuristicLab.PluginInfrastructure; 27 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums; 28 29 namespace HeuristicLab.Problems.DataAnalysis { 27 28 namespace HeuristicLab.Problems.DataAnalysis.Views { 29 [NonDiscoverableType] 30 30 public class FeatureCorrelationCalculator : Object { 31 31 … … 51 51 } 52 52 53 public void CalculateElements(F CE.CorrelationCalculators calc, FCE.Partitions partition) {53 public void CalculateElements(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition) { 54 54 CalculateElements(problemData.Dataset, calc, partition); 55 55 } 56 56 57 57 // returns if any calculation takes place 58 public bool CalculateTimeframeElements(F CE.CorrelationCalculators calc, FCE.Partitions partition, string variable, int frames, double[,] correlation = null) {58 public bool CalculateTimeframeElements(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition, string variable, int frames, double[,] correlation = null) { 59 59 if (correlation == null || correlation.GetLength(1) <= frames) { 60 60 CalculateElements(problemData.Dataset, calc, partition, variable, frames, correlation); … … 75 75 } 76 76 77 private void CalculateElements(Dataset dataset, F CE.CorrelationCalculators calc, FCE.Partitions partition, string variable = null, int frames = 0, double[,] alreadyCalculated = null) {77 private void CalculateElements(Dataset dataset, FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition, string variable = null, int frames = 0, double[,] alreadyCalculated = null) { 78 78 bwInfo = new BackgroundWorkerInfo { Dataset = dataset, Calculator = calc, Partition = partition, Variable = variable, Frames = frames, AlreadyCalculated = alreadyCalculated }; 79 79 if (bw == null) { … … 107 107 BackgroundWorkerInfo bwInfo = (BackgroundWorkerInfo)e.Argument; 108 108 Dataset dataset = bwInfo.Dataset; 109 F CE.Partitions partition = bwInfo.Partition;110 F CE.CorrelationCalculators calc = bwInfo.Calculator;109 FeatureCorrelationEnums.Partitions partition = bwInfo.Partition; 110 FeatureCorrelationEnums.CorrelationCalculators calc = bwInfo.Calculator; 111 111 112 112 IList<string> doubleVariableNames = dataset.DoubleVariables.ToList(); … … 144 144 BackgroundWorkerInfo bwInfo = (BackgroundWorkerInfo)e.Argument; 145 145 Dataset dataset = bwInfo.Dataset; 146 F CE.Partitions partition = bwInfo.Partition;147 F CE.CorrelationCalculators calc = bwInfo.Calculator;146 FeatureCorrelationEnums.Partitions partition = bwInfo.Partition; 147 FeatureCorrelationEnums.CorrelationCalculators calc = bwInfo.Calculator; 148 148 string variable = bwInfo.Variable; 149 149 int frames = bwInfo.Frames; … … 192 192 } 193 193 194 private IEnumerable<double> GetRelevantValues(IDataAnalysisProblemData problemData, F CE.Partitions partition, string variable) {194 private IEnumerable<double> GetRelevantValues(IDataAnalysisProblemData problemData, FeatureCorrelationEnums.Partitions partition, string variable) { 195 195 IEnumerable<double> var = problemData.Dataset.GetDoubleValues(variable); 196 if (partition.Equals(F CE.Partitions.TrainingSamples)) {196 if (partition.Equals(FeatureCorrelationEnums.Partitions.TrainingSamples)) { 197 197 var = var.Skip(problemData.TrainingPartition.Start).Take(problemData.TrainingPartition.End - problemData.TrainingPartition.Start); 198 } else if (partition.Equals(F CE.Partitions.TestSamples)) {198 } else if (partition.Equals(FeatureCorrelationEnums.Partitions.TestSamples)) { 199 199 var = var.Skip(problemData.TestPartition.Start).Take(problemData.TestPartition.End - problemData.TestPartition.Start); 200 200 } … … 202 202 } 203 203 204 private double CalculateElementWithCalculator(F CE.CorrelationCalculators calc, IEnumerable<double> var1, IEnumerable<double> var2, out OnlineCalculatorError error) {205 if (calc.Equals(F CE.CorrelationCalculators.HoeffdingsDependence)) {204 private double CalculateElementWithCalculator(FeatureCorrelationEnums.CorrelationCalculators calc, IEnumerable<double> var1, IEnumerable<double> var2, out OnlineCalculatorError error) { 205 if (calc.Equals(FeatureCorrelationEnums.CorrelationCalculators.HoeffdingsDependence)) { 206 206 return HoeffdingsDependenceCalculator.Calculate(var1, var2, out error); 207 } else if (calc.Equals(F CE.CorrelationCalculators.SpearmansRank)) {207 } else if (calc.Equals(FeatureCorrelationEnums.CorrelationCalculators.SpearmansRank)) { 208 208 return SpearmansRankCorrelationCoefficientCalculator.Calculate(var1, var2, out error); 209 } else if (calc.Equals(F CE.CorrelationCalculators.PearsonsRSquared)) {209 } else if (calc.Equals(FeatureCorrelationEnums.CorrelationCalculators.PearsonsRSquared)) { 210 210 return OnlinePearsonsRSquaredCalculator.Calculate(var1, var2, out error); 211 211 } else { … … 231 231 public class CorrelationCalculationFinishedArgs : EventArgs { 232 232 public double[,] Correlation { get; private set; } 233 public F CE.CorrelationCalculators Calculcator { get; private set; }234 public F CE.Partitions Partition { get; private set; }233 public FeatureCorrelationEnums.CorrelationCalculators Calculcator { get; private set; } 234 public FeatureCorrelationEnums.Partitions Partition { get; private set; } 235 235 public string Variable { get; private set; } 236 236 237 public CorrelationCalculationFinishedArgs(double[,] correlation, F CE.CorrelationCalculators calculator, FCE.Partitions partition, string variable = null) {237 public CorrelationCalculationFinishedArgs(double[,] correlation, FeatureCorrelationEnums.CorrelationCalculators calculator, FeatureCorrelationEnums.Partitions partition, string variable = null) { 238 238 this.Correlation = correlation; 239 239 this.Calculcator = calculator; … … 242 242 } 243 243 } 244 244 245 public delegate void CorrelationCalculationFinishedHandler(object sender, CorrelationCalculationFinishedArgs e); 245 246 public event CorrelationCalculationFinishedHandler CorrelationCalculationFinished; 246 protected virtual void OnCorrelationCalculationFinished(double[,] correlation, F CE.CorrelationCalculators calculator, FCE.Partitions partition, string variable = null) {247 protected virtual void OnCorrelationCalculationFinished(double[,] correlation, FeatureCorrelationEnums.CorrelationCalculators calculator, FeatureCorrelationEnums.Partitions partition, string variable = null) { 247 248 var handler = CorrelationCalculationFinished; 248 249 if (handler != null) … … 260 261 #endregion 261 262 262 pr otectedclass BackgroundWorkerInfo {263 private class BackgroundWorkerInfo { 263 264 public Dataset Dataset { get; set; } 264 public F CE.CorrelationCalculators Calculator { get; set; }265 public F CE.Partitions Partition { get; set; }265 public FeatureCorrelationEnums.CorrelationCalculators Calculator { get; set; } 266 public FeatureCorrelationEnums.Partitions Partition { get; set; } 266 267 public string Variable { get; set; } 267 268 public int Frames { get; set; } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationEnums.cs
r8725 r8729 26 26 using System.Reflection; 27 27 using HeuristicLab.Data; 28 using HeuristicLab.PluginInfrastructure; 28 29 29 namespace HeuristicLab.Problems.DataAnalysis {30 namespace HeuristicLab.Problems.DataAnalysis.Views { 30 31 // see http://blog.spontaneouspublicity.com/associating-strings-with-enums-in-c 32 [NonDiscoverableType] 31 33 public class FeatureCorrelationEnums { 32 34 public enum Partitions { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationTimeframeCache.cs
r8578 r8729 24 24 using System.Collections.Generic; 25 25 using HeuristicLab.PluginInfrastructure; 26 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;27 26 28 27 namespace HeuristicLab.Problems.DataAnalysis.Views { 29 28 [NonDiscoverableType] 30 29 internal class FeatureCorrelationTimeframeCache : Object { 31 private Dictionary<F CE.CorrelationCalculators, Dictionary<FCE.Partitions, Dictionary<string, double[,]>>> timeFrameCorrelationsCache;30 private Dictionary<FeatureCorrelationEnums.CorrelationCalculators, Dictionary<FeatureCorrelationEnums.Partitions, Dictionary<string, double[,]>>> timeFrameCorrelationsCache; 32 31 33 32 public FeatureCorrelationTimeframeCache() … … 37 36 38 37 private void InitializeCaches() { 39 timeFrameCorrelationsCache = new Dictionary<F CE.CorrelationCalculators, Dictionary<FCE.Partitions, Dictionary<string, double[,]>>>();40 foreach (var calc in F CE.EnumToList<FCE.CorrelationCalculators>()) {41 timeFrameCorrelationsCache.Add(calc, new Dictionary<F CE.Partitions, Dictionary<string, double[,]>>());42 foreach (var part in F CE.EnumToList<FCE.Partitions>()) {38 timeFrameCorrelationsCache = new Dictionary<FeatureCorrelationEnums.CorrelationCalculators, Dictionary<FeatureCorrelationEnums.Partitions, Dictionary<string, double[,]>>>(); 39 foreach (var calc in FeatureCorrelationEnums.EnumToList<FeatureCorrelationEnums.CorrelationCalculators>()) { 40 timeFrameCorrelationsCache.Add(calc, new Dictionary<FeatureCorrelationEnums.Partitions, Dictionary<string, double[,]>>()); 41 foreach (var part in FeatureCorrelationEnums.EnumToList<FeatureCorrelationEnums.Partitions>()) { 43 42 timeFrameCorrelationsCache[calc].Add(part, new Dictionary<string, double[,]>()); 44 43 } … … 50 49 } 51 50 52 public double[,] GetTimeframeCorrelation(F CE.CorrelationCalculators calc, FCE.Partitions partition, string variable) {51 public double[,] GetTimeframeCorrelation(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition, string variable) { 53 52 double[,] corr; 54 53 timeFrameCorrelationsCache[calc][partition].TryGetValue(variable, out corr); … … 56 55 } 57 56 58 public void SetTimeframeCorrelation(F CE.CorrelationCalculators calc, FCE.Partitions partition, string variable, double[,] correlation) {57 public void SetTimeframeCorrelation(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition, string variable, double[,] correlation) { 59 58 timeFrameCorrelationsCache[calc][partition][variable] = correlation; 60 59 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationView.cs
r8689 r8729 25 25 using HeuristicLab.MainForm; 26 26 using HeuristicLab.MainForm.WindowsForms; 27 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;28 27 29 28 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 47 46 protected override void CalculateCorrelation() { 48 47 if (CorrelationCalcComboBox.SelectedItem != null && PartitionComboBox.SelectedItem != null) { 49 F CE.CorrelationCalculators calc = (FCE.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue;50 F CE.Partitions partition = (FCE.Partitions)PartitionComboBox.SelectedValue;48 FeatureCorrelationEnums.CorrelationCalculators calc = (FeatureCorrelationEnums.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue; 49 FeatureCorrelationEnums.Partitions partition = (FeatureCorrelationEnums.Partitions)PartitionComboBox.SelectedValue; 51 50 DataGridView.Columns.Clear(); 52 51 DataGridView.Enabled = false; … … 61 60 } 62 61 63 private void SetNewCorrelation(double[,] elements, F CE.CorrelationCalculators calc) {64 DoubleRange range = F CE.calculatorInterval[calc];62 private void SetNewCorrelation(double[,] elements, FeatureCorrelationEnums.CorrelationCalculators calc) { 63 DoubleRange range = FeatureCorrelationEnums.calculatorInterval[calc]; 65 64 HeatMap hm = new HeatMap(elements, "", range.End, range.Start); 66 65 hm.RowNames = Content.Dataset.DoubleVariables; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs
r8689 r8729 26 26 using HeuristicLab.Data; 27 27 using HeuristicLab.MainForm; 28 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;29 28 30 29 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 59 58 string variable = (string)VariableSelectionComboBox.SelectedItem; 60 59 if (CorrelationCalcComboBox.SelectedItem != null && PartitionComboBox.SelectedItem != null && variable != null) { 61 F CE.CorrelationCalculators calc = (FCE.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue;62 F CE.Partitions partition = (FCE.Partitions)PartitionComboBox.SelectedValue;60 FeatureCorrelationEnums.CorrelationCalculators calc = (FeatureCorrelationEnums.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue; 61 FeatureCorrelationEnums.Partitions partition = (FeatureCorrelationEnums.Partitions)PartitionComboBox.SelectedValue; 63 62 DataGridView.Columns.Clear(); 64 63 DataGridView.Enabled = false; … … 76 75 } 77 76 78 private void SetNewCorrelation(double[,] elements, F CE.CorrelationCalculators calc, int frames) {77 private void SetNewCorrelation(double[,] elements, FeatureCorrelationEnums.CorrelationCalculators calc, int frames) { 79 78 double[,] neededValues = new double[elements.GetLength(0), frames + 1]; 80 79 for (int i = 0; i < elements.GetLength(0); i++) { … … 84 83 } 85 84 86 private void SetNewCorrelation(double[,] elements, F CE.CorrelationCalculators calc) {87 DoubleRange range = F CE.calculatorInterval[calc];85 private void SetNewCorrelation(double[,] elements, FeatureCorrelationEnums.CorrelationCalculators calc) { 86 DoubleRange range = FeatureCorrelationEnums.calculatorInterval[calc]; 88 87 HeatMap hm = new HeatMap(elements, "", range.End, range.Start); 89 88 hm.RowNames = Content.Dataset.DoubleVariables; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r8689 r8729 162 162 <DependentUpon>DataAnalysisSolutionEvaluationView.cs</DependentUpon> 163 163 </Compile> 164 <Compile Include="FeatureCorrelation\FeatureCorrelationCalculator.cs" /> 165 <Compile Include="FeatureCorrelation\FeatureCorrelationEnums.cs" /> 164 166 <Compile Include="FeatureCorrelation\VariableVisibilityDialog.cs"> 165 167 <SubType>Form</SubType> … … 452 454 </BootstrapperPackage> 453 455 </ItemGroup> 454 <ItemGroup />455 456 <ItemGroup> 456 457 <EmbeddedResource Include="FeatureCorrelation\AbstractFeatureCorrelationView.resx">
Note: See TracChangeset
for help on using the changeset viewer.