Changeset 10809 for branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/StatisticsLogic.cs
- Timestamp:
- 05/07/14 12:47:54 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/StatisticsLogic.cs
r10663 r10809 73 73 } 74 74 75 public T GetMin<T>(int columnIndex ) where T : IComparable<T> {76 return preprocessingData.GetValues<T>(columnIndex ).Min();75 public T GetMin<T>(int columnIndex, bool considerSelection) where T : IComparable<T> { 76 return preprocessingData.GetValues<T>(columnIndex, considerSelection).Min(); 77 77 } 78 78 79 public T GetMax<T>(int columnIndex ) where T : IComparable<T> {80 return preprocessingData.GetValues<T>(columnIndex ).Max();79 public T GetMax<T>(int columnIndex, bool considerSelection) where T : IComparable<T> { 80 return preprocessingData.GetValues<T>(columnIndex, considerSelection).Max(); 81 81 } 82 82 83 public double GetMedian(int columnIndex ) {83 public double GetMedian(int columnIndex, bool considerSelection) { 84 84 double median = double.NaN; 85 85 if (preprocessingData.IsType<double>(columnIndex)) { 86 median = GetValuesWithoutNaN<double>(columnIndex ).Median();86 median = GetValuesWithoutNaN<double>(columnIndex, considerSelection).Median(); 87 87 } 88 88 return median; 89 89 } 90 90 91 public double GetAverage(int columnIndex ) {91 public double GetAverage(int columnIndex, bool considerSelection) { 92 92 double avg = double.NaN; 93 93 if (preprocessingData.IsType<double>(columnIndex)) { 94 avg = GetValuesWithoutNaN<double>(columnIndex ).Average();94 avg = GetValuesWithoutNaN<double>(columnIndex, considerSelection).Average(); 95 95 } 96 96 return avg; 97 97 } 98 98 99 public DateTime GetMedianDateTime(int columnIndex ) {99 public DateTime GetMedianDateTime(int columnIndex, bool considerSelection) { 100 100 DateTime median = new DateTime(); 101 101 if (preprocessingData.IsType<DateTime>(columnIndex)) { 102 median = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex ).Median());102 median = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex, considerSelection).Median()); 103 103 } 104 104 return median; 105 105 } 106 106 107 public DateTime GetAverageDateTime(int columnIndex ) {107 public DateTime GetAverageDateTime(int columnIndex, bool considerSelection) { 108 108 DateTime avg = new DateTime(); 109 109 if (preprocessingData.IsType<DateTime>(columnIndex)) { 110 avg = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex ).Average());110 avg = GetSecondsAsDateTime(GetDateTimeAsSeconds(columnIndex, considerSelection).Average()); 111 111 } 112 112 return avg; 113 113 } 114 114 115 public T GetMostCommonValue<T>(int columnIndex ) {116 var t = preprocessingData.GetValues<T>(columnIndex );115 public T GetMostCommonValue<T>(int columnIndex, bool considerSelection) { 116 var t = preprocessingData.GetValues<T>(columnIndex, considerSelection); 117 117 var t2 = t.GroupBy(x => x); 118 118 var t3 = t2.Select(g => g.Key); 119 119 120 return preprocessingData.GetValues<T>(columnIndex )120 return preprocessingData.GetValues<T>(columnIndex, considerSelection) 121 121 .GroupBy(x => x) 122 122 .OrderByDescending(g => g.Count()) … … 129 129 double stdDev = double.NaN; 130 130 if (preprocessingData.IsType<double>(columnIndex)) { 131 stdDev = GetValuesWithoutNaN<double>(columnIndex ).StandardDeviation();131 stdDev = GetValuesWithoutNaN<double>(columnIndex, false).StandardDeviation(); 132 132 } else if (preprocessingData.IsType<DateTime>(columnIndex)) { 133 stdDev = GetDateTimeAsSeconds(columnIndex ).StandardDeviation();133 stdDev = GetDateTimeAsSeconds(columnIndex, false).StandardDeviation(); 134 134 } 135 135 return stdDev; … … 139 139 double variance = double.NaN; 140 140 if (preprocessingData.IsType<double>(columnIndex)) { 141 variance = preprocessingData.GetValues<double>(columnIndex ).Variance();141 variance = preprocessingData.GetValues<double>(columnIndex, false).Variance(); 142 142 } else if (preprocessingData.IsType<DateTime>(columnIndex)) { 143 variance = GetDateTimeAsSeconds(columnIndex ).Variance();143 variance = GetDateTimeAsSeconds(columnIndex, false).Variance(); 144 144 } 145 145 return variance; … … 147 147 148 148 public int GetDifferentValuesCount<T>(int columnIndex) { 149 return preprocessingData.GetValues<T>(columnIndex ).GroupBy(x => x).Count();149 return preprocessingData.GetValues<T>(columnIndex, false).GroupBy(x => x).Count(); 150 150 } 151 151 … … 179 179 } 180 180 181 private IEnumerable<double> GetDateTimeAsSeconds(int columnIndex ) {182 return GetValuesWithoutNaN<DateTime>(columnIndex ).Select(x => (double)x.Ticks / TimeSpan.TicksPerSecond);181 private IEnumerable<double> GetDateTimeAsSeconds(int columnIndex, bool considerSelection) { 182 return GetValuesWithoutNaN<DateTime>(columnIndex, considerSelection).Select(x => (double)x.Ticks / TimeSpan.TicksPerSecond); 183 183 } 184 184 185 private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex ) {186 return searchLogic.GetValuesWithoutNaN<T>(columnIndex );185 private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex, bool considerSelection) { 186 return searchLogic.GetValuesWithoutNaN<T>(columnIndex, considerSelection); 187 187 } 188 188
Note: See TracChangeset
for help on using the changeset viewer.