- Timestamp:
- 06/21/10 13:21:14 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/SupportVectorMachine/SupportVectorMachineCrossValidationEvaluator.cs
r3884 r3933 152 152 153 153 int reducedRows = (int)((SamplesEnd.Value - SamplesStart.Value) * reductionRatio); 154 varreducedProblemData = (DataAnalysisProblemData)DataAnalysisProblemData.Clone();155 ShuffleRows(RandomParameter.ActualValue, reducedProblemData.Dataset, SamplesStart.Value, SamplesEnd.Value);154 DataAnalysisProblemData reducedProblemData = (DataAnalysisProblemData)DataAnalysisProblemData.Clone(); 155 reducedProblemData.Dataset = CreateReducedDataset(RandomParameter.ActualValue, reducedProblemData.Dataset, reductionRatio, SamplesStart.Value, SamplesEnd.Value); 156 156 157 157 double quality = PerformCrossValidation(reducedProblemData, … … 164 164 } 165 165 166 private void ShuffleRows(IRandom random, Dataset dataset, int start, int end) { 167 for (int row = end - 1; row > start ; row--) { 168 int otherRow = random.Next(start, row); 169 for (int column = 0; column < dataset.Columns; column++) { 170 double tmp = dataset[otherRow, column]; 171 dataset[otherRow, column] = dataset[row, column]; 172 dataset[row, column] = tmp; 173 } 166 private Dataset CreateReducedDataset(IRandom random, Dataset dataset, double reductionRatio, int start, int end) { 167 int reducedRows = (int)((end - start) * reductionRatio); 168 double[,] reducedData = dataset.GetClonedData(); 169 HashSet<int> leftRows = new HashSet<int>(Enumerable.Range(0, end - start)); 170 for (int row = 0; row < reducedRows; row++) { 171 int rowIndex = random.Next(0, leftRows.Count); 172 leftRows.Remove(rowIndex); 173 for (int column = 0; column < dataset.Columns; column++) 174 reducedData[row, column] = dataset[rowIndex, column]; 174 175 } 176 return new Dataset(dataset.VariableNames, reducedData); 175 177 } 176 178
Note: See TracChangeset
for help on using the changeset viewer.