- Timestamp:
- 05/28/14 15:09:26 (11 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 12 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataPreprocessingView.cs
r10905 r10908 26 26 using HeuristicLab.Core.Views; 27 27 using HeuristicLab.MainForm; 28 using HeuristicLab.DataPreprocessing; 29 using HeuristicLab.Problems.DataAnalysis; 28 30 29 31 namespace HeuristicLab.DataPreprocessing.Views { … … 50 52 var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic, dataGridLogic); 51 53 var chartLogic = new ChartLogic(data); 54 var correlationMatrixLogic = new ChartLogic(data); 52 55 var filterLogic = new FilterLogic(data); 56 var creator = new ProblemDataCreator(Content); 57 var problemData = (DataAnalysisProblemData)creator.CreateProblemData(); 53 58 var dataCompletenessLogic = new ChartLogic(data); 54 59 … … 61 66 new LineChartContent(chartLogic), 62 67 new HistogramContent(chartLogic), 63 new ScatterPlotContent(chartLogic) 64 //, 65 //new DataCompletenessChartContent(dataCompletenessLogic) 68 new ScatterPlotContent(chartLogic), 69 new CorrelationMatrixContent(problemData) 66 70 }; 67 71 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/HeuristicLab.DataPreprocessing.Views-3.3.csproj
r10904 r10908 64 64 </ItemGroup> 65 65 <ItemGroup> 66 <Compile Include="PreprocessingFeatureCorrelationView.cs"> 67 <SubType>UserControl</SubType> 68 </Compile> 69 <Compile Include="PreprocessingFeatureCorrelationView.Designer.cs"> 70 <DependentUpon>PreprocessingFeatureCorrelationView.cs</DependentUpon> 71 </Compile> 66 72 <Compile Include="CheckedFilterCollectionView.cs"> 67 73 <SubType>UserControl</SubType> -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/HistogramView.Designer.cs
r10867 r10908 54 54 // 55 55 this.classifierComboBox.FormattingEnabled = true; 56 this.classifierComboBox.Location = new System.Drawing.Point( 6, 52);56 this.classifierComboBox.Location = new System.Drawing.Point(9, 52); 57 57 this.classifierComboBox.Name = "classifierComboBox"; 58 58 this.classifierComboBox.Size = new System.Drawing.Size(121, 21); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/HistogramView.cs
r10871 r10908 9 9 [Content(typeof(HistogramContent), true)] 10 10 public partial class HistogramView : PreprocessingChartView { 11 12 11 private const string HISTOGRAM_CHART_TITLE = "Histogram"; 13 12 … … 26 25 27 26 classifierComboBox.Items.Clear(); 28 29 27 classifierComboBox.Items.Add("None"); 30 28 31 foreach(string var in logic.GetVariableNames ()){29 foreach(string var in logic.GetVariableNamesForHistogramClassification()){ 32 30 classifierComboBox.Items.Add(var); 33 31 } 34 32 33 35 34 if (classifierComboBox.SelectedItem == null) { 36 // classifierComboBox.SelectedIndex = 0;37 38 35 classifierComboBox.SelectedIndex = Content.ClassifierVariableIndex; 39 36 } … … 46 43 } 47 44 48 private void classifierComboBox_SelectedIndexChanged(object sender, EventArgs e) 49 { 45 private void classifierComboBox_SelectedIndexChanged(object sender, EventArgs e) { 50 46 if (classifierComboBox.SelectedItem == null) 51 47 return; 52 48 53 54 if (classifierComboBox.SelectedIndex != 0) 55 { 56 classification = logic.GetVariableValues(classifierComboBox.SelectedItem.ToString()); 57 } 58 else { 59 classification = null; 49 if (classifierComboBox.SelectedIndex != 0) { 50 Classification = logic.GetVariableValues(classifierComboBox.SelectedItem.ToString()); 51 } else { 52 Classification = null; 60 53 } 61 54 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingChartView.cs
r10867 r10908 49 49 private const string DEFAULT_CHART_TITLE = "Chart"; 50 50 51 public List<double> classification { get; set; }51 public IEnumerable<double> Classification { get; set; } 52 52 53 53 public PreprocessingChartView() { … … 82 82 } 83 83 84 //if (!Content.AllInOneMode) 85 if (Content != null && !Content.AllInOneMode) 84 if (Content != null && !Content.AllInOneMode) 86 85 GenerateChart(); 87 86 … … 336 335 337 336 PreprocessingDataTableView dataView = new PreprocessingDataTableView(); 338 dataView. classification = classification;337 dataView.Classification = Classification; 339 338 enumerator.MoveNext(); 340 339 PreprocessingDataTable d = enumerator.Current; -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingDataTableView.cs
r10877 r10908 48 48 } 49 49 50 public List<double> classification { get; set; }50 public IEnumerable<double> Classification { get; set; } 51 51 52 52 public PreprocessingDataTableView() … … 115 115 #endregion 116 116 117 protected override void OnContentChanged() 118 { 117 protected override void OnContentChanged() { 119 118 base.OnContentChanged(); 120 119 invisibleSeries.Clear(); … … 126 125 { 127 126 128 if (classification != null) 129 { 127 if (Classification != null) 130 128 chart.Titles[0].Text = Content.Name; 131 }132 129 133 130 AddDataRows(Content.Rows); … … 166 163 FillSeriesWithRowValues(series, row); 167 164 168 if (classification == null) 169 { 170 chart.Series.Add(series); 171 } 165 if (Classification == null) 166 chart.Series.Add(series); 172 167 } 173 168 … … 202 197 FillSeriesWithRowValues(series, row); 203 198 204 if ( classification == null) {205 chart.Series.Add(series);206 }199 if (Classification == null) 200 chart.Series.Add(series); 201 207 202 } 208 203 } … … 735 730 } 736 731 737 protected virtual void CalculateHistogram(Series series, DataRow row) 738 { 739 if (classification != null) 740 { 741 742 var qry = row.Values.Select((i, index) => new { i, j = classification[index] }) 743 .GroupBy((x) => x.j).ToDictionary(x => x.Key, x => x.Select(v => v.i).ToList()); 732 protected virtual void CalculateHistogram(Series series, DataRow row) { 733 if (Classification != null) { 734 735 var valuesPerClass = row.Values.Select((i, index) => new { i, j = Classification.ToList()[index] }) 736 .GroupBy((x) => x.j) 737 .ToDictionary(x => x.Key, x => x.Select(v => v.i) 738 .ToList()); 739 744 740 chart.Titles.Add(row.Name); 745 foreach (KeyValuePair<double, List<double>> entry in qry) 746 {741 742 foreach (KeyValuePair<double, List<double>> entry in valuesPerClass) { 747 743 var s = new Series(row.Name + entry.Key); 748 744 … … 754 750 chart.Series.Add(s); 755 751 } 756 } 757 else 758 { 759 series.Points.Clear(); 752 } else { 753 series.Points.Clear(); 760 754 ConfigureSeries(series, row); 761 755 AddPointsToHistogramSeries(series, row, null); … … 763 757 } 764 758 765 private void AddPointsToHistogramSeries(Series series, DataRow row, List<double> values) 766 { 767 759 private void AddPointsToHistogramSeries(Series series, DataRow row, List<double> values) { 768 760 if (!row.Values.Any()) return; 769 761 int bins = row.VisualProperties.Bins; … … 819 811 820 812 // shift the chart to the left so the bars are placed on the intervals 821 if ( classification != null || valueFrequencies.First().Item1 < doubleRange.First()) {813 if (Classification != null || valueFrequencies.First().Item1 < doubleRange.First()) { 822 814 series.Points.Add(new DataPoint(min - intervalWidth, 0)); 823 815 series.Points.Add(new DataPoint(max + intervalWidth, 0)); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingFeatureCorrelationView.Designer.cs
r10870 r10908 23 23 24 24 namespace HeuristicLab.Problems.DataAnalysis.Views { 25 partial class AbstractFeatureCorrelationView {25 partial class PreprocessingFeatureCorrelationView { 26 26 /// <summary> 27 27 /// Required designer variable. -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingFeatureCorrelationView.cs
r10870 r10908 28 28 using HeuristicLab.MainForm.WindowsForms; 29 29 using HeuristicLab.PluginInfrastructure; 30 using System; 31 using HeuristicLab.DataPreprocessing; 30 32 31 33 namespace HeuristicLab.Problems.DataAnalysis.Views { 32 [View(" Feature Correlation View")]33 [Content(typeof( DataAnalysisProblemData), false)]34 public abstract partial class AbstractFeatureCorrelationView : AsynchronousContentView {34 [View("Preprocessing Feature Correlation View")] 35 [Content(typeof(CorrelationMatrixContent), false)] 36 public partial class PreprocessingFeatureCorrelationView : AsynchronousContentView { 35 37 public const string ALLSAMPLES = "All Samples"; 36 38 public const string TRAININGSAMPLES = "Training Samples"; … … 41 43 protected FeatureCorrelationCalculator fcc; 42 44 43 public new DataAnalysisProblemData Content { 44 get { return (DataAnalysisProblemData)base.Content; } 45 public new CorrelationMatrixContent Content 46 { 47 get { return (CorrelationMatrixContent) base.Content; } 45 48 set { base.Content = value; } 46 49 } 47 50 48 protected AbstractFeatureCorrelationView() { 51 private FeatureCorrelationCache correlationCache; 52 53 public PreprocessingFeatureCorrelationView() { 54 55 correlationCache = new FeatureCorrelationCache(); 49 56 InitializeComponent(); 50 57 fcc = new FeatureCorrelationCalculator(); … … 75 82 fcc.TryCancelCalculation(); 76 83 if (Content != null) { 77 fcc.ProblemData = Content ;84 fcc.ProblemData = Content.ProblemData; 78 85 CalculateCorrelation(); 79 86 } else { … … 86 93 87 94 protected virtual bool[] SetInitialVariableVisibility() { 88 bool[] initialVisibility = new bool[Content. Dataset.DoubleVariables.Count()];95 bool[] initialVisibility = new bool[Content.ProblemData.Dataset.DoubleVariables.Count()]; 89 96 int i = 0; 90 foreach (var variable in Content. Dataset.DoubleVariables) {91 initialVisibility[i] = Content. AllowedInputVariables.Contains(variable);97 foreach (var variable in Content.ProblemData.Dataset.DoubleVariables) { 98 initialVisibility[i] = Content.ProblemData.AllowedInputVariables.Contains(variable); 92 99 i++; 93 100 } … … 102 109 } 103 110 104 protected abstract void CalculateCorrelation(); 105 protected abstract void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e); 111 protected void CalculateCorrelation() { 112 if (correlationCalcComboBox.SelectedItem == null) return; 113 if (partitionComboBox.SelectedItem == null) return; 114 115 IDependencyCalculator calc = (IDependencyCalculator)correlationCalcComboBox.SelectedValue; 116 string partition = (string)partitionComboBox.SelectedValue; 117 dataView.Enabled = false; 118 double[,] corr = correlationCache.GetCorrelation(calc, partition); 119 if (corr == null) { 120 fcc.CalculateElements(calc, partition); 121 } else { 122 fcc.TryCancelCalculation(); 123 var correlation = new DoubleMatrix(corr, Content.ProblemData.Dataset.DoubleVariables, Content.ProblemData.Dataset.DoubleVariables); 124 UpdateDataView(correlation); 125 } 126 } 127 128 protected void Content_CorrelationCalculationFinished(object sender, FeatureCorrelationCalculator.CorrelationCalculationFinishedArgs e) { 129 if (InvokeRequired) { 130 Invoke(new FeatureCorrelationCalculator.CorrelationCalculationFinishedHandler(Content_CorrelationCalculationFinished), sender, e); 131 return; 132 } 133 correlationCache.SetCorrelation(e.Calculcator, e.Partition, e.Correlation); 134 var correlation = new DoubleMatrix(e.Correlation, Content.ProblemData.Dataset.DoubleVariables, Content.ProblemData.Dataset.DoubleVariables); 135 UpdateDataView(correlation); 136 } 106 137 107 138 protected void UpdateDataView(DoubleMatrix correlation) { … … 125 156 progressBar.Value = e.ProgressPercentage; 126 157 } 158 159 [NonDiscoverableType] 160 private class FeatureCorrelationCache : Object { 161 private Dictionary<Tuple<IDependencyCalculator, string>, double[,]> correlationsCache; 162 163 public FeatureCorrelationCache() 164 : base() { 165 InitializeCaches(); 166 } 167 168 private void InitializeCaches() { 169 correlationsCache = new Dictionary<Tuple<IDependencyCalculator, string>, double[,]>(); 170 } 171 172 public void Reset() { 173 InitializeCaches(); 174 } 175 176 public double[,] GetCorrelation(IDependencyCalculator calc, string partition) { 177 double[,] corr; 178 var key = new Tuple<IDependencyCalculator, string>(calc, partition); 179 correlationsCache.TryGetValue(key, out corr); 180 return corr; 181 } 182 183 public void SetCorrelation(IDependencyCalculator calc, string partition, double[,] correlation) { 184 var key = new Tuple<IDependencyCalculator, string>(calc, partition); 185 correlationsCache[key] = correlation; 186 } 187 } 127 188 } 128 189 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/HeuristicLab.DataPreprocessing-3.3.csproj
r10882 r10908 81 81 <Compile Include="Implementations\PreprocessingDataTable.cs" /> 82 82 <Compile Include="Interfaces\IFilteredPreprocessingData.cs" /> 83 <Compile Include="Implementations\CorrelationMatrixContent.cs" /> 83 84 <Compile Include="PreprocessingTransformator.cs" /> 84 85 <Compile Include="Utils\DataPreprocessingChangedEvent.cs" /> -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ChartLogic.cs
r10882 r10908 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 32 32 33 33 public class ChartLogic : IChartLogic { 34 34 private const int MAX_DISTINCT_VALUES_FOR_CLASSIFCATION = 20; 35 35 private ITransactionalPreprocessingData preprocessingData; 36 36 … … 63 63 } 64 64 65 public List<double> GetVariableValues(string variableName) {66 return preprocessingData.GetValues<double>(preprocessingData.GetColumnIndex(variableName)) .ToList();65 public IEnumerable<double> GetVariableValues(string variableName) { 66 return preprocessingData.GetValues<double>(preprocessingData.GetColumnIndex(variableName)); 67 67 } 68 68 … … 74 74 if (preprocessingData.IsType<double>(preprocessingData.GetColumnIndex(variableName))) 75 75 doubleVariableNames.Add(variableName); 76 } 77 78 return doubleVariableNames; 79 } 80 81 public IEnumerable<string> GetVariableNamesForHistogramClassification() { 82 List<string> doubleVariableNames = new List<string>(); 83 84 //only return variable names from type double 85 foreach (string variableName in preprocessingData.VariableNames) 86 { 87 int columnIndex = preprocessingData.GetColumnIndex(variableName); 88 bool isDouble = preprocessingData.IsType<double>(columnIndex); 89 double distinctValueCount = preprocessingData.GetValues<double>(columnIndex).GroupBy(x => x).Count(); 90 bool distinctValuesOk = distinctValueCount <= MAX_DISTINCT_VALUES_FOR_CLASSIFCATION; 91 92 if (isDouble && distinctValuesOk) 93 doubleVariableNames.Add(variableName); 76 94 } 77 95 … … 146 164 147 165 148 List<double> xValues = GetVariableValues(variableNameX) ;149 List<double> yValues = GetVariableValues(variableNameY) ;166 List<double> xValues = GetVariableValues(variableNameX).ToList(); 167 List<double> yValues = GetVariableValues(variableNameY).ToList(); 150 168 151 169 List<Point2D<double>> points = new List<Point2D<double>>(); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/CorrelationMatrixContent.cs
r10870 r10908 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Problems.DataAnalysis; 25 26 26 27 namespace HeuristicLab.DataPreprocessing { 27 28 28 [Item("LineChart", "Represents the line chart grid.")] 29 public class LineChartContent : PreprocessingChartContent { 29 [Item("Feature Correlation Matrix", "Represents the feature correlation matrix.")] 30 public class CorrelationMatrixContent : Item, IViewShortcut 31 { 32 public DataAnalysisProblemData ProblemData { get; set; } 30 33 31 public LineChartContent(IChartLogic chartlogic)32 : base(chartlogic) {34 public CorrelationMatrixContent(DataAnalysisProblemData data) { 35 ProblemData = data; 33 36 } 34 37 35 public LineChartContent(LineChartContent content, Cloner cloner)36 : base( content, cloner) {37 38 public CorrelationMatrixContent(CorrelationMatrixContent original, Cloner cloner) 39 : base(original, cloner) { 40 38 41 } 39 42 40 43 public static new Image StaticItemImage { 41 get { return HeuristicLab.Common.Resources.VSImageLibrary. Performance; }44 get { return HeuristicLab.Common.Resources.VSImageLibrary.Gradient; } 42 45 } 43 46 44 47 public override IDeepCloneable Clone(Cloner cloner) { 45 return new LineChartContent(this, cloner);48 return new CorrelationMatrixContent(this, cloner); 46 49 } 47 48 50 } 49 51 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilterLogic.cs
r10900 r10908 27 27 namespace HeuristicLab.DataPreprocessing { 28 28 public class FilterLogic : IFilterLogic { 29 30 29 private IFilteredPreprocessingData preprocessingData; 31 30 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/HistogramContent.cs
r10871 r10908 36 36 public HistogramContent(HistogramContent content, Cloner cloner) 37 37 : base(content, cloner) { 38 39 38 } 40 39 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IChartLogic.cs
r10882 r10908 50 50 51 51 IEnumerable<string> GetVariableNames(); 52 List<double> GetVariableValues(string variableName); 52 IEnumerable<string> GetVariableNamesForHistogramClassification(); 53 54 IEnumerable<double> GetVariableValues(string variableName); 53 55 } 54 56 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/ProblemDataCreator.cs
r10772 r10908 26 26 27 27 namespace HeuristicLab.DataPreprocessing { 28 internalclass ProblemDataCreator {28 public class ProblemDataCreator { 29 29 30 30 private readonly IPreprocessingContext context;
Note: See TracChangeset
for help on using the changeset viewer.