Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/24/12 10:44:47 (12 years ago)
Author:
sforsten
Message:

#1292:

  • added cloning method and constructor to ExtendedHeatMap
  • renamed a variable in ExtendedHeatMapView
  • added backwards compatibility code in DataAnalysisProblemData
Location:
branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/Implementation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r8276 r8318  
    114114    [StorableConstructor]
    115115    protected DataAnalysisProblemData(bool deserializing) : base(deserializing) { }
     116
    116117    [StorableHook(HookType.AfterDeserialization)]
    117118    private void AfterDeserialization() {
     119      // BackwardsCompatibility3.3
     120      #region Backwards compatible code, remove with 3.4
     121      if (!Parameters.ContainsKey(DatasetHeatMapParameterName)) {
     122        Parameters.Add(new FixedValueParameter<ExtendedHeatMap>(DatasetHeatMapParameterName, "", new ExtendedHeatMap()));
     123      }
     124      #endregion
     125      DatasetHeatMap.ProblemData = this;
    118126      RegisterEventHandlers();
    119127    }
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/ExtendedHeatMap.cs

    r8294 r8318  
    2626using System.Linq;
    2727using HeuristicLab.Analysis;
     28using HeuristicLab.Common;
    2829using HeuristicLab.Core;
    2930using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3132
    3233namespace HeuristicLab.Problems.DataAnalysis {
     34  [StorableClass]
    3335  [Item("HeatMap", "Represents a heat map of double values.")]
    34   [StorableClass]
    3536  public class ExtendedHeatMap : HeatMap {
    3637
     38    private const string PrearsonsRSquared = "Pearsons R Squared";
     39    private const string HoeffdingsDependence = "Hoeffdings Dependence";
     40    private const string SpearmansRank = "Spearmans Rank";
     41    public IEnumerable<string> CorrelationCalculators {
     42      get { return new List<string>() { PrearsonsRSquared, HoeffdingsDependence, SpearmansRank }; }
     43    }
     44
     45    private const string AllSamples = "All Samples";
     46    private const string TrainingSamples = "Training Samples";
     47    private const string TestSamples = "Test Samples";
     48    public IEnumerable<string> Partitions {
     49      get { return new List<string>() { AllSamples, TrainingSamples, TestSamples }; }
     50    }
     51
    3752    private IDataAnalysisProblemData problemData;
     53    public IDataAnalysisProblemData ProblemData {
     54      get { return problemData; }
     55      set {
     56        if (problemData != value) {
     57          problemData = value;
     58          columnNames = value.Dataset.DoubleVariables.ToList();
     59          rowNames = value.Dataset.DoubleVariables.ToList();
     60          OnProblemDataChanged();
     61        }
     62      }
     63    }
    3864
    3965    private BackgroundWorker bw;
    40 
    41     public delegate void ProgressCalculationHandler(object sender, ProgressChangedEventArgs e);
    42     public event ProgressCalculationHandler ProgressCalculation;
    4366
    4467    public ExtendedHeatMap()
    4568      : base() {
    46       columnNames = Enumerable.Range(1, 2).Select(x => x.ToString()).ToList();
    47       rowNames = Enumerable.Range(1, 2).Select(x => x.ToString()).ToList();
     69      this.Title = "Feature Correlation";
     70      this.columnNames = Enumerable.Range(1, 2).Select(x => x.ToString()).ToList();
     71      this.rowNames = Enumerable.Range(1, 2).Select(x => x.ToString()).ToList();
    4872    }
    4973
     
    5680      CalculateElements(problemData.Dataset);
    5781    }
    58 
    59     private const string PrearsonsRSquared = "Pearsons R Squared";
    60     private const string HoeffdingsDependence = "Hoeffdings Dependence";
    61     private const string SpearmansRank = "Spearmans Rank";
    62     public IEnumerable<string> CorrelationCalculators {
    63       get { return new List<string>() { PrearsonsRSquared, HoeffdingsDependence, SpearmansRank }; }
    64     }
    65 
    66     private const string AllSamples = "All Samples";
    67     private const string TrainingSamples = "Training Samples";
    68     private const string TestSamples = "Test Samples";
    69     public IEnumerable<string> Partitions {
    70       get { return new List<string>() { AllSamples, TrainingSamples, TestSamples }; }
     82    protected ExtendedHeatMap(ExtendedHeatMap original, Cloner cloner)
     83      : base(original, cloner) {
     84      this.Title = "Feature Correlation";
     85      this.problemData = original.problemData;
     86      this.columnNames = original.problemData.Dataset.DoubleVariables.ToList();
     87      this.rowNames = original.problemData.Dataset.DoubleVariables.ToList();
     88    }
     89    public override IDeepCloneable Clone(Cloner cloner) {
     90      return new ExtendedHeatMap(this, cloner);
    7191    }
    7292
     
    143163    }
    144164
    145     private void bw_ProgressChanged(object sender, ProgressChangedEventArgs e) {
    146       BackgroundWorker worker = sender as BackgroundWorker;
    147       if (!worker.CancellationPending && ProgressCalculation != null) {
    148         ProgressCalculation(sender, e);
    149       }
    150     }
    151 
    152165    private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    153166      BackgroundWorker worker = sender as BackgroundWorker;
     
    164177    }
    165178
    166     private class BackgroundWorkerInfo {
     179    #region events
     180    public delegate void ProgressCalculationHandler(object sender, ProgressChangedEventArgs e);
     181    public event ProgressCalculationHandler ProgressCalculation;
     182    protected void bw_ProgressChanged(object sender, ProgressChangedEventArgs e) {
     183      BackgroundWorker worker = sender as BackgroundWorker;
     184      if (!worker.CancellationPending && ProgressCalculation != null) {
     185        ProgressCalculation(sender, e);
     186      }
     187    }
     188
     189    public event EventHandler ProblemDataChanged;
     190    protected virtual void OnProblemDataChanged() {
     191      var handler = ProblemDataChanged;
     192      if (handler != null) handler(this, EventArgs.Empty);
     193    }
     194    #endregion
     195
     196    protected class BackgroundWorkerInfo {
    167197      public Dataset Dataset { get; set; }
    168198      public string Calculator { get; set; }
Note: See TracChangeset for help on using the changeset viewer.