Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationCache.cs @ 10129

Last change on this file since 10129 was 8578, checked in by sforsten, 12 years ago

#1292:

  • added ProblemDataView which has a button to open the feature correlation
  • added abstract base class for feature correlations
  • added caches for the feature correlation
  • created own class for calculation of feature correlation
  • changed SelectedItemChanged to SelectionChangeCommitted events, so the correlation is only calculated if the user changes the selection
File size: 2.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#endregion
22
23using System;
24using System.Collections.Generic;
25using HeuristicLab.PluginInfrastructure;
26using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;
27
28namespace HeuristicLab.Problems.DataAnalysis.Views {
29  [NonDiscoverableType]
30  internal class FeatureCorrelationCache : Object {
31    private Dictionary<FCE.CorrelationCalculators, Dictionary<FCE.Partitions, double[,]>> correlationsCache;
32
33    public FeatureCorrelationCache()
34      : base() {
35      InitializeCaches();
36    }
37
38    private void InitializeCaches() {
39      correlationsCache = new Dictionary<FCE.CorrelationCalculators, Dictionary<FCE.Partitions, double[,]>>();
40      foreach (var calc in FCE.EnumToList<FCE.CorrelationCalculators>()) {
41        correlationsCache.Add(calc, new Dictionary<FCE.Partitions, double[,]>());
42      }
43    }
44
45    public void Reset() {
46      InitializeCaches();
47    }
48
49    public double[,] GetCorrelation(FCE.CorrelationCalculators calc, FCE.Partitions partition) {
50      double[,] corr;
51      correlationsCache[calc].TryGetValue(partition, out corr);
52      return corr;
53    }
54
55    public void SetCorrelation(FCE.CorrelationCalculators calc, FCE.Partitions partition, double[,] correlation) {
56      correlationsCache[calc][partition] = correlation;
57    }
58  }
59}
Note: See TracBrowser for help on using the repository browser.