Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/14/12 13:05:48 (12 years ago)
Author:
sforsten
Message:

#1292:

  • Renamed ExtendedHeatMap to FeatureCorrelation
  • deleted old CorrelationHeatMapView
  • added FeatureCorrelationView
File:
1 moved

Legend:

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

    r8481 r8483  
    3333namespace HeuristicLab.Problems.DataAnalysis {
    3434  [StorableClass]
    35   [Item("HeatMap", "Represents a heat map of double values.")]
    36   public class ExtendedHeatMap : HeatMap {
    37 
    38     private const string PrearsonsRSquared = "Pearsons R Squared";
     35  [Item("FeatureCorrelation", "Represents the correlation of features in a data set.")]
     36  public class FeatureCorrelation : HeatMap {
     37
     38    private const string PearsonsR = "Pearsons R";
     39    private const string PearsonsRSquared = "Pearsons R Squared";
    3940    private const string HoeffdingsDependence = "Hoeffdings Dependence";
    4041    private const string SpearmansRank = "Spearmans Rank";
    4142    public IEnumerable<string> CorrelationCalculators {
    42       get { return new List<string>() { PrearsonsRSquared, HoeffdingsDependence, SpearmansRank }; }
     43      get { return new List<string>() { PearsonsR, PearsonsRSquared, HoeffdingsDependence, SpearmansRank }; }
    4344    }
    4445
     
    6566    private BackgroundWorker bw;
    6667
    67     public ExtendedHeatMap()
     68    public FeatureCorrelation()
    6869      : base() {
    6970      this.Title = "Feature Correlation";
    7071      this.columnNames = Enumerable.Range(1, 2).Select(x => x.ToString()).ToList();
    7172      this.rowNames = Enumerable.Range(1, 2).Select(x => x.ToString()).ToList();
    72     }
    73 
    74     public ExtendedHeatMap(IDataAnalysisProblemData problemData) {
     73      sortableView = true;
     74    }
     75
     76    public FeatureCorrelation(IDataAnalysisProblemData problemData) {
    7577      this.problemData = problemData;
    7678      this.Title = "Feature Correlation";
    7779      this.columnNames = problemData.Dataset.DoubleVariables.ToList();
    7880      this.rowNames = problemData.Dataset.DoubleVariables.ToList();
     81      sortableView = true;
    7982
    8083      CalculateElements(problemData.Dataset);
    8184    }
    82     protected ExtendedHeatMap(ExtendedHeatMap original, Cloner cloner)
     85    protected FeatureCorrelation(FeatureCorrelation original, Cloner cloner)
    8386      : base(original, cloner) {
    8487      this.Title = "Feature Correlation";
     
    8891    }
    8992    public override IDeepCloneable Clone(Cloner cloner) {
    90       return new ExtendedHeatMap(this, cloner);
     93      return new FeatureCorrelation(this, cloner);
    9194    }
    9295
     
    112115      }
    113116      bw.RunWorkerAsync(new BackgroundWorkerInfo { Dataset = dataset, Calculator = calc, Partition = partition });
     117      if (calc.Equals(PearsonsR) || calc.Equals(SpearmansRank)) {
     118        Maximum = 1.0;
     119        Minimum = -1.0;
     120      } else if (calc.Equals(HoeffdingsDependence)) {
     121        Maximum = 1.0;
     122        Minimum = -0.5;
     123      } else {
     124        Maximum = 1.0;
     125        Minimum = 0.0;
     126      }
    114127    }
    115128
     
    128141
    129142      double calculations = (Math.Pow(length, 2) + length) / 2;
     143
     144      worker.ReportProgress(0);
    130145
    131146      for (int i = 0; i < length; i++) {
     
    150165          } else if (calc.Equals(SpearmansRank)) {
    151166            elements[i, j] = SpearmansRankCorrelationCoefficientCalculator.Calculate(var1, var2, out error);
     167          } else if (calc.Equals(PearsonsRSquared)) {
     168            elements[i, j] = OnlinePearsonsRSquaredCalculator.Calculate(var1, var2, out error);
    152169          } else {
    153             elements[i, j] = OnlinePearsonsRSquaredCalculator.Calculate(var1, var2, out error);
     170            elements[i, j] = OnlinePearsonsRSquaredCalculator.CalculateR(var1, var2, out error);
    154171          }
    155172          elements[j, i] = elements[i, j];
    156173          if (!error.Equals(OnlineCalculatorError.None)) {
    157             throw new ArgumentException("Calculator returned " + error);
     174            worker.ReportProgress(100);
     175            throw new ArgumentException("Calculator returned " + error + Environment.NewLine + "Maybe try another calculator.");
    158176          }
    159177          worker.ReportProgress((int)Math.Round((((Math.Pow(i, 2) + i) / 2 + j + 1.0) / calculations) * 100));
     
    172190          OnReset();
    173191        }
    174       } else {
    175         Console.WriteLine("Backgroundworker canceled");
    176192      }
    177193    }
     
    189205    public event EventHandler ProblemDataChanged;
    190206    protected virtual void OnProblemDataChanged() {
    191       var handler = ProblemDataChanged;
    192       if (handler != null) handler(this, EventArgs.Empty);
     207      EventHandler handler = ProblemDataChanged;
     208      if (handler != null)
     209        handler(this, EventArgs.Empty);
    193210    }
    194211    #endregion
Note: See TracChangeset for help on using the changeset viewer.