Changeset 10159
- Timestamp:
- 11/27/13 15:20:12 (11 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3
- Files:
-
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/DataSetStatisticInfo.cs
r10148 r10159 1 1 using System; 2 using System.Linq; 3 using HeuristicLab.Problems.DataAnalysis; 2 using HeuristicLab.DataPreprocessing.Interfaces; 4 3 5 4 namespace HeuristicLab.DataPreprocessing { 6 5 class DatasetStatisticInfo : IDatasetStatisticInfo { 7 6 8 private I Dataset dataSet;7 private IPreprocessingData preprocessingData; 9 8 10 public DatasetStatisticInfo(I DatasettheDataSet) {11 dataSet= theDataSet;9 public DatasetStatisticInfo(IPreprocessingData theDataSet) { 10 preprocessingData = theDataSet; 12 11 } 13 12 14 13 15 14 public int GetColumnCount() { 16 return dataSet.Columns;15 return preprocessingData.Columns; 17 16 } 18 17 19 18 public int GetRowCount() { 20 return dataSet.Rows;19 return preprocessingData.Rows; 21 20 } 22 21 23 22 public int GetNumericColumnCount() { 24 return dataSet.DoubleVariables.Count(); 23 int count = 0; 24 for (int i = 0; i < preprocessingData.Columns; ++i) { 25 if (preprocessingData.IsType<double>(i)) { 26 ++count; 27 } 28 } 29 return count; 25 30 } 26 31 27 32 public int GetNominalColumnCount() { 28 return dataSet.Columns - GetNumericColumnCount();33 return preprocessingData.Columns - GetNumericColumnCount(); 29 34 } 30 35 31 36 public int GetMissingValueCount() { 32 37 int count = 0; 33 for (int i = 0; i < dataSet.Columns; ++i) {38 for (int i = 0; i < preprocessingData.Columns; ++i) { 34 39 count += GetMissingValueCount(i); 35 40 } … … 38 43 39 44 public int GetMissingValueCount(int columnIndex) { 40 Func<string, bool> isMissingValueFunc; 41 if (dataSet.IsType<double>(columnIndex)) { 42 isMissingValueFunc = IsMissingDoubleValue; 43 } else if (dataSet.IsType<string>(columnIndex)) { 44 isMissingValueFunc = IsMissingStringValue; 45 } else if (dataSet.IsType<DateTime>(columnIndex)) { 46 isMissingValueFunc = isMissingDateTimeValue; 47 } else { 48 throw new ArgumentException("column with index: " + columnIndex + " contains a non supported type."); 49 } 45 throw new System.NotImplementedException(); 46 //Func<dynamic, bool> isMissingValueFunc; 47 //if (preprocessingData.IsType<double>(columnIndex)) { 48 // isMissingValueFunc = IsMissingDoubleValue; 49 //} else if (preprocessingData.IsType<string>(columnIndex)) { 50 // isMissingValueFunc = IsMissingStringValue; 51 //} else if (preprocessingData.IsType<DateTime>(columnIndex)) { 52 // isMissingValueFunc = isMissingDateTimeValue; 53 //} else { 54 // throw new ArgumentException("column with index: " + columnIndex + " contains a non supported type."); 55 //} 50 56 51 int count = 0;52 for (int i = 0; i < dataSet.Rows; ++i) {53 if (isMissingValueFunc(dataSet.GetValue(i, columnIndex))) {54 ++count;55 }56 }57 return count;57 //int count = 0; 58 //for (int i = 0; i < preprocessingData.Rows; ++i) { 59 // if (isMissingValueFunc(preprocessingData.GetCell(i, columnIndex))) { 60 // ++count; 61 // } 62 //} 63 //return count; 58 64 } 59 65 … … 75 81 76 82 public T GetMin<T>(int columnIndex) where T : IComparable<T> { 77 if (! dataSet.IsType<double>(columnIndex)) {83 if (!preprocessingData.IsType<double>(columnIndex)) { 78 84 throw new ArgumentException("column with index: " + columnIndex + " was assumed to be of type " + typeof(T).Name + " but was different."); 79 85 } … … 88 94 89 95 public T GetMax<T>(int columnIndex) where T : IComparable<T> { 90 if (! dataSet.IsType<double>(columnIndex)) {96 if (!preprocessingData.IsType<double>(columnIndex)) { 91 97 throw new ArgumentException("column with index: " + columnIndex + " was assumed to be of type " + typeof(T).Name + " but was different."); 92 98 } … … 101 107 102 108 private T GetMin<T>(int columnIndex, T max, Func<string, bool> isMissingValueFunc, Func<string, T> parseFunc) where T : IComparable<T> { 103 T min = max; 104 for (int i = 0; i < dataSet.Rows; ++i) { 105 var value = dataSet.GetValue(i, columnIndex); 106 if (!isMissingValueFunc(value)) { 107 T parsedValue = parseFunc(value); 108 if (parsedValue.CompareTo(min) < 0) { 109 min = parsedValue; 110 } 111 } 112 } 113 return min; 109 throw new System.NotImplementedException(); 110 //T min = max; 111 //for (int i = 0; i < preprocessingData.Rows; ++i) { 112 // var value = preprocessingData.GetValue(i, columnIndex); 113 // if (!isMissingValueFunc(value)) { 114 // T parsedValue = parseFunc(value); 115 // if (parsedValue.CompareTo(min) < 0) { 116 // min = parsedValue; 117 // } 118 // } 119 //} 120 //return min; 114 121 } 115 122 116 123 private T GetMax<T>(int columnIndex, T min, Func<string, bool> isMissingValueFunc, Func<string, T> parseFunc) where T : IComparable<T> { 117 T max = min; 118 for (int i = 0; i < dataSet.Rows; ++i) { 119 var value = dataSet.GetValue(i, columnIndex); 120 if (!isMissingValueFunc(value)) { 121 T parsedValue = parseFunc(value); 122 if (parsedValue.CompareTo(min) > 0) { 123 max = parsedValue; 124 } 125 } 126 } 127 return max; 124 throw new System.NotImplementedException(); 125 //T max = min; 126 //for (int i = 0; i < preprocessingData.Rows; ++i) { 127 // var value = preprocessingData.GetValue(i, columnIndex); 128 // if (!isMissingValueFunc(value)) { 129 // T parsedValue = parseFunc(value); 130 // if (parsedValue.CompareTo(min) > 0) { 131 // max = parsedValue; 132 // } 133 // } 134 //} 135 //return max; 128 136 } 129 137 130 138 131 139 132 140 133 141 134 142 public double GetMedian(int columnIndex) { … … 141 149 142 150 public double GetMostCommonValue(int columnIndex) { 143 throw new System.NotImplementedException(); 151 double result = 0; 152 for (int i = 0; i < preprocessingData.Rows; ++i) { 153 154 } 155 return result; 144 156 } 145 157 146 public double Ge StandardDeviation(int columnIndex) {158 public double GetStandardDeviation(int columnIndex) { 147 159 throw new System.NotImplementedException(); 148 160 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/HeuristicLab.DataPreprocessing-3.3.csproj
r10157 r10159 86 86 <Compile Include="EditableDataset.cs" /> 87 87 <Compile Include="DataSetStatisticInfo.cs" /> 88 <Compile Include="I DataSetStatisticInfo.cs" />88 <Compile Include="Interfaces\IDataSetStatisticInfo.cs" /> 89 89 <Compile Include="Interfaces\IPreprocessingData.cs" /> 90 90 <Compile Include="Plugin.cs" /> -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IDataSetStatisticInfo.cs
r10158 r10159 15 15 double GetAverage(int columnNumber); 16 16 double GetMostCommonValue(int columnNumber); 17 double Ge StandardDeviation(int columnNumber);17 double GetStandardDeviation(int columnNumber); 18 18 } 19 19 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IPreprocessingData.cs
r10158 r10159 40 40 IList<string> VariableNames { get; } 41 41 bool IsType<T>(int columnIndex); 42 43 int Columns { get; } 44 int Rows { get; } 42 45 } 43 46 }
Note: See TracChangeset
for help on using the changeset viewer.