- Timestamp:
- 06/11/14 15:06:24 (10 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4
- Files:
-
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj
r10962 r10992 94 94 <Compile Include="Implementations\HistogramContent.cs" /> 95 95 <Compile Include="Implementations\LineChartContent.cs" /> 96 <Compile Include="Implementations\ChartLogic.cs" />97 96 <Compile Include="Implementations\StatisticsContent.cs" /> 98 97 <Compile Include="Implementations\TransformationContent.cs" /> 99 98 <Compile Include="Interfaces\IFilterLogic.cs" /> 100 <Compile Include="Interfaces\IChartLogic.cs" />101 99 <Compile Include="Interfaces\IManipulationLogic.cs" /> 102 100 <Compile Include="Interfaces\ITransformationLogic.cs" /> -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/FilteredPreprocessingData.cs
r10978 r10992 13 13 private ITransactionalPreprocessingData filteredData; 14 14 15 15 public IDictionary<int, IList<int>> Selection { 16 16 get { return originalData.Selection; } 17 17 set { originalData.Selection = value; } … … 228 228 229 229 #endregion 230 231 #region IPreprocessingData Members 232 233 234 public IEnumerable<string> GetDoubleVariableNames() { 235 return originalData.GetDoubleVariableNames(); 236 } 237 238 #endregion 230 239 } 231 240 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/HistogramContent.cs
r10914 r10992 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using System.Drawing; 24 using System.Linq; 23 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Core; 27 using HeuristicLab.DataPreprocessing.Interfaces; 25 28 26 29 namespace HeuristicLab.DataPreprocessing { … … 28 31 public class HistogramContent : PreprocessingChartContent { 29 32 33 public static new Image StaticItemImage { 34 get { return HeuristicLab.Common.Resources.VSImageLibrary.Statistics; } 35 } 36 private const int MAX_DISTINCT_VALUES_FOR_CLASSIFCATION = 20; 37 30 38 private int classifierVariableIndex = 0; 31 32 public HistogramContent(IChartLogic chartlogic)33 : base(chartlogic) {34 AllInOneMode = false;35 }36 37 public HistogramContent(HistogramContent content, Cloner cloner)38 : base(content, cloner) {39 }40 39 41 40 public int ClassifierVariableIndex { … … 45 44 46 45 47 public static new Image StaticItemImage { 48 get { return HeuristicLab.Common.Resources.VSImageLibrary.Statistics; } 46 public HistogramContent(IFilteredPreprocessingData preprocessingData) 47 : base(preprocessingData) { 48 AllInOneMode = false; 49 49 } 50 50 51 public HistogramContent(HistogramContent content, Cloner cloner) 52 : base(content, cloner) { 53 } 51 54 public override IDeepCloneable Clone(Cloner cloner) { 52 55 return new HistogramContent(this, cloner); 53 56 } 57 58 public IEnumerable<string> GetVariableNamesForHistogramClassification() { 59 List<string> doubleVariableNames = new List<string>(); 60 61 //only return variable names from type double 62 for (int i = 0; i < PreprocessingData.Columns; ++i) { 63 if (PreprocessingData.IsType<double>(i)) { 64 double distinctValueCount = PreprocessingData.GetValues<double>(i).GroupBy(x => x).Count(); 65 bool distinctValuesOk = distinctValueCount <= MAX_DISTINCT_VALUES_FOR_CLASSIFCATION; 66 if (distinctValuesOk) 67 doubleVariableNames.Add(PreprocessingData.GetVariableName(i)); 68 } 69 } 70 return doubleVariableNames; 71 } 72 54 73 } 55 74 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/LineChartContent.cs
r10771 r10992 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.DataPreprocessing.Interfaces; 25 26 26 27 namespace HeuristicLab.DataPreprocessing { … … 29 30 public class LineChartContent : PreprocessingChartContent { 30 31 31 public LineChartContent(IChartLogic chartlogic) 32 : base(chartlogic) { 32 public static new Image StaticItemImage { 33 get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; } 34 } 35 36 public LineChartContent(IFilteredPreprocessingData preprocessingData) 37 : base(preprocessingData) { 33 38 } 34 39 35 40 public LineChartContent(LineChartContent content, Cloner cloner) 36 41 : base(content, cloner) { 37 38 42 } 39 40 public static new Image StaticItemImage {41 get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; }42 }43 44 43 public override IDeepCloneable Clone(Cloner cloner) { 45 44 return new LineChartContent(this, cloner); 46 45 } 47 48 46 } 49 47 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingChartContent.cs
r10967 r10992 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using System.Drawing; 25 using HeuristicLab.Analysis; 23 26 using HeuristicLab.Common; 24 27 using HeuristicLab.Core; 25 28 using HeuristicLab.Data; 26 using System; 27 using System.Collections.Generic; 29 using HeuristicLab.DataPreprocessing.Interfaces; 28 30 29 31 namespace HeuristicLab.DataPreprocessing { 30 32 [Item("PreprocessingChart", "Represents a preprocessing chart.")] 31 33 public class PreprocessingChartContent : Item, IViewChartShortcut { 34 public static new Image StaticItemImage { 35 get { return HeuristicLab.Common.Resources.VSImageLibrary.PieChart; } 36 } 32 37 33 38 private bool allInOneMode = true; 39 public bool AllInOneMode { 40 get { return this.allInOneMode; } 41 set { this.allInOneMode = value; } 42 } 34 43 35 44 private ICheckedItemList<StringValue> variableItemList = null; 45 public ICheckedItemList<StringValue> VariableItemList { 46 get { return this.variableItemList; } 47 set { this.variableItemList = value; } 48 } 36 49 50 public IFilteredPreprocessingData PreprocessingData { get; private set; } 37 51 38 private readonly IChartLogic chartLogic; 39 40 41 public PreprocessingChartContent(IChartLogic chartLogic) { 42 this.chartLogic = chartLogic; 52 public PreprocessingChartContent(IFilteredPreprocessingData preprocessingData) { 53 PreprocessingData = preprocessingData; 43 54 } 44 55 45 56 public PreprocessingChartContent(PreprocessingChartContent content, Cloner cloner) 46 57 : base(content, cloner) { 47 48 this.chartLogic = content.chartLogic;49 58 this.allInOneMode = content.allInOneMode; 59 this.PreprocessingData = cloner.Clone<IFilteredPreprocessingData>(PreprocessingData); 60 this.variableItemList = cloner.Clone<ICheckedItemList<StringValue>>(variableItemList); 50 61 } 51 52 public IChartLogic ChartLogic {53 get {54 return chartLogic;55 }56 }57 58 public static new Image StaticItemImage {59 get { return HeuristicLab.Common.Resources.VSImageLibrary.PieChart; }60 }61 62 62 public override IDeepCloneable Clone(Cloner cloner) { 63 63 return new PreprocessingChartContent(this, cloner); 64 64 } 65 65 66 public event DataPreprocessingChangedEventHandler Changed { 67 add { chartLogic.Changed += value; } 68 remove { chartLogic.Changed -= value; } 66 67 public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) { 68 IList<double> values = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableName)); 69 DataRow row = new DataRow(variableName, "", values); 70 row.VisualProperties.ChartType = chartType; 71 return row; 69 72 } 70 73 71 public bool AllInOneMode 72 { 73 get { return this.allInOneMode; } 74 set { this.allInOneMode = value; } 74 public List<DataRow> CreateAllDataRows(DataRowVisualProperties.DataRowChartType chartType) { 75 List<DataRow> dataRows = new List<DataRow>(); 76 foreach (var name in PreprocessingData.GetDoubleVariableNames()) 77 dataRows.Add(CreateDataRow(name, chartType)); 78 return dataRows; 75 79 } 76 80 77 public ICheckedItemList<StringValue> VariableItemList 78 { 79 get { return this.variableItemList; } 80 set { this.variableItemList = value; } 81 public DataRow CreateSelectedDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) { 82 83 IDictionary<int, IList<int>> selection = PreprocessingData.Selection; 84 int variableIndex = PreprocessingData.GetColumnIndex(variableName); 85 86 if (selection.Keys.Contains(variableIndex)) { 87 List<int> selectedIndices = new List<int>(selection[variableIndex]); 88 //need selection with more than 1 value 89 if (selectedIndices.Count < 2) 90 return null; 91 92 selectedIndices.Sort(); 93 int start = selectedIndices[0]; 94 int end = selectedIndices[selectedIndices.Count - 1]; 95 96 DataRow rowSelect = CreateDataRowRange(variableName, start, end, chartType); 97 return rowSelect; 98 } else 99 return null; 81 100 } 101 102 public DataRow CreateDataRowRange(string variableName, int start, int end, DataRowVisualProperties.DataRowChartType chartType) { 103 IList<double> values = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableName)); 104 IList<double> valuesRange = new List<double>(); 105 for (int i = 0; i < values.Count; i++) { 106 if (i >= start && i <= end) 107 valuesRange.Add(values[i]); 108 else 109 valuesRange.Add(Double.NaN); 110 } 111 112 DataRow row = new DataRow(variableName, "", valuesRange); 113 row.VisualProperties.ChartType = chartType; 114 return row; 115 } 116 117 public List<DataRow> CreateAllSelectedDataRows(DataRowVisualProperties.DataRowChartType chartType) { 118 List<DataRow> dataRows = new List<DataRow>(); 119 foreach (var name in PreprocessingData.GetDoubleVariableNames()) { 120 DataRow row = CreateSelectedDataRow(name, chartType); 121 if (row != null) 122 dataRows.Add(row); 123 } 124 return dataRows; 125 } 126 127 128 public ICheckedItemList<StringValue> CreateVariableItemList() { 129 ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>(); 130 foreach (string name in PreprocessingData.GetDoubleVariableNames()) { 131 itemList.Add(new StringValue(name), true); 132 } 133 return new ReadOnlyCheckedItemList<StringValue>(itemList); 134 } 135 136 public event DataPreprocessingChangedEventHandler Changed { 137 add { PreprocessingData.Changed += value; } 138 remove { PreprocessingData.Changed -= value; } 139 } 140 82 141 } 83 142 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingData.cs
r10991 r10992 55 55 } 56 56 57 public IEnumerable<string> GetDoubleVariableNames() { 58 var doubleVariableNames = new List<string>(); 59 for (int i = 0; i < Columns; ++i) { 60 if (IsType<double>(i)) { 61 doubleVariableNames.Add(variableNames[i]); 62 } 63 } 64 return doubleVariableNames; 65 } 66 57 67 public int Columns { 58 68 get { return variableNames.Count; } … … 67 77 get { return selection; } 68 78 set { 69 70 71 72 }79 selection = value; 80 OnSelectionChanged(); 81 } 82 } 73 83 74 84 protected PreprocessingData(PreprocessingData original, Cloner cloner) … … 161 171 162 172 public event DataPreprocessingChangedEventHandler Changed; 163 protected virtual void OnChanged(DataPreprocessingChangedEventType type, int column, int row) 164 { 173 protected virtual void OnChanged(DataPreprocessingChangedEventType type, int column, int row) { 165 174 var listeners = Changed; 166 175 if (listeners != null) listeners(this, new DataPreprocessingChangedEventArgs(type, column, row)); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/ScatterPlotContent.cs
r10987 r10992 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.DataPreprocessing.Interfaces; 27 28 28 29 namespace HeuristicLab.DataPreprocessing { 29 30 30 31 [Item("ScatterPlot", "Represents a scatter plot.")] 31 public class ScatterPlotContent : Item, IViewChartShortcut {32 public class ScatterPlotContent : PreprocessingChartContent { 32 33 public static new Image StaticItemImage { 33 34 get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; } … … 37 38 public string SelectedYVariable { get; set; } 38 39 39 public IPreprocessingContext Context { 40 get; 41 private set; 42 } 43 public ITransactionalPreprocessingData PreprocessingData { 44 get { return Context.Data; } 45 } 46 47 public ScatterPlotContent(IPreprocessingContext context) 48 : base() { 49 this.Context = context; 40 public ScatterPlotContent(IFilteredPreprocessingData preprocessingData) 41 : base(preprocessingData) { 50 42 } 51 43 52 44 public ScatterPlotContent(ScatterPlotContent content, Cloner cloner) 53 45 : base(content, cloner) { 54 this.Context = content.Context;55 46 this.SelectedXVariable = content.SelectedXVariable; 56 47 this.SelectedYVariable = content.SelectedYVariable; … … 60 51 } 61 52 62 public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {63 int columnIndex = PreprocessingData.GetColumnIndex(variableName);64 IList<double> values = PreprocessingData.GetValues<double>(columnIndex);65 DataRow row = new DataRow(variableName, "", values);66 row.VisualProperties.ChartType = chartType;67 return row;68 }69 70 public IEnumerable<string> GetVariableNames() {71 List<string> doubleVariableNames = new List<string>();72 73 //only return variable names from type double74 foreach (string variableName in PreprocessingData.VariableNames) {75 if (PreprocessingData.IsType<double>(PreprocessingData.GetColumnIndex(variableName)))76 doubleVariableNames.Add(variableName);77 }78 79 return doubleVariableNames;80 }81 82 53 public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY) { 83 54 ScatterPlot scatterPlot = new ScatterPlot(); 84 55 85 int xColumnIndex = PreprocessingData.GetColumnIndex(variableNameX); 86 int yColumnIndex = PreprocessingData.GetColumnIndex(variableNameY); 87 88 IList<double> xValues = PreprocessingData.GetValues<double>(xColumnIndex); 89 IList<double> yValues = PreprocessingData.GetValues<double>(yColumnIndex); 56 IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX)); 57 IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY)); 90 58 91 59 List<Point2D<double>> points = new List<Point2D<double>>(); … … 100 68 return scatterPlot; 101 69 } 102 103 70 } 104 71 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Interfaces/IPreprocessingData.cs
r10978 r10992 55 55 56 56 IEnumerable<string> VariableNames { get; } 57 IEnumerable<string> GetDoubleVariableNames(); 57 58 string GetVariableName(int columnIndex); 58 59 int GetColumnIndex(string variableName);
Note: See TracChangeset
for help on using the changeset viewer.