Changeset 8483


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

#1292:

  • Renamed ExtendedHeatMap to FeatureCorrelation
  • deleted old CorrelationHeatMapView
  • added FeatureCorrelationView
Location:
branches/DatasetFeatureCorrelation
Files:
3 added
4 deleted
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r8276 r8483  
    172172      <DependentUpon>ClassificationEnsembleSolutionModelView.cs</DependentUpon>
    173173    </Compile>
    174     <Compile Include="CorrelationHeatMapView.cs">
    175       <SubType>UserControl</SubType>
    176     </Compile>
    177     <Compile Include="CorrelationHeatMapView.Designer.cs">
    178       <DependentUpon>CorrelationHeatMapView.cs</DependentUpon>
     174    <Compile Include="FeatureCorrelationView.cs">
     175      <SubType>UserControl</SubType>
     176    </Compile>
     177    <Compile Include="FeatureCorrelationView.Designer.cs">
     178      <DependentUpon>FeatureCorrelationView.cs</DependentUpon>
    179179    </Compile>
    180180    <Compile Include="DataAnalysisSolutionEvaluationView.cs">
     
    183183    <Compile Include="DataAnalysisSolutionEvaluationView.Designer.cs">
    184184      <DependentUpon>DataAnalysisSolutionEvaluationView.cs</DependentUpon>
    185     </Compile>
    186     <Compile Include="ExtendedHeatMapView.cs">
    187       <SubType>UserControl</SubType>
    188     </Compile>
    189     <Compile Include="ExtendedHeatMapView.Designer.cs">
    190       <DependentUpon>ExtendedHeatMapView.cs</DependentUpon>
    191185    </Compile>
    192186    <Compile Include="Plugin.cs" />
     
    350344  <ItemGroup>
    351345    <Folder Include="obj\" />
     346  </ItemGroup>
     347  <ItemGroup>
     348    <EmbeddedResource Include="FeatureCorrelationView.resx">
     349      <DependentUpon>FeatureCorrelationView.cs</DependentUpon>
     350    </EmbeddedResource>
    352351  </ItemGroup>
    353352  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r8294 r8483  
    158158    <Compile Include="Implementation\Clustering\ClusteringProblemData.cs" />
    159159    <Compile Include="Implementation\Clustering\ClusteringSolution.cs" />
    160     <Compile Include="Implementation\ExtendedHeatMap.cs" />
     160    <Compile Include="Implementation\FeatureCorrelation.cs" />
    161161    <Compile Include="Implementation\Regression\ConstantRegressionModel.cs" />
    162162    <Compile Include="Implementation\Regression\ConstantRegressionSolution.cs" />
     
    215215    <Compile Include="OnlineCalculators\OnlineMeanSquaredErrorCalculator.cs" />
    216216    <Compile Include="OnlineCalculators\OnlineNormalizedMeanSquaredErrorCalculator.cs" />
     217    <Compile Include="Implementation\Regression\RegressionSolution.cs" />
    217218    <Compile Include="OnlineCalculators\OnlinePearsonsRSquaredCalculator.cs" />
    218     <Compile Include="Implementation\Regression\RegressionSolution.cs" />
    219219    <Compile Include="OnlineCalculators\SpearmansRankCorrelationCoefficientCalculator.cs" />
    220220    <Compile Include="Plugin.cs" />
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r8318 r8483  
    5252      get { return (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName]; }
    5353    }
    54     public IFixedValueParameter<ExtendedHeatMap> DatasetHeatMapParameter {
    55       get { return (IFixedValueParameter<ExtendedHeatMap>)Parameters[DatasetHeatMapParameterName]; }
     54    public IFixedValueParameter<FeatureCorrelation> DatasetHeatMapParameter {
     55      get { return (IFixedValueParameter<FeatureCorrelation>)Parameters[DatasetHeatMapParameterName]; }
    5656    }
    5757    #endregion
     
    7878      get { return TestPartitionParameter.Value; }
    7979    }
    80     public ExtendedHeatMap DatasetHeatMap {
     80    public FeatureCorrelation DatasetHeatMap {
    8181      get { return DatasetHeatMapParameter.Value; }
    8282    }
     
    120120      #region Backwards compatible code, remove with 3.4
    121121      if (!Parameters.ContainsKey(DatasetHeatMapParameterName)) {
    122         Parameters.Add(new FixedValueParameter<ExtendedHeatMap>(DatasetHeatMapParameterName, "", new ExtendedHeatMap()));
     122        Parameters.Add(new FixedValueParameter<FeatureCorrelation>(DatasetHeatMapParameterName, "", new FeatureCorrelation()));
    123123      }
    124124      #endregion
     
    147147      Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", new IntRange(trainingPartitionStart, trainingPartitionEnd)));
    148148      Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd)));
    149       Parameters.Add(new FixedValueParameter<ExtendedHeatMap>(DatasetHeatMapParameterName, "", new ExtendedHeatMap(this)));
     149      Parameters.Add(new FixedValueParameter<FeatureCorrelation>(DatasetHeatMapParameterName, "", new FeatureCorrelation(this)));
    150150
    151151      ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
  • 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
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlinePearsonsRSquaredCalculator.cs

    r7259 r8483  
    3030    private OnlineMeanAndVarianceCalculator syCalculator = new OnlineMeanAndVarianceCalculator();
    3131
    32     public double RSquared {
     32    public double PearsonsR {
    3333      get {
    3434        double xVar = sxCalculator.PopulationVariance;
     
    3838        } else {
    3939          double r = covCalculator.Covariance / (Math.Sqrt(xVar) * Math.Sqrt(yVar));
    40           return r * r;
     40          return r;
    4141        }
     42      }
     43    }
     44
     45    public double RSquared {
     46      get {
     47        return Math.Pow(PearsonsR, 2);
    4248      }
    4349    }
     
    6773    #endregion
    6874
    69     public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
     75    public static double CalculateR(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
    7076      IEnumerator<double> firstEnumerator = first.GetEnumerator();
    7177      IEnumerator<double> secondEnumerator = second.GetEnumerator();
     
    8692      } else {
    8793        errorState = rSquaredCalculator.ErrorState;
    88         return rSquaredCalculator.RSquared;
     94        return rSquaredCalculator.PearsonsR;
    8995      }
     96    }
     97
     98    public static double Calculate(IEnumerable<double> first, IEnumerable<double> second, out OnlineCalculatorError errorState) {
     99      return Math.Pow(CalculateR(first, second, out errorState), 2);
    90100    }
    91101  }
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/SpearmansRankCorrelationCoefficientCalculator.cs

    r8294 r8483  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
     
    2827
    2928    public static double Calculate(IEnumerable<double> originalValues, IEnumerable<double> estimatedValues, out OnlineCalculatorError errorState) {
    30       double rs = Math.Abs(alglib.basestat.spearmancorr2(originalValues.ToArray(), estimatedValues.ToArray(), originalValues.Count()));
     29      double rs = alglib.basestat.spearmancorr2(originalValues.ToArray(), estimatedValues.ToArray(), originalValues.Count());
    3130      errorState = OnlineCalculatorError.None;
    3231      return rs;
Note: See TracChangeset for help on using the changeset viewer.