- Timestamp:
- 06/11/14 15:15:54 (10 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingData.cs
r10992 r10994 35 35 public abstract class PreprocessingData : NamedItem, IPreprocessingData { 36 36 37 protected double trainingToTestRatio; 38 public IntRange TrainingPartition { 39 get { return new IntRange(0, (int)(Rows * trainingToTestRatio)); } 40 } 41 public IntRange TestPartition { 42 get { return new IntRange((int)(Rows * trainingToTestRatio), Rows); } 43 } 37 public IntRange TrainingPartition { get; set; } 38 public IntRange TestPartition { get; set; } 44 39 45 40 protected IList<ITransformation> transformations; … … 86 81 variableValues = CopyVariableValues(original.variableValues); 87 82 variableNames = new List<string>(original.variableNames); 88 trainingToTestRatio = original.trainingToTestRatio; 83 TrainingPartition = (IntRange)original.TrainingPartition.Clone(cloner); 84 TestPartition = (IntRange)original.TestPartition.Clone(cloner); 89 85 transformations = new List<ITransformation>(); 86 87 RegisterEventHandler(); 90 88 } 91 89 … … 114 112 } 115 113 116 trainingToTestRatio = (double)problemData.TrainingPartition.Size / Math.Max(problemData.Dataset.Rows, double.Epsilon); 114 TrainingPartition = new IntRange(problemData.TrainingPartition.Start, problemData.TrainingPartition.End); 115 TestPartition = new IntRange(problemData.TestPartition.Start, problemData.TestPartition.End); 116 117 RegisterEventHandler(); 118 } 119 120 private void RegisterEventHandler() { 121 Changed += (s, e) => { 122 switch (e.Type) { 123 case DataPreprocessingChangedEventType.DeleteRow: 124 CheckPartitionRanges(); 125 break; 126 case DataPreprocessingChangedEventType.Any: 127 CheckPartitionRanges(); 128 break; 129 case DataPreprocessingChangedEventType.Transformation: 130 CheckPartitionRanges(); 131 break; 132 } 133 }; 117 134 } 118 135 … … 125 142 } 126 143 144 private void CheckPartitionRanges() { 145 int maxRowIndex = Math.Max(0, Rows - 1); 146 TrainingPartition.Start = Math.Min(TrainingPartition.Start, maxRowIndex); 147 TrainingPartition.End = Math.Min(TrainingPartition.End, maxRowIndex); 148 TestPartition.Start = Math.Min(TestPartition.Start, maxRowIndex); 149 TestPartition.End = Math.Min(TestPartition.End, maxRowIndex); 150 } 151 127 152 protected IList<IList> CopyVariableValues(IList<IList> original) { 128 153 var copy = new List<IList>(original); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/TransactionalPreprocessingData.cs
r10991 r10994 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 27 28 using HeuristicLab.Problems.DataAnalysis; 28 29 using HeuristicLab.Problems.DataAnalysis.Transformations; … … 37 38 public IList<string> VariableNames { get; set; } 38 39 39 public double TrainingToTestRatio { get; set; } 40 public IntRange TrainingPartition { get; set; } 41 public IntRange TestPartition { get; set; } 40 42 public IList<ITransformation> Transformations { get; set; } 41 43 public DataPreprocessingChangedEventType ChangedType { get; set; } … … 66 68 VariableValues = CopyVariableValues(variableValues), 67 69 VariableNames = new List<string>(variableNames), 68 TrainingToTestRatio = trainingToTestRatio, 70 TrainingPartition = new IntRange(TrainingPartition.Start, TrainingPartition.End), 71 TestPartition = new IntRange(TestPartition.Start, TestPartition.End), 69 72 Transformations = new List<ITransformation>(transformations), 70 73 ChangedType = changedType, … … 235 238 variableValues = previousSnapshot.VariableValues; 236 239 variableNames = previousSnapshot.VariableNames; 237 trainingToTestRatio = previousSnapshot.TrainingToTestRatio; 240 TrainingPartition = previousSnapshot.TrainingPartition; 241 TestPartition = previousSnapshot.TestPartition; 238 242 transformations = previousSnapshot.Transformations; 239 243 undoHistory.Remove(previousSnapshot);
Note: See TracChangeset
for help on using the changeset viewer.