Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/11/14 12:56:55 (9 years ago)
Author:
mkommend
Message:

#2245: Merged r11380, r11381 & r11403 into stable.

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.DataPreprocessing/3.4/Implementations/ManipulationLogic.cs

    r11170 r11537  
    225225    }
    226226
    227     public void ShuffleWithRanges() {
    228       ShuffleWithRanges(new[] {
    229         preprocessingData.TestPartition,
    230         preprocessingData.TrainingPartition
    231       });
    232     }
    233 
    234     public void ShuffleWithRanges(IEnumerable<IntRange> ranges) {
    235       // init random outside loop
     227    public void Shuffle(bool shuffleRangesSeparately) {
    236228      Random random = new Random();
    237 
    238       preprocessingData.InTransaction(() => {
    239         // process all given ranges - e.g. TrainingPartition, TestPartition
    240         foreach (IntRange range in ranges) {
    241           List<Tuple<int, int>> shuffledIndices = new List<Tuple<int, int>>();
    242 
    243           // generate random indices used for shuffeling each column
    244           for (int i = range.End - 1; i >= range.Start; --i) {
    245             int rand = random.Next(range.Start, i);
    246             shuffledIndices.Add(new Tuple<int, int>(i, rand));
    247           }
    248 
    249           ShuffleToIndices(shuffledIndices);
    250         }
    251       });
     229      var ranges = new[] { preprocessingData.TestPartition, preprocessingData.TrainingPartition };
     230      if (shuffleRangesSeparately) {
     231        preprocessingData.InTransaction(() => {
     232          // process all given ranges - e.g. TrainingPartition, TestPartition
     233          foreach (IntRange range in ranges) {
     234            List<Tuple<int, int>> shuffledIndices = new List<Tuple<int, int>>();
     235
     236            // generate random indices used for shuffeling each column
     237            for (int i = range.End - 1; i >= range.Start; --i) {
     238              int rand = random.Next(range.Start, i);
     239              shuffledIndices.Add(new Tuple<int, int>(i, rand));
     240            }
     241
     242            ShuffleToIndices(shuffledIndices);
     243          }
     244        });
     245      } else {
     246        preprocessingData.InTransaction(() => {
     247          var indices = ranges.SelectMany(x => Enumerable.Range(x.Start, x.Size)).ToList();
     248          var shuffledIndices = indices.OrderBy(x => random.Next());
     249          ShuffleToIndices(indices.Zip(shuffledIndices, (i, j) => new Tuple<int, int>(i, j)).ToList());
     250        });
     251      }
    252252    }
    253253
Note: See TracChangeset for help on using the changeset viewer.