[10539] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[14185] | 3 | * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[10539] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
[10193] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
[10249] | 25 | using HeuristicLab.Data;
|
---|
[10193] | 26 |
|
---|
[10249] | 27 | namespace HeuristicLab.DataPreprocessing {
|
---|
[13508] | 28 | public class ManipulationLogic {
|
---|
[11070] | 29 | private readonly ITransactionalPreprocessingData preprocessingData;
|
---|
[13508] | 30 | private readonly StatisticsLogic statisticsLogic;
|
---|
| 31 | private readonly SearchLogic searchLogic;
|
---|
[10193] | 32 |
|
---|
[11002] | 33 | public IEnumerable<string> VariableNames {
|
---|
| 34 | get { return preprocessingData.VariableNames; }
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | public ITransactionalPreprocessingData PreProcessingData {
|
---|
| 38 | get { return preprocessingData; }
|
---|
| 39 | }
|
---|
| 40 |
|
---|
[14996] | 41 | public ManipulationLogic(ITransactionalPreprocessingData preprocessingData, SearchLogic theSearchLogic, StatisticsLogic theStatisticsLogic) {
|
---|
| 42 | this.preprocessingData = preprocessingData;
|
---|
[10249] | 43 | searchLogic = theSearchLogic;
|
---|
[10615] | 44 | statisticsLogic = theStatisticsLogic;
|
---|
[10249] | 45 | }
|
---|
[10193] | 46 |
|
---|
[10367] | 47 | public void ReplaceIndicesByValue<T>(int columnIndex, IEnumerable<int> rowIndices, T value) {
|
---|
| 48 | foreach (int index in rowIndices) {
|
---|
| 49 | preprocessingData.SetCell<T>(columnIndex, index, value);
|
---|
[10249] | 50 | }
|
---|
| 51 | }
|
---|
[10193] | 52 |
|
---|
[13508] | 53 | public void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
|
---|
[10612] | 54 | preprocessingData.InTransaction(() => {
|
---|
| 55 | foreach (var column in cells) {
|
---|
[11156] | 56 | if (preprocessingData.VariableHasType<double>(column.Key)) {
|
---|
[10809] | 57 | double average = statisticsLogic.GetAverage(column.Key, considerSelection);
|
---|
[10615] | 58 | ReplaceIndicesByValue<double>(column.Key, column.Value, average);
|
---|
[11156] | 59 | } else if (preprocessingData.VariableHasType<DateTime>(column.Key)) {
|
---|
[10809] | 60 | DateTime average = statisticsLogic.GetAverageDateTime(column.Key, considerSelection);
|
---|
[10615] | 61 | ReplaceIndicesByValue<DateTime>(column.Key, column.Value, average);
|
---|
| 62 | }
|
---|
[10612] | 63 | }
|
---|
| 64 | });
|
---|
[10249] | 65 | }
|
---|
[10193] | 66 |
|
---|
[13508] | 67 | public void ReplaceIndicesByMedianValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
|
---|
[10612] | 68 | preprocessingData.InTransaction(() => {
|
---|
| 69 | foreach (var column in cells) {
|
---|
[11156] | 70 | if (preprocessingData.VariableHasType<double>(column.Key)) {
|
---|
[10809] | 71 | double median = statisticsLogic.GetMedian(column.Key, considerSelection);
|
---|
[10615] | 72 | ReplaceIndicesByValue<double>(column.Key, column.Value, median);
|
---|
[11156] | 73 | } else if (preprocessingData.VariableHasType<DateTime>(column.Key)) {
|
---|
[10809] | 74 | DateTime median = statisticsLogic.GetMedianDateTime(column.Key, considerSelection);
|
---|
[10615] | 75 | ReplaceIndicesByValue<DateTime>(column.Key, column.Value, median);
|
---|
| 76 | }
|
---|
[10612] | 77 | }
|
---|
| 78 | });
|
---|
[10249] | 79 | }
|
---|
[10193] | 80 |
|
---|
[13508] | 81 | public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
|
---|
[10612] | 82 | preprocessingData.InTransaction(() => {
|
---|
| 83 | Random r = new Random();
|
---|
[10193] | 84 |
|
---|
[10612] | 85 | foreach (var column in cells) {
|
---|
[11156] | 86 | if (preprocessingData.VariableHasType<double>(column.Key)) {
|
---|
[13935] | 87 | double max = statisticsLogic.GetMax<double>(column.Key, double.NaN, considerSelection);
|
---|
| 88 | double min = statisticsLogic.GetMin<double>(column.Key, double.NaN, considerSelection);
|
---|
[10615] | 89 | double randMultiplier = (max - min);
|
---|
| 90 | foreach (int index in column.Value) {
|
---|
| 91 | double rand = r.NextDouble() * randMultiplier + min;
|
---|
| 92 | preprocessingData.SetCell<double>(column.Key, index, rand);
|
---|
| 93 | }
|
---|
[11156] | 94 | } else if (preprocessingData.VariableHasType<DateTime>(column.Key)) {
|
---|
[13935] | 95 | DateTime min = statisticsLogic.GetMin<DateTime>(column.Key, DateTime.MinValue, considerSelection);
|
---|
| 96 | DateTime max = statisticsLogic.GetMax<DateTime>(column.Key, DateTime.MinValue, considerSelection);
|
---|
[10615] | 97 | double randMultiplier = (max - min).TotalSeconds;
|
---|
| 98 | foreach (int index in column.Value) {
|
---|
| 99 | double rand = r.NextDouble() * randMultiplier;
|
---|
| 100 | preprocessingData.SetCell<DateTime>(column.Key, index, min.AddSeconds(rand));
|
---|
| 101 | }
|
---|
[10612] | 102 | }
|
---|
[10590] | 103 | }
|
---|
[10612] | 104 | });
|
---|
[10249] | 105 | }
|
---|
[10193] | 106 |
|
---|
[10672] | 107 | public void ReplaceIndicesByLinearInterpolationOfNeighbours(IDictionary<int, IList<int>> cells) {
|
---|
[10612] | 108 | preprocessingData.InTransaction(() => {
|
---|
| 109 | foreach (var column in cells) {
|
---|
[10820] | 110 | IList<Tuple<int, int>> startEndings = GetStartAndEndingsForInterpolation(column);
|
---|
| 111 | foreach (var tuple in startEndings) {
|
---|
| 112 | Interpolate(column, tuple.Item1, tuple.Item2);
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 | });
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | private List<Tuple<int, int>> GetStartAndEndingsForInterpolation(KeyValuePair<int, IList<int>> column) {
|
---|
| 119 | List<Tuple<int, int>> startEndings = new List<Tuple<int, int>>();
|
---|
| 120 | var rowIndices = column.Value;
|
---|
| 121 | rowIndices = rowIndices.OrderBy(x => x).ToList();
|
---|
| 122 | var count = rowIndices.Count;
|
---|
| 123 | int start = int.MinValue;
|
---|
| 124 | for (int i = 0; i < count; ++i) {
|
---|
| 125 | if (start == int.MinValue) {
|
---|
| 126 | start = indexOfPrevPresentValue(column.Key, rowIndices[i]);
|
---|
| 127 | }
|
---|
| 128 | if (i + 1 == count || (i + 1 < count && rowIndices[i + 1] - rowIndices[i] > 1)) {
|
---|
| 129 | int next = indexOfNextPresentValue(column.Key, rowIndices[i]);
|
---|
| 130 | if (start > 0 && next < preprocessingData.Rows) {
|
---|
| 131 | startEndings.Add(new Tuple<int, int>(start, next));
|
---|
| 132 | }
|
---|
| 133 | start = int.MinValue;
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 | return startEndings;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | public void ReplaceIndicesBySmoothing(IDictionary<int, IList<int>> cells) {
|
---|
| 140 | preprocessingData.InTransaction(() => {
|
---|
| 141 | foreach (var column in cells) {
|
---|
| 142 | int countValues = preprocessingData.Rows;
|
---|
| 143 |
|
---|
[10621] | 144 | foreach (int index in column.Value) {
|
---|
| 145 | // dont replace first or last values
|
---|
| 146 | if (index > 0 && index < countValues) {
|
---|
| 147 | int prevIndex = indexOfPrevPresentValue(column.Key, index);
|
---|
| 148 | int nextIndex = indexOfNextPresentValue(column.Key, index);
|
---|
| 149 |
|
---|
| 150 | // no neighbours found
|
---|
[10820] | 151 | if (prevIndex < 0 || nextIndex >= countValues) {
|
---|
[10621] | 152 | continue;
|
---|
| 153 | }
|
---|
| 154 |
|
---|
[10820] | 155 | Interpolate(column, prevIndex, nextIndex);
|
---|
[10590] | 156 | }
|
---|
[10249] | 157 | }
|
---|
[10193] | 158 | }
|
---|
[10612] | 159 | });
|
---|
[10249] | 160 | }
|
---|
[10193] | 161 |
|
---|
[10820] | 162 | private void Interpolate(KeyValuePair<int, IList<int>> column, int prevIndex, int nextIndex) {
|
---|
| 163 | int valuesToInterpolate = nextIndex - prevIndex;
|
---|
| 164 |
|
---|
[11156] | 165 | if (preprocessingData.VariableHasType<double>(column.Key)) {
|
---|
[10820] | 166 | double prev = preprocessingData.GetCell<double>(column.Key, prevIndex);
|
---|
| 167 | double next = preprocessingData.GetCell<double>(column.Key, nextIndex);
|
---|
| 168 | double interpolationStep = (next - prev) / valuesToInterpolate;
|
---|
| 169 |
|
---|
| 170 | for (int i = prevIndex; i < nextIndex; ++i) {
|
---|
| 171 | double interpolated = prev + (interpolationStep * (i - prevIndex));
|
---|
| 172 | preprocessingData.SetCell<double>(column.Key, i, interpolated);
|
---|
| 173 | }
|
---|
[11156] | 174 | } else if (preprocessingData.VariableHasType<DateTime>(column.Key)) {
|
---|
[10820] | 175 | DateTime prev = preprocessingData.GetCell<DateTime>(column.Key, prevIndex);
|
---|
| 176 | DateTime next = preprocessingData.GetCell<DateTime>(column.Key, nextIndex);
|
---|
| 177 | double interpolationStep = (next - prev).TotalSeconds / valuesToInterpolate;
|
---|
| 178 |
|
---|
| 179 | for (int i = prevIndex; i < nextIndex; ++i) {
|
---|
| 180 | DateTime interpolated = prev.AddSeconds(interpolationStep * (i - prevIndex));
|
---|
| 181 | preprocessingData.SetCell<DateTime>(column.Key, i, interpolated);
|
---|
| 182 | }
|
---|
| 183 | }
|
---|
| 184 | }
|
---|
| 185 |
|
---|
[10367] | 186 | private int indexOfPrevPresentValue(int columnIndex, int start) {
|
---|
[10249] | 187 | int offset = start - 1;
|
---|
[10367] | 188 | while (offset >= 0 && searchLogic.IsMissingValue(columnIndex, offset)) {
|
---|
[10249] | 189 | offset--;
|
---|
| 190 | }
|
---|
[10234] | 191 |
|
---|
[10249] | 192 | return offset;
|
---|
| 193 | }
|
---|
[10234] | 194 |
|
---|
[10367] | 195 | private int indexOfNextPresentValue(int columnIndex, int start) {
|
---|
[10249] | 196 | int offset = start + 1;
|
---|
[10367] | 197 | while (offset < preprocessingData.Rows && searchLogic.IsMissingValue(columnIndex, offset)) {
|
---|
[10249] | 198 | offset++;
|
---|
| 199 | }
|
---|
[10234] | 200 |
|
---|
[10249] | 201 | return offset;
|
---|
| 202 | }
|
---|
[10234] | 203 |
|
---|
[13508] | 204 | public void ReplaceIndicesByMostCommonValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
|
---|
[10612] | 205 | preprocessingData.InTransaction(() => {
|
---|
| 206 | foreach (var column in cells) {
|
---|
[11156] | 207 | if (preprocessingData.VariableHasType<double>(column.Key)) {
|
---|
[13935] | 208 | ReplaceIndicesByValue<double>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<double>(column.Key, double.NaN, considerSelection));
|
---|
[11156] | 209 | } else if (preprocessingData.VariableHasType<string>(column.Key)) {
|
---|
[13935] | 210 | ReplaceIndicesByValue<string>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<string>(column.Key, string.Empty, considerSelection));
|
---|
[11156] | 211 | } else if (preprocessingData.VariableHasType<DateTime>(column.Key)) {
|
---|
[13935] | 212 | ReplaceIndicesByValue<DateTime>(column.Key, column.Value, statisticsLogic.GetMostCommonValue<DateTime>(column.Key, DateTime.MinValue, considerSelection));
|
---|
[10612] | 213 | } else {
|
---|
| 214 | throw new ArgumentException("column with index: " + column.Key + " contains a non supported type.");
|
---|
| 215 | }
|
---|
[10590] | 216 | }
|
---|
[10612] | 217 | });
|
---|
[10249] | 218 | }
|
---|
[10218] | 219 |
|
---|
[11403] | 220 | public void Shuffle(bool shuffleRangesSeparately) {
|
---|
| 221 | Random random = new Random();
|
---|
[11380] | 222 | var ranges = new[] { preprocessingData.TestPartition, preprocessingData.TrainingPartition };
|
---|
| 223 | if (shuffleRangesSeparately) {
|
---|
| 224 | preprocessingData.InTransaction(() => {
|
---|
| 225 | // process all given ranges - e.g. TrainingPartition, TestPartition
|
---|
| 226 | foreach (IntRange range in ranges) {
|
---|
| 227 | List<Tuple<int, int>> shuffledIndices = new List<Tuple<int, int>>();
|
---|
[10218] | 228 |
|
---|
[11380] | 229 | // generate random indices used for shuffeling each column
|
---|
| 230 | for (int i = range.End - 1; i >= range.Start; --i) {
|
---|
| 231 | int rand = random.Next(range.Start, i);
|
---|
| 232 | shuffledIndices.Add(new Tuple<int, int>(i, rand));
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 | ShuffleToIndices(shuffledIndices);
|
---|
[10612] | 236 | }
|
---|
[11380] | 237 | });
|
---|
| 238 | } else {
|
---|
| 239 | preprocessingData.InTransaction(() => {
|
---|
| 240 | var indices = ranges.SelectMany(x => Enumerable.Range(x.Start, x.Size)).ToList();
|
---|
| 241 | var shuffledIndices = indices.OrderBy(x => random.Next());
|
---|
| 242 | ShuffleToIndices(indices.Zip(shuffledIndices, (i, j) => new Tuple<int, int>(i, j)).ToList());
|
---|
| 243 | });
|
---|
| 244 | }
|
---|
[10253] | 245 | }
|
---|
| 246 |
|
---|
[10535] | 247 | public void ReOrderToIndices(IEnumerable<int> indices) {
|
---|
[10256] | 248 | List<Tuple<int, int>> indicesTuple = new List<Tuple<int, int>>();
|
---|
[10255] | 249 |
|
---|
[10256] | 250 | for (int i = 0; i < indices.Count(); ++i) {
|
---|
[10311] | 251 | indicesTuple.Add(new Tuple<int, int>(i, indices.ElementAt(i)));
|
---|
[10256] | 252 | }
|
---|
| 253 |
|
---|
[10535] | 254 | ReOrderToIndices(indicesTuple);
|
---|
[10255] | 255 | }
|
---|
| 256 |
|
---|
[10535] | 257 | public void ReOrderToIndices(IList<System.Tuple<int, int>> indices) {
|
---|
[10612] | 258 | preprocessingData.InTransaction(() => {
|
---|
| 259 | for (int i = 0; i < preprocessingData.Columns; ++i) {
|
---|
[11156] | 260 | if (preprocessingData.VariableHasType<double>(i)) {
|
---|
[14996] | 261 | ReOrderToIndices<double>(i, indices);
|
---|
[11156] | 262 | } else if (preprocessingData.VariableHasType<string>(i)) {
|
---|
[14996] | 263 | ReOrderToIndices<string>(i, indices);
|
---|
[11156] | 264 | } else if (preprocessingData.VariableHasType<DateTime>(i)) {
|
---|
[14996] | 265 | ReOrderToIndices<DateTime>(i, indices);
|
---|
[10612] | 266 | }
|
---|
[10249] | 267 | }
|
---|
[10612] | 268 | });
|
---|
[10249] | 269 | }
|
---|
[10218] | 270 |
|
---|
[10820] | 271 | public void ShuffleToIndices(IList<System.Tuple<int, int>> indices) {
|
---|
| 272 | preprocessingData.InTransaction(() => {
|
---|
| 273 | for (int i = 0; i < preprocessingData.Columns; ++i) {
|
---|
[11156] | 274 | if (preprocessingData.VariableHasType<double>(i)) {
|
---|
[10718] | 275 | ShuffleToIndices<double>(i, indices);
|
---|
[11156] | 276 | } else if (preprocessingData.VariableHasType<string>(i)) {
|
---|
[10718] | 277 | ShuffleToIndices<string>(i, indices);
|
---|
[11156] | 278 | } else if (preprocessingData.VariableHasType<DateTime>(i)) {
|
---|
[10718] | 279 | ShuffleToIndices<DateTime>(i, indices);
|
---|
| 280 | }
|
---|
| 281 | }
|
---|
| 282 | });
|
---|
| 283 | }
|
---|
| 284 |
|
---|
[14996] | 285 | private void ReOrderToIndices<T>(int columnIndex, IList<Tuple<int, int>> indices) {
|
---|
[10811] | 286 | List<T> originalData = new List<T>(preprocessingData.GetValues<T>(columnIndex));
|
---|
[10308] | 287 |
|
---|
[10249] | 288 | // process all columns equally
|
---|
| 289 | foreach (Tuple<int, int> index in indices) {
|
---|
| 290 | int originalIndex = index.Item1;
|
---|
| 291 | int replaceIndex = index.Item2;
|
---|
[10218] | 292 |
|
---|
[10308] | 293 | T replaceValue = originalData.ElementAt<T>(replaceIndex);
|
---|
[10367] | 294 | preprocessingData.SetCell<T>(columnIndex, originalIndex, replaceValue);
|
---|
[10249] | 295 | }
|
---|
[10193] | 296 | }
|
---|
[10672] | 297 |
|
---|
[10820] | 298 | private void ShuffleToIndices<T>(int columnIndex, IList<Tuple<int, int>> indices) {
|
---|
[10718] | 299 | // process all columns equally
|
---|
[10820] | 300 | foreach (Tuple<int, int> index in indices) {
|
---|
[10718] | 301 | int originalIndex = index.Item1;
|
---|
| 302 | int replaceIndex = index.Item2;
|
---|
| 303 |
|
---|
| 304 | T tmp = preprocessingData.GetCell<T>(columnIndex, originalIndex);
|
---|
| 305 | T replaceValue = preprocessingData.GetCell<T>(columnIndex, replaceIndex);
|
---|
| 306 |
|
---|
| 307 | preprocessingData.SetCell<T>(columnIndex, originalIndex, replaceValue);
|
---|
| 308 | preprocessingData.SetCell<T>(columnIndex, replaceIndex, tmp);
|
---|
| 309 | }
|
---|
| 310 | }
|
---|
| 311 |
|
---|
[10672] | 312 | public void ReplaceIndicesByValue(IDictionary<int, IList<int>> cells, string value) {
|
---|
| 313 | preprocessingData.InTransaction(() => {
|
---|
| 314 | foreach (var column in cells) {
|
---|
| 315 | foreach (var rowIdx in column.Value) {
|
---|
[11002] | 316 | preprocessingData.SetValue(value, column.Key, rowIdx);
|
---|
[10672] | 317 | }
|
---|
| 318 | }
|
---|
| 319 | });
|
---|
| 320 | }
|
---|
[10711] | 321 |
|
---|
| 322 |
|
---|
[10715] | 323 | public List<int> RowsWithMissingValuesGreater(double percent) {
|
---|
[10820] | 324 | List<int> rows = new List<int>();
|
---|
[10715] | 325 |
|
---|
[10820] | 326 | for (int i = 0; i < preprocessingData.Rows; ++i) {
|
---|
[10711] | 327 | int missingCount = statisticsLogic.GetRowMissingValueCount(i);
|
---|
[10820] | 328 | if (100f / preprocessingData.Columns * missingCount > percent) {
|
---|
[10715] | 329 | rows.Add(i);
|
---|
[10711] | 330 | }
|
---|
| 331 | }
|
---|
[10715] | 332 |
|
---|
| 333 | return rows;
|
---|
[10711] | 334 | }
|
---|
| 335 |
|
---|
[10715] | 336 | public List<int> ColumnsWithMissingValuesGreater(double percent) {
|
---|
| 337 | List<int> columns = new List<int>();
|
---|
[10737] | 338 | for (int i = 0; i < preprocessingData.Columns; ++i) {
|
---|
[10711] | 339 | int missingCount = statisticsLogic.GetMissingValueCount(i);
|
---|
[10737] | 340 | if (100f / preprocessingData.Rows * missingCount > percent) {
|
---|
[10715] | 341 | columns.Add(i);
|
---|
[10711] | 342 | }
|
---|
| 343 | }
|
---|
[10715] | 344 |
|
---|
| 345 | return columns;
|
---|
[10711] | 346 | }
|
---|
| 347 |
|
---|
[10715] | 348 | public List<int> ColumnsWithVarianceSmaller(double variance) {
|
---|
| 349 | List<int> columns = new List<int>();
|
---|
[10737] | 350 | for (int i = 0; i < preprocessingData.Columns; ++i) {
|
---|
[11156] | 351 | if (preprocessingData.VariableHasType<double>(i) || preprocessingData.VariableHasType<DateTime>(i)) {
|
---|
[10711] | 352 | double columnVariance = statisticsLogic.GetVariance(i);
|
---|
[10820] | 353 | if (columnVariance < variance) {
|
---|
[10715] | 354 | columns.Add(i);
|
---|
[10711] | 355 | }
|
---|
| 356 | }
|
---|
| 357 | }
|
---|
[10715] | 358 | return columns;
|
---|
[10711] | 359 | }
|
---|
| 360 |
|
---|
[10715] | 361 | public void DeleteRowsWithMissingValuesGreater(double percent) {
|
---|
| 362 | DeleteRows(RowsWithMissingValuesGreater(percent));
|
---|
| 363 | }
|
---|
| 364 |
|
---|
| 365 | public void DeleteColumnsWithMissingValuesGreater(double percent) {
|
---|
| 366 | DeleteColumns(ColumnsWithMissingValuesGreater(percent));
|
---|
| 367 | }
|
---|
| 368 |
|
---|
| 369 | public void DeleteColumnsWithVarianceSmaller(double variance) {
|
---|
| 370 | DeleteColumns(ColumnsWithVarianceSmaller(variance));
|
---|
| 371 | }
|
---|
| 372 |
|
---|
[10737] | 373 | private void DeleteRows(List<int> rows) {
|
---|
| 374 | rows.Sort();
|
---|
| 375 | rows.Reverse();
|
---|
[10820] | 376 | preprocessingData.InTransaction(() => {
|
---|
| 377 | foreach (int row in rows) {
|
---|
[10715] | 378 | preprocessingData.DeleteRow(row);
|
---|
| 379 | }
|
---|
| 380 | });
|
---|
| 381 | }
|
---|
| 382 |
|
---|
[10737] | 383 | private void DeleteColumns(List<int> columns) {
|
---|
| 384 | columns.Sort();
|
---|
| 385 | columns.Reverse();
|
---|
[10820] | 386 | preprocessingData.InTransaction(() => {
|
---|
| 387 | foreach (int column in columns) {
|
---|
[10715] | 388 | preprocessingData.DeleteColumn(column);
|
---|
| 389 | }
|
---|
| 390 | });
|
---|
| 391 | }
|
---|
[10249] | 392 | }
|
---|
[10193] | 393 | }
|
---|