Changeset 14581
- Timestamp:
- 01/18/17 11:25:43 (8 years ago)
- Location:
- branches/DataPreprocessing Enhancements
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs
r14579 r14581 44 44 45 45 if (Content != null) { 46 foreach (string var in Content.GetVariableNamesForGrouping()) {46 foreach (string var in GetVariableNamesForGrouping(Content.PreprocessingData)) { 47 47 classifierComboBox.Items.Add(var); 48 48 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs
r14511 r14581 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Drawing; … … 35 36 [Content(typeof(PreprocessingChartContent), false)] 36 37 public partial class PreprocessingChartView : PreprocessingCheckedVariablesView { 37 38 private const int MAX_DISTINCT_VALUES_FOR_GROUPING = 20; 38 39 protected Dictionary<string, DataTable> dataTables; 39 40 protected Dictionary<string, DataTableControl> dataTableControls; … … 54 55 InitializeComponent(); 55 56 dataTables = new Dictionary<string, DataTable>(); 56 dataTableControls = new Dictionary<string, DataTableControl>();57 dataTableControls = new Dictionary<string, DataTableControl>(); 57 58 } 58 59 … … 63 64 GenerateLayout(); 64 65 } 66 } 67 68 protected static IEnumerable<string> GetVariableNamesForGrouping(IPreprocessingData preprocessingData) { 69 var variableNames = new List<string>(); 70 71 for (int i = 0; i < preprocessingData.Columns; ++i) { 72 int distinctValues = Int32.MaxValue; 73 if (preprocessingData.VariableHasType<double>(i)) 74 distinctValues = preprocessingData.GetValues<double>(i).GroupBy(x => x).Count(); 75 else if (preprocessingData.VariableHasType<string>(i)) 76 distinctValues = preprocessingData.GetValues<string>(i).GroupBy(x => x).Count(); 77 else if (preprocessingData.VariableHasType<DateTime>(i)) 78 distinctValues = preprocessingData.GetValues<DateTime>(i).GroupBy(x => x).Count(); 79 80 if (distinctValues <= MAX_DISTINCT_VALUES_FOR_GROUPING) 81 variableNames.Add(preprocessingData.GetVariableName(i)); 82 } 83 return variableNames; 65 84 } 66 85 -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/HistogramContent.cs
r14579 r14581 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 22 using System.Drawing; 25 using System.Linq;26 23 using HeuristicLab.Common; 27 24 using HeuristicLab.Core; … … 30 27 [Item("Histogram", "Represents the histogram grid.")] 31 28 public class HistogramContent : PreprocessingChartContent { 32 33 29 public static new Image StaticItemImage { 34 30 get { return HeuristicLab.Common.Resources.VSImageLibrary.Statistics; } 35 31 } 36 37 private const int MAX_DISTINCT_VALUES_FOR_GROUPING = 20;38 32 39 33 public string GroupingVariableName { get; set; } … … 55 49 } 56 50 57 public IEnumerable<string> GetVariableNamesForGrouping() {58 var variableNames = new List<string>();59 51 60 for (int i = 0; i < PreprocessingData.Columns; ++i) {61 int distinctValues = int.MaxValue;62 if (PreprocessingData.VariableHasType<double>(i))63 distinctValues = PreprocessingData.GetValues<double>(i).GroupBy(x => x).Count();64 else if (PreprocessingData.VariableHasType<string>(i))65 distinctValues = PreprocessingData.GetValues<string>(i).GroupBy(x => x).Count();66 else if (PreprocessingData.VariableHasType<DateTime>(i))67 distinctValues = PreprocessingData.GetValues<DateTime>(i).GroupBy(x => x).Count();68 69 if (distinctValues <= MAX_DISTINCT_VALUES_FOR_GROUPING)70 variableNames.Add(PreprocessingData.GetVariableName(i));71 }72 return variableNames;73 }74 52 } 75 53 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/PreprocessingChartContent.cs
r14511 r14581 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Drawing; 25 using System.Linq; 24 26 using HeuristicLab.Analysis; 25 27 using HeuristicLab.Common; 28 using HeuristicLab.Common.Resources; 26 29 using HeuristicLab.Core; 27 30 using HeuristicLab.Data; … … 31 34 public class PreprocessingChartContent : Item, IViewShortcut { 32 35 public static new Image StaticItemImage { 33 get { return HeuristicLab.Common.Resources.VSImageLibrary.PieChart; }36 get { return VSImageLibrary.PieChart; } 34 37 } 35 38 … … 38 41 get { 39 42 if (variableItemList == null) 40 variableItemList = CreateVariableItemList( );43 variableItemList = CreateVariableItemList(PreprocessingData); 41 44 return this.variableItemList; 42 45 } 43 //set { this.variableItemList = value; }44 46 } 45 47 46 48 public IFilteredPreprocessingData PreprocessingData { get; private set; } 49 public event DataPreprocessingChangedEventHandler Changed { 50 add { PreprocessingData.Changed += value; } 51 remove { PreprocessingData.Changed -= value; } 52 } 47 53 48 54 public PreprocessingChartContent(IFilteredPreprocessingData preprocessingData) { … … 66 72 } 67 73 68 69 70 71 public ICheckedItemList<StringValue> CreateVariableItemList() { 74 private static ICheckedItemList<StringValue> CreateVariableItemList(IPreprocessingData preprocessingData) { 72 75 ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>(); 73 foreach (string name in PreprocessingData.GetDoubleVariableNames()) {76 foreach (string name in preprocessingData.GetDoubleVariableNames()) { 74 77 var n = new StringValue(name); 75 bool isInputTarget = PreprocessingData.InputVariables.Contains(name) || PreprocessingData.TargetVariable == name;78 bool isInputTarget = preprocessingData.InputVariables.Contains(name) || preprocessingData.TargetVariable == name; 76 79 itemList.Add(n, isInputTarget); 77 80 } 78 81 return new ReadOnlyCheckedItemList<StringValue>(itemList); 79 82 } 80 81 public event DataPreprocessingChangedEventHandler Changed {82 add { PreprocessingData.Changed += value; }83 remove { PreprocessingData.Changed -= value; }84 }85 86 83 } 87 84 }
Note: See TracChangeset
for help on using the changeset viewer.