Changeset 10218
- Timestamp:
- 12/11/13 15:55:30 (11 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingData.cs
r10194 r10218 27 27 using HeuristicLab.Core; 28 28 using HeuristicLab.Problems.DataAnalysis; 29 using HeuristicLab.Data; 29 30 30 31 namespace HeuristicLab.DataPreprocessing { … … 35 36 36 37 private IList<string> variableNames; 38 private IntRange trainingPartition; 39 private IntRange testPartition; 37 40 38 41 private IDictionary<string, int> variableNameIndices; … … 71 74 } 72 75 } 76 77 trainingPartition = problemData.TrainingPartition; 78 testPartition = problemData.TestPartition; 73 79 74 80 trainingToTestRatio = (double)problemData.TrainingPartition.Size / problemData.TestPartition.Size; -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingDataManipulation.cs
r10193 r10218 1 using System; 1 using HeuristicLab.Data; 2 using System; 2 3 using System.Collections.Generic; 3 4 using System.Linq; … … 87 88 } 88 89 } 90 91 public void ShuffleWithRanges(IEnumerable<IntRange> ranges) 92 { 93 // init random outside loop 94 Random random = new Random(); 95 96 // process all given ranges - e.g. TrainingPartition, Trainingpartition 97 foreach (IntRange range in ranges) { 98 List<int> shuffledIndices = new List<int>(); 99 100 // generate random indices used for shuffeling each column 101 for (int i = range.End; i > range.Start; --i) 102 { 103 int rand = random.Next(range.Start, i); 104 shuffledIndices[i] = rand; 105 } 106 107 foreach (string variableName in preprocessingData.VariableNames) 108 { 109 if (preprocessingData.IsType<double>(variableName)) 110 { 111 reOrderToIndices<double>(variableName, shuffledIndices); 112 } 113 else if (preprocessingData.IsType<string>(variableName)) 114 { 115 reOrderToIndices<string>(variableName, shuffledIndices); 116 } 117 else if (preprocessingData.IsType<DateTime>(variableName)) 118 { 119 reOrderToIndices<DateTime>(variableName, shuffledIndices); 120 } 121 } 122 } 123 } 124 125 public void reOrderToIndices<T>(string variableName, List<int> indices) { 126 // process all columns equally 127 for (int i = 0; i < preprocessingData.Rows; i++) 128 { 129 int replaceIndex = indices[i]; 130 131 T tmp = preprocessingData.GetCell<T>(variableName, i); 132 T replaceValue = preprocessingData.GetCell<T>(variableName, replaceIndex); 133 134 preprocessingData.SetCell<T>(variableName, i, replaceValue); 135 preprocessingData.SetCell<T>(variableName, replaceIndex, tmp); 136 } 137 } 89 138 } 90 139 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IPreprocessingData.cs
r10194 r10218 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Problems.DataAnalysis; 25 using HeuristicLab.Data; 25 26 26 27 namespace HeuristicLab.DataPreprocessing { … … 35 36 void InsertRow(int rowIndex); 36 37 void DeleteRow(int rowIndex); 38 39 IntRange TrainingPartition { get; } 40 IntRange TestPartition { get; } 37 41 38 42 void InsertColumn<T>(string variableName, int columnIndex);
Note: See TracChangeset
for help on using the changeset viewer.