Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/27/16 15:28:26 (8 years ago)
Author:
mkommend
Message:

#2619:

  • Refactored and separated the different feature correlation calculations.
  • Added a checkbox to ignore missing values in the calculation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationView.cs

    r12012 r13938  
    3434
    3535    private FeatureCorrelationCache correlationCache;
     36    private new FeatureCorrelationCalculator CorrelationCalculator {
     37      get { return (FeatureCorrelationCalculator)base.CorrelationCalculator; }
     38      set { base.CorrelationCalculator = value; }
     39    }
    3640
    3741    public FeatureCorrelationView()
    3842      : base() {
    3943      InitializeComponent();
     44      CorrelationCalculator = new FeatureCorrelationCalculator();
    4045      correlationCache = new FeatureCorrelationCache();
    4146    }
     
    4954    }
    5055
     56    private void ignoreMissingValuesCheckbox_CheckedChanged(object sender, EventArgs e) {
     57      CalculateCorrelation();
     58    }
     59
    5160    protected override void CalculateCorrelation() {
    5261      if (correlationCalcComboBox.SelectedItem == null) return;
     
    5665      string partition = (string)partitionComboBox.SelectedValue;
    5766      dataView.Enabled = false;
    58       double[,] corr = correlationCache.GetCorrelation(calc, partition);
     67      double[,] corr = correlationCache.GetCorrelation(calc, partition, ignoreMissingValuesCheckbox.Checked);
    5968      if (corr == null) {
    60         fcc.CalculateElements(calc, partition);
     69        CorrelationCalculator.CalculateElements(Content, calc, partition, ignoreMissingValuesCheckbox.Checked);
    6170      } else {
    62         fcc.TryCancelCalculation();
     71        CorrelationCalculator.TryCancelCalculation();
    6372        var correlation = new DoubleMatrix(corr, Content.Dataset.DoubleVariables, Content.Dataset.DoubleVariables);
    6473        UpdateDataView(correlation);
     
    6675    }
    6776
    68 
    69 
    70     protected override void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e) {
     77    protected override void FeatureCorrelation_CalculationFinished(object sender, AbstractFeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e) {
    7178      if (InvokeRequired) {
    72         Invoke(new FeatureCorrelationCalculator.CorrelationCalculationFinishedHandler(Content_CorrelationCalculationFinished), sender, e);
     79        Invoke(new AbstractFeatureCorrelationCalculator.CorrelationCalculationFinishedHandler(FeatureCorrelation_CalculationFinished), sender, e);
    7380        return;
    7481      }
    75       correlationCache.SetCorrelation(e.Calculcator, e.Partition, e.Correlation);
     82      correlationCache.SetCorrelation(e.Calculcator, e.Partition, e.IgnoreMissingValues, e.Correlation);
     83
    7684      var correlation = new DoubleMatrix(e.Correlation, Content.Dataset.DoubleVariables, Content.Dataset.DoubleVariables);
    7785      UpdateDataView(correlation);
     
    8088    [NonDiscoverableType]
    8189    private class FeatureCorrelationCache : Object {
    82       private Dictionary<Tuple<IDependencyCalculator, string>, double[,]> correlationsCache;
     90      private Dictionary<Tuple<IDependencyCalculator, string, bool>, double[,]> correlationsCache;
    8391
    8492      public FeatureCorrelationCache()
     
    8896
    8997      private void InitializeCaches() {
    90         correlationsCache = new Dictionary<Tuple<IDependencyCalculator, string>, double[,]>();
     98        correlationsCache = new Dictionary<Tuple<IDependencyCalculator, string, bool>, double[,]>();
    9199      }
    92100
     
    95103      }
    96104
    97       public double[,] GetCorrelation(IDependencyCalculator calc, string partition) {
     105      public double[,] GetCorrelation(IDependencyCalculator calc, string partition, bool ignoreMissingValues) {
    98106        double[,] corr;
    99         var key = new Tuple<IDependencyCalculator, string>(calc, partition);
     107        var key = Tuple.Create(calc, partition, ignoreMissingValues);
    100108        correlationsCache.TryGetValue(key, out corr);
    101109        return corr;
    102110      }
    103111
    104       public void SetCorrelation(IDependencyCalculator calc, string partition, double[,] correlation) {
    105         var key = new Tuple<IDependencyCalculator, string>(calc, partition);
     112      public void SetCorrelation(IDependencyCalculator calc, string partition, bool ignoreMissingValues, double[,] correlation) {
     113        var key = Tuple.Create(calc, partition, ignoreMissingValues);
    106114        correlationsCache[key] = correlation;
    107115      }
Note: See TracChangeset for help on using the changeset viewer.