Changeset 15291
- Timestamp:
- 07/27/17 12:45:23 (7 years ago)
- Location:
- branches/DataPreprocessing Cleanup
- Files:
-
- 5 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Cleanup/DataPreprocessing Cleanup.sln
r15268 r15291 2 2 Microsoft Visual Studio Solution File, Format Version 12.00 3 3 # Visual Studio 15 4 VisualStudioVersion = 15.0.26430.1 54 VisualStudioVersion = 15.0.26430.16 5 5 MinimumVisualStudioVersion = 10.0.40219.1 6 6 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.DataPreprocessing-3.4", "HeuristicLab.DataPreprocessing\3.4\HeuristicLab.DataPreprocessing-3.4.csproj", "{3B90F866-70F8-43EF-A541-51819D255B7B}" -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/PreprocessingData.cs
r15285 r15291 32 32 33 33 namespace HeuristicLab.DataPreprocessing { 34 35 34 [Item("PreprocessingData", "Represents data used for preprocessing.")] 36 35 [StorableClass] … … 38 37 39 38 [Storable] 40 protected IList<IList> variableValues; 41 [Storable] 42 protected IList<string> variableNames; 39 protected List<PreprocessingDataColumn> dataColumns; 43 40 44 41 #region Constructor, Cloning & Persistence … … 47 44 Name = "Preprocessing Data"; 48 45 46 dataColumns = new List<PreprocessingDataColumn>(); 49 47 Transformations = new List<ITransformation>(); 50 48 selection = new Dictionary<int, IList<int>>(); … … 57 55 protected PreprocessingData(PreprocessingData original, Cloner cloner) 58 56 : base(original, cloner) { 59 variableValues = CopyVariableValues(original.variableValues); 60 variableNames = new List<string>(original.variableNames); 61 TrainingPartition = (IntRange)original.TrainingPartition.Clone(cloner); 62 TestPartition = (IntRange)original.TestPartition.Clone(cloner); 57 dataColumns = new List<PreprocessingDataColumn>(original.dataColumns.Select(cloner.Clone)); 58 TrainingPartition = cloner.Clone(original.TrainingPartition); 59 TestPartition = cloner.Clone(original.TestPartition); 63 60 Transformations = new List<ITransformation>(original.Transformations.Select(cloner.Clone)); 64 61 … … 99 96 #region Cells 100 97 public bool IsCellEmpty(int columnIndex, int rowIndex) { 101 var value = variableValues[columnIndex][rowIndex]; 102 return IsMissingValue(value); 103 } 98 return !dataColumns[columnIndex].IsValidValue(rowIndex); 99 } 100 101 private void ColumnTypeSwitchAction<T>(int columnIndex, T value, Action<DoublePreprocessingDataColumn, double?> doubleAction, 102 Action<StringPreprocessingDataColumn, string> stringAction = null, Action<DateTimePreprocessingDataColumn, DateTime?> dateTimeAction = null) { 103 ColumnTypeSwitchAction(dataColumns[columnIndex], value, doubleAction, stringAction, dateTimeAction); 104 } 105 private void ColumnTypeSwitchAction<T>(PreprocessingDataColumn column, T value, Action<DoublePreprocessingDataColumn, double?> doubleAction, 106 Action<StringPreprocessingDataColumn, string> stringAction = null, Action<DateTimePreprocessingDataColumn, DateTime?> dateTimeAction = null) { 107 var doubleColumn = column as DoublePreprocessingDataColumn; 108 if (doubleColumn != null && doubleAction != null) doubleAction(doubleColumn, Convert<double?>(value)); 109 var stringColumn = column as StringPreprocessingDataColumn; 110 if (stringColumn != null && stringAction != null) stringAction(stringColumn, Convert<string>(value)); 111 var dateTimeColumn = column as DateTimePreprocessingDataColumn; 112 if (dateTimeColumn != null && dateTimeAction != null) dateTimeAction(dateTimeColumn, Convert<DateTime?>(value)); 113 } 114 115 private void ColumnTypeSwitchAction(int columnIndex, Action<DoublePreprocessingDataColumn> doubleAction, 116 Action<StringPreprocessingDataColumn> stringAction = null, Action<DateTimePreprocessingDataColumn> dateTimeAction = null) { 117 ColumnTypeSwitchAction(dataColumns[columnIndex], doubleAction, stringAction, dateTimeAction); 118 } 119 private void ColumnTypeSwitchAction(PreprocessingDataColumn column, Action<DoublePreprocessingDataColumn> doubleAction, 120 Action<StringPreprocessingDataColumn> stringAction = null, Action<DateTimePreprocessingDataColumn> dateTimeAction = null) { 121 var doubleColumn = column as DoublePreprocessingDataColumn; 122 if (doubleColumn != null && doubleAction != null) doubleAction(doubleColumn); 123 var stringColumn = column as StringPreprocessingDataColumn; 124 if (stringColumn != null && stringAction != null) stringAction(stringColumn); 125 var dateTimeColumn = column as DateTimePreprocessingDataColumn; 126 if (dateTimeColumn != null && dateTimeAction != null) dateTimeAction(dateTimeColumn); 127 } 128 129 130 private T ColumnTypeSwitchFunc<T>(int columnIndex, Func<DoublePreprocessingDataColumn, double?> doubleFunc, 131 Func<StringPreprocessingDataColumn, string> stringFunc = null, Func<DateTimePreprocessingDataColumn, DateTime?> dateTimeFunc = null) { 132 var doubleColumn = dataColumns[columnIndex] as DoublePreprocessingDataColumn; 133 if (doubleColumn != null && doubleFunc != null) return Convert<T>(doubleFunc(doubleColumn)); 134 var stringColumn = dataColumns[columnIndex] as StringPreprocessingDataColumn; 135 if (stringColumn != null && stringFunc != null) return Convert<T>(stringFunc(stringColumn)); 136 var dateTimeColumn = dataColumns[columnIndex] as DateTimePreprocessingDataColumn; 137 if (dateTimeColumn != null && dateTimeFunc != null) return Convert<T>(dateTimeFunc(dateTimeColumn)); 138 throw new InvalidOperationException("Invalid data column type."); 139 } 140 141 private T ColumnTypeSwitchFuncResult<T>(int columnIndex, Func<DoublePreprocessingDataColumn, T> doubleFunc, 142 Func<StringPreprocessingDataColumn, T> stringFunc = null, Func<DateTimePreprocessingDataColumn, T> dateTimeFunc = null) { 143 var doubleColumn = dataColumns[columnIndex] as DoublePreprocessingDataColumn; 144 if (doubleColumn != null && doubleFunc != null) return doubleFunc(doubleColumn); 145 var stringColumn = dataColumns[columnIndex] as StringPreprocessingDataColumn; 146 if (stringColumn != null && stringFunc != null) return stringFunc(stringColumn); 147 var dateTimeColumn = dataColumns[columnIndex] as DateTimePreprocessingDataColumn; 148 if (dateTimeColumn != null && dateTimeFunc != null) return dateTimeFunc(dateTimeColumn); 149 throw new InvalidOperationException("Invalid data column type."); 150 } 151 private TOut ColumnTypeSwitchFuncResult<TIn, TOut>(int columnIndex, TIn value, Func<DoublePreprocessingDataColumn, double?, TOut> doubleFunc, 152 Func<StringPreprocessingDataColumn, string, TOut> stringFunc = null, Func<DateTimePreprocessingDataColumn, DateTime?, TOut> dateTimeFunc = null) { 153 var doubleColumn = dataColumns[columnIndex] as DoublePreprocessingDataColumn; 154 if (doubleColumn != null && doubleFunc != null) return doubleFunc(doubleColumn, Convert<double?>(value)); 155 var stringColumn = dataColumns[columnIndex] as StringPreprocessingDataColumn; 156 if (stringColumn != null && stringFunc != null) return stringFunc(stringColumn, Convert<string>(value)); 157 var dateTimeColumn = dataColumns[columnIndex] as DateTimePreprocessingDataColumn; 158 if (dateTimeColumn != null && dateTimeFunc != null) return dateTimeFunc(dateTimeColumn, Convert<DateTime?>(value)); 159 throw new InvalidOperationException("Invalid data column type."); 160 } 161 162 private IList<T> ColumnTypeSwitchFuncList<T>(int columnIndex, Func<DoublePreprocessingDataColumn, IList<double>> doubleFunc, 163 Func<StringPreprocessingDataColumn, IList<string>> stringFunc = null, Func<DateTimePreprocessingDataColumn, IList<DateTime>> dateTimeFunc = null) { 164 var doubleColumn = dataColumns[columnIndex] as DoublePreprocessingDataColumn; 165 if (doubleColumn != null && doubleFunc != null) return Convert<IList<T>>(doubleFunc(doubleColumn)); 166 var stringColumn = dataColumns[columnIndex] as StringPreprocessingDataColumn; 167 if (stringColumn != null && stringFunc != null) return Convert<IList<T>>(stringFunc(stringColumn)); 168 var dateTimeColumn = dataColumns[columnIndex] as DateTimePreprocessingDataColumn; 169 if (dateTimeColumn != null && dateTimeFunc != null) return Convert<IList<T>>(dateTimeFunc(dateTimeColumn)); 170 throw new InvalidOperationException("Invalid data column type."); 171 } 172 private static T Convert<T>(object obj) { return (T)obj; } 173 104 174 105 175 public T GetCell<T>(int columnIndex, int rowIndex) { 106 return (T)variableValues[columnIndex][rowIndex]; 176 return ColumnTypeSwitchFunc<T>(columnIndex, 177 c => c[rowIndex], 178 c => c[rowIndex], 179 c => c[rowIndex]); 107 180 } 108 181 … … 115 188 InsertColumn<T>(i.ToString(), i); 116 189 117 variableValues[columnIndex][rowIndex] = value; 190 ColumnTypeSwitchAction<T>(columnIndex, value, 191 (c, v) => c[rowIndex] = v, 192 (c, v) => c[rowIndex] = v, 193 (c, v) => c[rowIndex] = v); 194 118 195 if (!IsInTransaction) 119 196 OnChanged(DataPreprocessingChangedEventType.ChangeItem, columnIndex, rowIndex); … … 121 198 122 199 public string GetCellAsString(int columnIndex, int rowIndex) { 123 return variableValues[columnIndex][rowIndex].ToString();200 return dataColumns[columnIndex].GetValue(rowIndex); 124 201 } 125 202 … … 128 205 var list = new List<T>(); 129 206 foreach (var rowIdx in selection[columnIndex]) { 130 list.Add((T)variableValues[columnIndex][rowIdx]); 207 list.Add(GetCell<T>(columnIndex, rowIdx)); 208 //list.Add((T)dataColumns[columnIndex][rowIdx]); 131 209 } 132 210 return list; 133 211 } else { 134 return (IList<T>)variableValues[columnIndex]; 212 return ColumnTypeSwitchFuncList<T>(columnIndex, 213 c => c.Values.Select(x => x ?? double.NaN).ToList(), 214 c => c.Values, 215 c => c.Values.Select(x => x ?? DateTime.MinValue).ToList()); 216 //(IList<T>)dataColumns[columnIndex]; 135 217 } 136 218 } … … 139 221 SaveSnapshot(DataPreprocessingChangedEventType.ChangeColumn, columnIndex, -1); 140 222 if (VariableHasType<T>(columnIndex)) { 141 variableValues[columnIndex] = (IList)values; 223 var name = dataColumns[columnIndex].Name; 224 if (dataColumns[columnIndex].IsType<double>()) { 225 dataColumns[columnIndex] = new DoublePreprocessingDataColumn(name, (IEnumerable<double>)values); 226 } else if (dataColumns[columnIndex].IsType<string>()) { 227 dataColumns[columnIndex] = new StringPreprocessingDataColumn(name, (IEnumerable<string>)values); 228 } else if (dataColumns[columnIndex].IsType<DateTime>()) { 229 dataColumns[columnIndex] = new DateTimePreprocessingDataColumn(name, (IEnumerable<DateTime>)values); 230 } else { 231 throw new ArgumentException("Unknown column type"); 232 } 142 233 } else { 143 throw new ArgumentException("The datatype of column " + columnIndex + " must be of type " + variableValues[columnIndex].GetType().Name + " but was " + typeof(T).Name);234 throw new ArgumentException("The datatype of column " + columnIndex + " must be of type " + dataColumns[columnIndex].GetType().Name + " but was " + typeof(T).Name); 144 235 } 145 236 if (!IsInTransaction) … … 179 270 180 271 public int Columns { 181 get { return variableNames.Count; }272 get { return dataColumns.Count; } 182 273 } 183 274 184 275 public int Rows { 185 get { return variableValues.Count > 0 ? variableValues[0].Count : 0; } 186 } 187 188 public static bool IsMissingValue(object value) { 189 if (value is double) return double.IsNaN((double)value); 190 if (value is string) return string.IsNullOrEmpty((string)value); 191 if (value is DateTime) return ((DateTime)value).Equals(DateTime.MinValue); 192 throw new ArgumentException(); 276 get { return dataColumns.Count > 0 ? dataColumns[0].Length : 0; } 193 277 } 194 278 #endregion … … 197 281 public void InsertRow(int rowIndex) { 198 282 SaveSnapshot(DataPreprocessingChangedEventType.DeleteRow, -1, rowIndex); 199 foreach (IList column in variableValues) { 200 Type type = column.GetType().GetGenericArguments()[0]; 201 column.Insert(rowIndex, type.IsValueType ? Activator.CreateInstance(type) : null); 283 foreach (var column in dataColumns) { 284 ColumnTypeSwitchAction(column, 285 c => c.Values.Insert(rowIndex, null), 286 c => c.Values.Insert(rowIndex, null), 287 c => c.Values.Insert(rowIndex, null)); 288 //var valueType = column.GetValueType(); 289 //column.Insert(rowIndex, valueType.IsValueType ? Activator.CreateInstance(valueType) : null); 202 290 } 203 291 if (TrainingPartition.Start <= rowIndex && rowIndex <= TrainingPartition.End) { … … 219 307 public void DeleteRow(int rowIndex) { 220 308 SaveSnapshot(DataPreprocessingChangedEventType.AddRow, -1, rowIndex); 221 foreach (IList column in variableValues) { 222 column.RemoveAt(rowIndex); 309 foreach (var column in dataColumns) { 310 ColumnTypeSwitchAction(column, 311 c => c.Values.RemoveAt(rowIndex), 312 c => c.Values.RemoveAt(rowIndex), 313 c => c.Values.RemoveAt(rowIndex)); 314 //column.RemoveAt(rowIndex); 223 315 } 224 316 if (TrainingPartition.Start <= rowIndex && rowIndex <= TrainingPartition.End) { … … 241 333 SaveSnapshot(DataPreprocessingChangedEventType.AddRow, -1, -1); 242 334 foreach (int rowIndex in rows.OrderByDescending(x => x)) { 243 foreach (IList column in variableValues) { 244 column.RemoveAt(rowIndex); 335 foreach (var column in dataColumns) { 336 ColumnTypeSwitchAction(column, 337 c => c.Values.RemoveAt(rowIndex), 338 c => c.Values.RemoveAt(rowIndex), 339 c => c.Values.RemoveAt(rowIndex)); 340 //column.RemoveAt(rowIndex); 245 341 } 246 342 if (TrainingPartition.Start <= rowIndex && rowIndex <= TrainingPartition.End) { … … 264 360 public void InsertColumn<T>(string variableName, int columnIndex) { 265 361 SaveSnapshot(DataPreprocessingChangedEventType.DeleteColumn, columnIndex, -1); 266 variableValues.Insert(columnIndex, new List<T>(Enumerable.Repeat(default(T), Rows))); 267 variableNames.Insert(columnIndex, variableName); 362 363 if (typeof(T) == typeof(double)) { 364 dataColumns.Insert(columnIndex, new DoublePreprocessingDataColumn(variableName, Enumerable.Repeat<double?>(null, Rows))); 365 } else if (typeof(T) == typeof(string)) { 366 dataColumns.Add(new StringPreprocessingDataColumn(variableName, Enumerable.Repeat<string>(null, Rows))); 367 } else if (typeof(T) == typeof(DateTime)) { 368 dataColumns.Add(new DateTimePreprocessingDataColumn(variableName, Enumerable.Repeat<DateTime?>(null, Rows))); 369 } else { 370 throw new ArgumentException("The datatype of column " + variableName + " must be of type double, string or DateTime"); 371 } 372 373 //dataColumns.Insert(columnIndex, new List<T>(Enumerable.Repeat(default(T), Rows))); 374 //variableNames.Insert(columnIndex, variableName); 268 375 if (!IsInTransaction) 269 376 OnChanged(DataPreprocessingChangedEventType.AddColumn, columnIndex, -1); … … 272 379 public void DeleteColumn(int columnIndex) { 273 380 SaveSnapshot(DataPreprocessingChangedEventType.AddColumn, columnIndex, -1); 274 variableValues.RemoveAt(columnIndex);275 variableNames.RemoveAt(columnIndex);381 dataColumns.RemoveAt(columnIndex); 382 //variableNames.RemoveAt(columnIndex); 276 383 if (!IsInTransaction) 277 384 OnChanged(DataPreprocessingChangedEventType.DeleteColumn, columnIndex, -1); … … 280 387 public void RenameColumn(int columnIndex, string name) { 281 388 SaveSnapshot(DataPreprocessingChangedEventType.ChangeColumn, columnIndex, -1); 282 if (columnIndex < 0 || columnIndex > variableNames.Count)389 if (columnIndex < 0 || columnIndex > dataColumns.Count) 283 390 throw new ArgumentOutOfRangeException("columnIndex"); 284 variableNames[columnIndex]= name;391 dataColumns[columnIndex].Name = name; 285 392 286 393 if (!IsInTransaction) … … 290 397 public void RenameColumns(IList<string> names) { 291 398 if (names == null) throw new ArgumentNullException("names"); 292 if (names.Count != variableNames.Count) throw new ArgumentException("number of names must match the number of columns.", "names");399 if (names.Count != dataColumns.Count) throw new ArgumentException("number of names must match the number of columns.", "names"); 293 400 294 401 SaveSnapshot(DataPreprocessingChangedEventType.ChangeColumn, -1, -1); 295 402 for (int i = 0; i < names.Count; i++) 296 variableNames[i]= names[i];403 dataColumns[i].Name = names[i]; 297 404 298 405 if (!IsInTransaction) … … 307 414 #region Variables 308 415 public IEnumerable<string> VariableNames { 309 get { return variableNames; }416 get { return dataColumns.Select(c => c.Name); } 310 417 } 311 418 312 419 public IEnumerable<string> GetDoubleVariableNames() { 313 var doubleVariableNames = new List<string>(); 314 for (int i = 0; i < Columns; ++i) { 315 if (VariableHasType<double>(i)) { 316 doubleVariableNames.Add(variableNames[i]); 317 } 318 } 319 return doubleVariableNames; 420 return dataColumns.OfType<DoublePreprocessingDataColumn>().Select(c => c.Name); 320 421 } 321 422 322 423 public string GetVariableName(int columnIndex) { 323 return variableNames[columnIndex];424 return dataColumns[columnIndex].Name; 324 425 } 325 426 326 427 public int GetColumnIndex(string variableName) { 327 return variableNames.IndexOf(variableName);428 return dataColumns.FindIndex(c => c.Name == variableName); 328 429 } 329 430 330 431 public bool VariableHasType<T>(int columnIndex) { 331 return columnIndex >= variableValues.Count || variableValues[columnIndex] is List<T>;432 return dataColumns[columnIndex].IsType<T>(); 332 433 } 333 434 334 435 public Type GetVariableType(int columnIndex) { 335 var listType = variableValues[columnIndex].GetType(); 336 return listType.GenericTypeArguments.Single(); 436 return dataColumns[columnIndex].GetValueType(); 337 437 } 338 438 … … 392 492 #region Import & Export 393 493 public void Import(IDataAnalysisProblemData problemData) { 394 Dataset dataset = (Dataset)problemData.Dataset; 395 variableNames = new List<string>(problemData.Dataset.VariableNames); 494 var dataset = problemData.Dataset; 396 495 InputVariables = new List<string>(problemData.AllowedInputVariables); 397 TargetVariable = (problemData is IRegressionProblemData) ? ((IRegressionProblemData)problemData).TargetVariable 398 : (problemData is IClassificationProblemData) ? ((IClassificationProblemData)problemData).TargetVariable 399 : null; 400 401 int columnIndex = 0; 402 variableValues = new List<IList>(); 496 TargetVariable = problemData is IRegressionProblemData ? ((IRegressionProblemData)problemData).TargetVariable 497 : problemData is IClassificationProblemData ? ((IClassificationProblemData)problemData).TargetVariable 498 : null; 499 500 dataColumns.Clear(); 403 501 foreach (var variableName in problemData.Dataset.VariableNames) { 404 502 if (dataset.VariableHasType<double>(variableName)) { 405 variableValues.Insert(columnIndex, dataset.GetDoubleValues(variableName).ToList());503 dataColumns.Add(new DoublePreprocessingDataColumn(variableName, dataset.GetDoubleValues(variableName))); 406 504 } else if (dataset.VariableHasType<string>(variableName)) { 407 variableValues.Insert(columnIndex, dataset.GetStringValues(variableName).ToList());505 dataColumns.Add(new StringPreprocessingDataColumn(variableName, dataset.GetStringValues(variableName))); 408 506 } else if (dataset.VariableHasType<DateTime>(variableName)) { 409 variableValues.Insert(columnIndex, dataset.GetDateTimeValues(variableName).ToList());507 dataColumns.Add(new DateTimePreprocessingDataColumn(variableName, dataset.GetDateTimeValues(variableName))); 410 508 } else { 411 509 throw new ArgumentException("The datatype of column " + variableName + " must be of type double, string or DateTime"); 412 510 } 413 ++columnIndex;414 511 } 415 512 … … 421 518 IList<IList> values = new List<IList>(); 422 519 423 for (int i = 0; i < Columns; ++i) { 424 values.Add(variableValues[i]); 425 } 426 427 var dataset = new Dataset(variableNames, values); 428 return dataset; 520 for (int i = 0; i < Columns; i++) { 521 var doubleColumn = dataColumns[i] as DoublePreprocessingDataColumn; 522 var stringColumn = dataColumns[i] as StringPreprocessingDataColumn; 523 var dateTimeColumn = dataColumns[i] as DateTimePreprocessingDataColumn; 524 if (doubleColumn != null) values.Add(new List<double>(doubleColumn.Values.Select(x => x ?? double.NaN))); 525 else if (stringColumn != null) values.Add(new List<string>(stringColumn.Values)); 526 else if (dateTimeColumn != null) values.Add(new List<DateTime>(dateTimeColumn.Values.Select(x => x ?? DateTime.MinValue))); 527 else throw new InvalidOperationException("Column type not supported for export"); 528 } 529 530 return new Dataset(VariableNames, values); 429 531 } 430 532 #endregion … … 452 554 453 555 #region Transactions 454 // S tapshot/History are nost storable/cloneable on purpose556 // Snapshot/History are not storable/cloneable on purpose 455 557 private class Snapshot { 456 public IList<IList> VariableValues { get; set; } 457 public IList<string> VariableNames { get; set; } 558 public List<PreprocessingDataColumn> DataColumns { get; set; } 458 559 459 560 public IntRange TrainingPartition { get; set; } … … 472 573 } 473 574 474 private const int M AX_UNDO_DEPTH= 5;575 private const int MaxUndoDepth = 5; 475 576 476 577 private readonly IList<Snapshot> undoHistory = new List<Snapshot>(); … … 482 583 if (IsInTransaction) return; 483 584 585 var cloner = new Cloner(); 484 586 var currentSnapshot = new Snapshot { 485 VariableValues = CopyVariableValues(variableValues), 486 VariableNames = new List<string>(variableNames), 587 DataColumns = new List<PreprocessingDataColumn>(dataColumns.Select(cloner.Clone)), 487 588 TrainingPartition = new IntRange(TrainingPartition.Start, TrainingPartition.End), 488 589 TestPartition = new IntRange(TestPartition.Start, TestPartition.End), … … 493 594 }; 494 595 495 if (undoHistory.Count >= M AX_UNDO_DEPTH)596 if (undoHistory.Count >= MaxUndoDepth) 496 597 undoHistory.RemoveAt(0); 497 598 … … 506 607 if (IsUndoAvailable) { 507 608 Snapshot previousSnapshot = undoHistory[undoHistory.Count - 1]; 508 variableValues = previousSnapshot.VariableValues; 509 variableNames = previousSnapshot.VariableNames; 609 dataColumns = previousSnapshot.DataColumns; 510 610 TrainingPartition = previousSnapshot.TrainingPartition; 511 611 TestPartition = previousSnapshot.TestPartition; … … 620 720 621 721 private IEnumerable<T> GetValuesWithoutMissingValues<T>(int columnIndex, bool considerSelection) { 622 return GetValues<T>(columnIndex, considerSelection).Where(x => !IsMissingValue(x)); 722 //var doubleColumn = dataColumns[columnIndex] as DoublePreprocessingDataColumn; 723 //var stringColumn = dataColumns[columnIndex] as StringPreprocessingDataColumn; 724 //var dateTimeColumn = dataColumns[columnIndex] as DateTimePreprocessingDataColumn; 725 //return GetValues<T>(columnIndex, considerSelection).Where(x => 726 // doubleColumn != null ? doubleColumn.IsValidValue(Convert<double>(x)) 727 // : stringColumn != null ? stringColumn.IsValidValue(Convert<string>(x)) 728 // : dateTimeColumn != null ? dateTimeColumn.IsValidValue(Convert<DateTime>(x)) 729 // : false); 730 //!IsMissingValue(x)); 731 732 return GetValues<T>(columnIndex, considerSelection).Where(x => 733 ColumnTypeSwitchFuncResult<T, bool>(columnIndex, x, 734 (c, v) => v.HasValue && c.IsValidValue(v.Value), 735 (c, v) => c.IsValidValue(v), 736 (c, v) => v.HasValue && c.IsValidValue(v.Value) 737 )); 623 738 } 624 739 … … 626 741 return new DateTime((long)(func(values.Select(x => (double)x.Ticks / TimeSpan.TicksPerSecond)) * TimeSpan.TicksPerSecond)); 627 742 } 628 private static T Convert<T>(object obj) { return (T)obj; }629 743 630 744 public int GetMissingValueCount() { -
branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj
r15285 r15291 123 123 <Compile Include="Content\ScatterPlotContent.cs" /> 124 124 <Compile Include="Content\DataCompletenessChartContent.cs" /> 125 <Compile Include="Data\Columns\DateTimePreprocessingDataColumn.cs" /> 126 <Compile Include="Data\Columns\DoublePreprocessingDataColumn.cs" /> 127 <Compile Include="Data\Columns\PreprocessingDataColumn.cs" /> 128 <Compile Include="Data\Columns\StringPreprocessingDataColumn.cs" /> 125 129 <Compile Include="Data\FilteredPreprocessingData.cs" /> 126 130 <Compile Include="Content\ManipulationContent.cs" />
Note: See TracChangeset
for help on using the changeset viewer.