Ignore:
Timestamp:
06/27/16 15:28:26 (5 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/TimeframeFeatureCorrelationView.cs

    r12012 r13938  
    3636    private string lastFramesValue;
    3737
     38    private new TimeframeFeatureCorrelationCalculator CorrelationCalculator {
     39      get { return (TimeframeFeatureCorrelationCalculator)base.CorrelationCalculator; }
     40      set { base.CorrelationCalculator = value; }
     41    }
     42
     43
    3844    public TimeframeFeatureCorrelationView() {
    3945      InitializeComponent();
     46      CorrelationCalculator = new TimeframeFeatureCorrelationCalculator();
    4047      correlationTimeframCache = new FeatureCorrelationTimeframeCache();
    4148      errorProvider.SetIconAlignment(timeframeTextbox, ErrorIconAlignment.MiddleRight);
     
    93100
    94101    protected override void CalculateCorrelation() {
    95       if (correlationCalcComboBox.SelectedItem != null && partitionComboBox.SelectedItem != null
    96         && variableSelectionComboBox.SelectedItem != null) {
    97         string variable = (string)variableSelectionComboBox.SelectedItem;
    98         IDependencyCalculator calc = (IDependencyCalculator)correlationCalcComboBox.SelectedValue;
    99         string partition = (string)partitionComboBox.SelectedValue;
    100         int frames;
    101         int.TryParse(timeframeTextbox.Text, out frames);
    102         dataView.Enabled = false;
    103         double[,] corr = correlationTimeframCache.GetTimeframeCorrelation(calc, partition, variable);
    104         if (corr == null) {
    105           fcc.CalculateTimeframeElements(calc, partition, variable, frames);
    106         } else if (corr.GetLength(1) <= frames) {
    107           fcc.CalculateTimeframeElements(calc, partition, variable, frames, corr);
    108         } else {
    109           fcc.TryCancelCalculation();
    110           var columnNames = Enumerable.Range(0, corr.GetLength(1)).Select(x => x.ToString());
    111           var correlation = new DoubleMatrix(corr, columnNames, Content.Dataset.DoubleVariables);
    112           ((IStringConvertibleMatrix)correlation).Columns = frames + 1;
    113           UpdateDataView(correlation);
    114         }
     102      if (correlationCalcComboBox.SelectedItem == null) return;
     103      if (partitionComboBox.SelectedItem == null) return;
     104      if (variableSelectionComboBox.SelectedItem == null) return;
     105
     106      string variable = (string)variableSelectionComboBox.SelectedItem;
     107      IDependencyCalculator calc = (IDependencyCalculator)correlationCalcComboBox.SelectedValue;
     108      string partition = (string)partitionComboBox.SelectedValue;
     109      int frames;
     110      int.TryParse(timeframeTextbox.Text, out frames);
     111      dataView.Enabled = false;
     112      double[,] corr = correlationTimeframCache.GetTimeframeCorrelation(calc, partition, variable);
     113      if (corr == null) {
     114        CorrelationCalculator.CalculateTimeframeElements(Content, calc, partition, variable, frames);
     115      } else if (corr.GetLength(1) <= frames) {
     116        CorrelationCalculator.CalculateTimeframeElements(Content, calc, partition, variable, frames, corr);
     117      } else {
     118        CorrelationCalculator.TryCancelCalculation();
     119        var columnNames = Enumerable.Range(0, corr.GetLength(1)).Select(x => x.ToString());
     120        var correlation = new DoubleMatrix(corr, columnNames, Content.Dataset.DoubleVariables);
     121        ((IStringConvertibleMatrix)correlation).Columns = frames + 1;
     122        UpdateDataView(correlation);
    115123      }
    116124    }
    117125
    118     protected override void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e) {
     126    protected override void FeatureCorrelation_CalculationFinished(object sender, AbstractFeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e) {
    119127      if (InvokeRequired) {
    120         Invoke(new FeatureCorrelationCalculator.CorrelationCalculationFinishedHandler(Content_CorrelationCalculationFinished), sender, e);
     128        Invoke(new AbstractFeatureCorrelationCalculator.CorrelationCalculationFinishedHandler(FeatureCorrelation_CalculationFinished), sender, e);
    121129      } else {
    122130        correlationTimeframCache.SetTimeframeCorrelation(e.Calculcator, e.Partition, e.Variable, e.Correlation);
Note: See TracChangeset for help on using the changeset viewer.