Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/04/12 11:43:16 (12 years ago)
Author:
mkommend
Message:

#1292: Moved FeatureCorrelation specific classes from Problems.DataAnalysis to Problems.DataAnalysis.Views.

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  
    3333using HeuristicLab.MainForm;
    3434using HeuristicLab.MainForm.WindowsForms;
    35 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;
    3635
    3736namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    5352    }
    5453
    55     public AbstractFeatureCorrelationView() {
     54    protected AbstractFeatureCorrelationView() {
    5655      InitializeComponent();
    5756      sortedColumnIndices = new List<KeyValuePair<int, SortOrder>>();
    5857      rowComparer = new StringConvertibleMatrixView.RowComparer();
    5958      fcc = new FeatureCorrelationCalculator();
    60       var calculatorList = FCE.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();
    6160      CorrelationCalcComboBox.ValueMember = "Key";
    6261      CorrelationCalcComboBox.DisplayMember = "Value";
    63       CorrelationCalcComboBox.DataSource = new BindingList<KeyValuePair<FCE.CorrelationCalculators, string>>(calculatorList);
    64       var partitionList = FCE.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();
    6564      PartitionComboBox.ValueMember = "Key";
    6665      PartitionComboBox.DisplayMember = "Value";
    67       PartitionComboBox.DataSource = new BindingList<KeyValuePair<FCE.Partitions, string>>(partitionList);
     66      PartitionComboBox.DataSource = new BindingList<KeyValuePair<FeatureCorrelationEnums.Partitions, string>>(partitionList);
    6867    }
    6968
    7069    protected override void RegisterContentEvents() {
    7170      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);
    7473    }
    7574
    7675    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);
    7978      base.DeregisterContentEvents();
    8079    }
     
    115114
    116115    protected abstract void CalculateCorrelation();
     116    protected abstract void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e);
    117117
    118118    protected void UpdateDataGrid() {
     
    163163      HeatMapProgressBar.Value = e.ProgressPercentage;
    164164    }
    165 
    166     protected abstract void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e);
    167165
    168166    protected void DataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationCache.cs

    r8578 r8729  
    2424using System.Collections.Generic;
    2525using HeuristicLab.PluginInfrastructure;
    26 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;
    2726
    2827namespace HeuristicLab.Problems.DataAnalysis.Views {
    2928  [NonDiscoverableType]
    3029  internal class FeatureCorrelationCache : Object {
    31     private Dictionary<FCE.CorrelationCalculators, Dictionary<FCE.Partitions, double[,]>> correlationsCache;
     30    private Dictionary<FeatureCorrelationEnums.CorrelationCalculators, Dictionary<FeatureCorrelationEnums.Partitions, double[,]>> correlationsCache;
    3231
    3332    public FeatureCorrelationCache()
     
    3736
    3837    private void InitializeCaches() {
    39       correlationsCache = new Dictionary<FCE.CorrelationCalculators, Dictionary<FCE.Partitions, double[,]>>();
    40       foreach (var calc in FCE.EnumToList<FCE.CorrelationCalculators>()) {
    41         correlationsCache.Add(calc, new Dictionary<FCE.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[,]>());
    4241      }
    4342    }
     
    4746    }
    4847
    49     public double[,] GetCorrelation(FCE.CorrelationCalculators calc, FCE.Partitions partition) {
     48    public double[,] GetCorrelation(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition) {
    5049      double[,] corr;
    5150      correlationsCache[calc].TryGetValue(partition, out corr);
     
    5352    }
    5453
    55     public void SetCorrelation(FCE.CorrelationCalculators calc, FCE.Partitions partition, double[,] correlation) {
     54    public void SetCorrelation(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition, double[,] correlation) {
    5655      correlationsCache[calc][partition] = correlation;
    5756    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationCalculator.cs

    r8725 r8729  
    2525using System.Linq;
    2626using HeuristicLab.PluginInfrastructure;
    27 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;
    28 
    29 namespace HeuristicLab.Problems.DataAnalysis {
     27
     28namespace HeuristicLab.Problems.DataAnalysis.Views {
     29  [NonDiscoverableType]
    3030  public class FeatureCorrelationCalculator : Object {
    3131
     
    5151    }
    5252
    53     public void CalculateElements(FCE.CorrelationCalculators calc, FCE.Partitions partition) {
     53    public void CalculateElements(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition) {
    5454      CalculateElements(problemData.Dataset, calc, partition);
    5555    }
    5656
    5757    // returns if any calculation takes place
    58     public bool CalculateTimeframeElements(FCE.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) {
    5959      if (correlation == null || correlation.GetLength(1) <= frames) {
    6060        CalculateElements(problemData.Dataset, calc, partition, variable, frames, correlation);
     
    7575    }
    7676
    77     private void CalculateElements(Dataset dataset, FCE.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) {
    7878      bwInfo = new BackgroundWorkerInfo { Dataset = dataset, Calculator = calc, Partition = partition, Variable = variable, Frames = frames, AlreadyCalculated = alreadyCalculated };
    7979      if (bw == null) {
     
    107107      BackgroundWorkerInfo bwInfo = (BackgroundWorkerInfo)e.Argument;
    108108      Dataset dataset = bwInfo.Dataset;
    109       FCE.Partitions partition = bwInfo.Partition;
    110       FCE.CorrelationCalculators calc = bwInfo.Calculator;
     109      FeatureCorrelationEnums.Partitions partition = bwInfo.Partition;
     110      FeatureCorrelationEnums.CorrelationCalculators calc = bwInfo.Calculator;
    111111
    112112      IList<string> doubleVariableNames = dataset.DoubleVariables.ToList();
     
    144144      BackgroundWorkerInfo bwInfo = (BackgroundWorkerInfo)e.Argument;
    145145      Dataset dataset = bwInfo.Dataset;
    146       FCE.Partitions partition = bwInfo.Partition;
    147       FCE.CorrelationCalculators calc = bwInfo.Calculator;
     146      FeatureCorrelationEnums.Partitions partition = bwInfo.Partition;
     147      FeatureCorrelationEnums.CorrelationCalculators calc = bwInfo.Calculator;
    148148      string variable = bwInfo.Variable;
    149149      int frames = bwInfo.Frames;
     
    192192    }
    193193
    194     private IEnumerable<double> GetRelevantValues(IDataAnalysisProblemData problemData, FCE.Partitions partition, string variable) {
     194    private IEnumerable<double> GetRelevantValues(IDataAnalysisProblemData problemData, FeatureCorrelationEnums.Partitions partition, string variable) {
    195195      IEnumerable<double> var = problemData.Dataset.GetDoubleValues(variable);
    196       if (partition.Equals(FCE.Partitions.TrainingSamples)) {
     196      if (partition.Equals(FeatureCorrelationEnums.Partitions.TrainingSamples)) {
    197197        var = var.Skip(problemData.TrainingPartition.Start).Take(problemData.TrainingPartition.End - problemData.TrainingPartition.Start);
    198       } else if (partition.Equals(FCE.Partitions.TestSamples)) {
     198      } else if (partition.Equals(FeatureCorrelationEnums.Partitions.TestSamples)) {
    199199        var = var.Skip(problemData.TestPartition.Start).Take(problemData.TestPartition.End - problemData.TestPartition.Start);
    200200      }
     
    202202    }
    203203
    204     private double CalculateElementWithCalculator(FCE.CorrelationCalculators calc, IEnumerable<double> var1, IEnumerable<double> var2, out OnlineCalculatorError error) {
    205       if (calc.Equals(FCE.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)) {
    206206        return HoeffdingsDependenceCalculator.Calculate(var1, var2, out error);
    207       } else if (calc.Equals(FCE.CorrelationCalculators.SpearmansRank)) {
     207      } else if (calc.Equals(FeatureCorrelationEnums.CorrelationCalculators.SpearmansRank)) {
    208208        return SpearmansRankCorrelationCoefficientCalculator.Calculate(var1, var2, out error);
    209       } else if (calc.Equals(FCE.CorrelationCalculators.PearsonsRSquared)) {
     209      } else if (calc.Equals(FeatureCorrelationEnums.CorrelationCalculators.PearsonsRSquared)) {
    210210        return OnlinePearsonsRSquaredCalculator.Calculate(var1, var2, out error);
    211211      } else {
     
    231231    public class CorrelationCalculationFinishedArgs : EventArgs {
    232232      public double[,] Correlation { get; private set; }
    233       public FCE.CorrelationCalculators Calculcator { get; private set; }
    234       public FCE.Partitions Partition { get; private set; }
     233      public FeatureCorrelationEnums.CorrelationCalculators Calculcator { get; private set; }
     234      public FeatureCorrelationEnums.Partitions Partition { get; private set; }
    235235      public string Variable { get; private set; }
    236236
    237       public CorrelationCalculationFinishedArgs(double[,] correlation, FCE.CorrelationCalculators calculator, FCE.Partitions partition, string variable = null) {
     237      public CorrelationCalculationFinishedArgs(double[,] correlation, FeatureCorrelationEnums.CorrelationCalculators calculator, FeatureCorrelationEnums.Partitions partition, string variable = null) {
    238238        this.Correlation = correlation;
    239239        this.Calculcator = calculator;
     
    242242      }
    243243    }
     244
    244245    public delegate void CorrelationCalculationFinishedHandler(object sender, CorrelationCalculationFinishedArgs e);
    245246    public event CorrelationCalculationFinishedHandler CorrelationCalculationFinished;
    246     protected virtual void OnCorrelationCalculationFinished(double[,] correlation, FCE.CorrelationCalculators calculator, FCE.Partitions partition, string variable = null) {
     247    protected virtual void OnCorrelationCalculationFinished(double[,] correlation, FeatureCorrelationEnums.CorrelationCalculators calculator, FeatureCorrelationEnums.Partitions partition, string variable = null) {
    247248      var handler = CorrelationCalculationFinished;
    248249      if (handler != null)
     
    260261    #endregion
    261262
    262     protected class BackgroundWorkerInfo {
     263    private class BackgroundWorkerInfo {
    263264      public Dataset Dataset { get; set; }
    264       public FCE.CorrelationCalculators Calculator { get; set; }
    265       public FCE.Partitions Partition { get; set; }
     265      public FeatureCorrelationEnums.CorrelationCalculators Calculator { get; set; }
     266      public FeatureCorrelationEnums.Partitions Partition { get; set; }
    266267      public string Variable { get; set; }
    267268      public int Frames { get; set; }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationEnums.cs

    r8725 r8729  
    2626using System.Reflection;
    2727using HeuristicLab.Data;
     28using HeuristicLab.PluginInfrastructure;
    2829
    29 namespace HeuristicLab.Problems.DataAnalysis {
     30namespace HeuristicLab.Problems.DataAnalysis.Views {
    3031  // see http://blog.spontaneouspublicity.com/associating-strings-with-enums-in-c
     32  [NonDiscoverableType]
    3133  public class FeatureCorrelationEnums {
    3234    public enum Partitions {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationTimeframeCache.cs

    r8578 r8729  
    2424using System.Collections.Generic;
    2525using HeuristicLab.PluginInfrastructure;
    26 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;
    2726
    2827namespace HeuristicLab.Problems.DataAnalysis.Views {
    2928  [NonDiscoverableType]
    3029  internal class FeatureCorrelationTimeframeCache : Object {
    31     private Dictionary<FCE.CorrelationCalculators, Dictionary<FCE.Partitions, Dictionary<string, double[,]>>> timeFrameCorrelationsCache;
     30    private Dictionary<FeatureCorrelationEnums.CorrelationCalculators, Dictionary<FeatureCorrelationEnums.Partitions, Dictionary<string, double[,]>>> timeFrameCorrelationsCache;
    3231
    3332    public FeatureCorrelationTimeframeCache()
     
    3736
    3837    private void InitializeCaches() {
    39       timeFrameCorrelationsCache = new Dictionary<FCE.CorrelationCalculators, Dictionary<FCE.Partitions, Dictionary<string, double[,]>>>();
    40       foreach (var calc in FCE.EnumToList<FCE.CorrelationCalculators>()) {
    41         timeFrameCorrelationsCache.Add(calc, new Dictionary<FCE.Partitions, Dictionary<string, double[,]>>());
    42         foreach (var part in FCE.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>()) {
    4342          timeFrameCorrelationsCache[calc].Add(part, new Dictionary<string, double[,]>());
    4443        }
     
    5049    }
    5150
    52     public double[,] GetTimeframeCorrelation(FCE.CorrelationCalculators calc, FCE.Partitions partition, string variable) {
     51    public double[,] GetTimeframeCorrelation(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition, string variable) {
    5352      double[,] corr;
    5453      timeFrameCorrelationsCache[calc][partition].TryGetValue(variable, out corr);
     
    5655    }
    5756
    58     public void SetTimeframeCorrelation(FCE.CorrelationCalculators calc, FCE.Partitions partition, string variable, double[,] correlation) {
     57    public void SetTimeframeCorrelation(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition, string variable, double[,] correlation) {
    5958      timeFrameCorrelationsCache[calc][partition][variable] = correlation;
    6059    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationView.cs

    r8689 r8729  
    2525using HeuristicLab.MainForm;
    2626using HeuristicLab.MainForm.WindowsForms;
    27 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;
    2827
    2928namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    4746    protected override void CalculateCorrelation() {
    4847      if (CorrelationCalcComboBox.SelectedItem != null && PartitionComboBox.SelectedItem != null) {
    49         FCE.CorrelationCalculators calc = (FCE.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue;
    50         FCE.Partitions partition = (FCE.Partitions)PartitionComboBox.SelectedValue;
     48        FeatureCorrelationEnums.CorrelationCalculators calc = (FeatureCorrelationEnums.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue;
     49        FeatureCorrelationEnums.Partitions partition = (FeatureCorrelationEnums.Partitions)PartitionComboBox.SelectedValue;
    5150        DataGridView.Columns.Clear();
    5251        DataGridView.Enabled = false;
     
    6160    }
    6261
    63     private void SetNewCorrelation(double[,] elements, FCE.CorrelationCalculators calc) {
    64       DoubleRange range = FCE.calculatorInterval[calc];
     62    private void SetNewCorrelation(double[,] elements, FeatureCorrelationEnums.CorrelationCalculators calc) {
     63      DoubleRange range = FeatureCorrelationEnums.calculatorInterval[calc];
    6564      HeatMap hm = new HeatMap(elements, "", range.End, range.Start);
    6665      hm.RowNames = Content.Dataset.DoubleVariables;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs

    r8689 r8729  
    2626using HeuristicLab.Data;
    2727using HeuristicLab.MainForm;
    28 using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;
    2928
    3029namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    5958      string variable = (string)VariableSelectionComboBox.SelectedItem;
    6059      if (CorrelationCalcComboBox.SelectedItem != null && PartitionComboBox.SelectedItem != null && variable != null) {
    61         FCE.CorrelationCalculators calc = (FCE.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue;
    62         FCE.Partitions partition = (FCE.Partitions)PartitionComboBox.SelectedValue;
     60        FeatureCorrelationEnums.CorrelationCalculators calc = (FeatureCorrelationEnums.CorrelationCalculators)CorrelationCalcComboBox.SelectedValue;
     61        FeatureCorrelationEnums.Partitions partition = (FeatureCorrelationEnums.Partitions)PartitionComboBox.SelectedValue;
    6362        DataGridView.Columns.Clear();
    6463        DataGridView.Enabled = false;
     
    7675    }
    7776
    78     private void SetNewCorrelation(double[,] elements, FCE.CorrelationCalculators calc, int frames) {
     77    private void SetNewCorrelation(double[,] elements, FeatureCorrelationEnums.CorrelationCalculators calc, int frames) {
    7978      double[,] neededValues = new double[elements.GetLength(0), frames + 1];
    8079      for (int i = 0; i < elements.GetLength(0); i++) {
     
    8483    }
    8584
    86     private void SetNewCorrelation(double[,] elements, FCE.CorrelationCalculators calc) {
    87       DoubleRange range = FCE.calculatorInterval[calc];
     85    private void SetNewCorrelation(double[,] elements, FeatureCorrelationEnums.CorrelationCalculators calc) {
     86      DoubleRange range = FeatureCorrelationEnums.calculatorInterval[calc];
    8887      HeatMap hm = new HeatMap(elements, "", range.End, range.Start);
    8988      hm.RowNames = Content.Dataset.DoubleVariables;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r8689 r8729  
    162162      <DependentUpon>DataAnalysisSolutionEvaluationView.cs</DependentUpon>
    163163    </Compile>
     164    <Compile Include="FeatureCorrelation\FeatureCorrelationCalculator.cs" />
     165    <Compile Include="FeatureCorrelation\FeatureCorrelationEnums.cs" />
    164166    <Compile Include="FeatureCorrelation\VariableVisibilityDialog.cs">
    165167      <SubType>Form</SubType>
     
    452454    </BootstrapperPackage>
    453455  </ItemGroup>
    454   <ItemGroup />
    455456  <ItemGroup>
    456457    <EmbeddedResource Include="FeatureCorrelation\AbstractFeatureCorrelationView.resx">
Note: See TracChangeset for help on using the changeset viewer.