Changeset 10367 for branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/StatisticsLogic.cs
- Timestamp:
- 01/22/14 14:13:11 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/StatisticsLogic.cs
r10249 r10367 39 39 public int GetMissingValueCount() { 40 40 int count = 0; 41 for each (var variableName in preprocessingData.VariableNames){42 count += GetMissingValueCount( variableName);41 for(int i = 0; i < preprocessingData.Columns; ++i){ 42 count += GetMissingValueCount(i); 43 43 } 44 44 return count; 45 45 } 46 46 47 public int GetMissingValueCount( string variableName) {48 return searchLogic.GetMissingValueIndices( variableName).Count();47 public int GetMissingValueCount(int columnIndex) { 48 return searchLogic.GetMissingValueIndices(columnIndex).Count(); 49 49 } 50 50 51 public T GetMin<T>( string variableName) where T : IComparable<T> {52 return preprocessingData.GetValues<T>( variableName).Min();51 public T GetMin<T>(int columnIndex) where T : IComparable<T> { 52 return preprocessingData.GetValues<T>(columnIndex).Min(); 53 53 } 54 54 55 public T GetMax<T>( string variableName) where T : IComparable<T> {56 return preprocessingData.GetValues<T>( variableName).Max();55 public T GetMax<T>(int columnIndex) where T : IComparable<T> { 56 return preprocessingData.GetValues<T>(columnIndex).Max(); 57 57 } 58 58 59 public double GetMedian( string variableName) {59 public double GetMedian(int columnIndex) { 60 60 double median = double.NaN; 61 if (preprocessingData.IsType<double>( variableName)) {62 median = preprocessingData.GetValues<double>( variableName).Median();61 if (preprocessingData.IsType<double>(columnIndex)) { 62 median = preprocessingData.GetValues<double>(columnIndex).Median(); 63 63 } 64 64 return median; 65 65 } 66 66 67 public double GetAverage( string variableName) {67 public double GetAverage(int columnIndex) { 68 68 double avg = double.NaN; 69 if (preprocessingData.IsType<double>( variableName)) {70 avg = preprocessingData.GetValues<double>( variableName).Average();69 if (preprocessingData.IsType<double>(columnIndex)) { 70 avg = preprocessingData.GetValues<double>(columnIndex).Average(); 71 71 } 72 72 return avg; 73 73 } 74 74 75 public T GetMostCommonValue<T>( string variableName) {76 return preprocessingData.GetValues<T>( variableName)75 public T GetMostCommonValue<T>(int columnIndex) { 76 return preprocessingData.GetValues<T>(columnIndex) 77 77 .GroupBy(x => x) 78 78 .OrderByDescending(g => g.Count()) … … 82 82 83 83 84 public double GetStandardDeviation( string variableName) {84 public double GetStandardDeviation(int columnIndex) { 85 85 double stdDev = double.NaN; 86 if (preprocessingData.IsType<double>( variableName)) {87 stdDev = preprocessingData.GetValues<double>( variableName).StandardDeviation();86 if (preprocessingData.IsType<double>(columnIndex)) { 87 stdDev = preprocessingData.GetValues<double>(columnIndex).StandardDeviation(); 88 88 } 89 89 return stdDev; 90 90 } 91 91 92 public double GetVariance( string variableName) {92 public double GetVariance(int columnIndex) { 93 93 double stdDev = double.NaN; 94 if (preprocessingData.IsType<double>( variableName)) {95 stdDev = preprocessingData.GetValues<double>( variableName).Variance();94 if (preprocessingData.IsType<double>(columnIndex)) { 95 stdDev = preprocessingData.GetValues<double>(columnIndex).Variance(); 96 96 } 97 97 return stdDev; 98 98 } 99 99 100 public int GetDifferentValuesCount<T>( string variableName) {101 return preprocessingData.GetValues<T>( variableName).GroupBy(x => x).Count();100 public int GetDifferentValuesCount<T>(int columnIndex) { 101 return preprocessingData.GetValues<T>(columnIndex).GroupBy(x => x).Count(); 102 102 } 103 103 104 104 public int GetRowMissingValueCount(int rowIndex) { 105 105 int count = 0; 106 foreach (var variableName in preprocessingData.VariableNames){107 if (searchLogic.IsMissingValue( variableName, rowIndex)) {106 for(int i = 0; i < preprocessingData.Columns; ++i){ 107 if (searchLogic.IsMissingValue(i, rowIndex)) { 108 108 ++count; 109 109 } … … 111 111 return count; 112 112 } 113 114 115 public string GetVariableName(int columnIndex) { 116 return preprocessingData.GetVariableName(columnIndex); 117 } 118 119 public bool IsType<T>(int columnIndex) { 120 return preprocessingData.IsType<T>(columnIndex); 121 } 113 122 } 114 123 }
Note: See TracChangeset
for help on using the changeset viewer.