Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11380


Ignore:
Timestamp:
09/18/14 15:08:00 (10 years ago)
Author:
bburlacu
Message:

#2245: Added a checkbox in the properties section of the shuffle data tab in the ManipulationView to specify whether the problem data should be shuffled as a whole or separately for each training/test range. Modified ShuffleToIndices methods accordingly. Also fixed very small typo in ManipulationContent.cs

Location:
trunk/sources/HeuristicLab.DataPreprocessing/3.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/ManipulationContent.cs

    r11171 r11380  
    4141    }
    4242
    43     public ManipulationContent(IManipulationLogic theManipulationLogic, ISearchLogic theSearchLogic, IFilterLogic theFitlerLogic) {
     43    public ManipulationContent(IManipulationLogic theManipulationLogic, ISearchLogic theSearchLogic, IFilterLogic theFilterLogic) {
    4444      manipulationLogic = theManipulationLogic;
    4545      searchLogic = theSearchLogic;
    46       filterLogic = theFitlerLogic;
     46      filterLogic = theFilterLogic;
    4747    }
    4848
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/ManipulationLogic.cs

    r11171 r11380  
    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) {
     227    public void ShuffleWithRanges(bool shuffleRangesSeparately) {
     228      var ranges = new[] { preprocessingData.TestPartition, preprocessingData.TrainingPartition };
     229      ShuffleWithRanges(ranges, shuffleRangesSeparately);
     230    }
     231
     232    public void ShuffleWithRanges(IEnumerable<IntRange> ranges, bool shuffleRangesSeparately) {
    235233      // init random outside loop
    236234      Random random = new Random();
    237235
    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       });
     236      if (shuffleRangesSeparately) {
     237        preprocessingData.InTransaction(() => {
     238          // process all given ranges - e.g. TrainingPartition, TestPartition
     239          foreach (IntRange range in ranges) {
     240            List<Tuple<int, int>> shuffledIndices = new List<Tuple<int, int>>();
     241
     242            // generate random indices used for shuffeling each column
     243            for (int i = range.End - 1; i >= range.Start; --i) {
     244              int rand = random.Next(range.Start, i);
     245              shuffledIndices.Add(new Tuple<int, int>(i, rand));
     246            }
     247
     248            ShuffleToIndices(shuffledIndices);
     249          }
     250        });
     251      } else {
     252        preprocessingData.InTransaction(() => {
     253          var indices = ranges.SelectMany(x => Enumerable.Range(x.Start, x.Size)).ToList();
     254          var shuffledIndices = indices.OrderBy(x => random.Next());
     255          ShuffleToIndices(indices.Zip(shuffledIndices, (i, j) => new Tuple<int, int>(i, j)).ToList());
     256        });
     257      }
    252258    }
    253259
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Interfaces/IManipulationLogic.cs

    r11171 r11380  
    3838    void ReplaceIndicesByValue(IDictionary<int, IList<int>> cells, string value);
    3939    void ReplaceIndicesByValue<T>(int columnIndex, IEnumerable<int> rowIndices, T value);
    40     void ShuffleWithRanges();
    41     void ShuffleWithRanges(IEnumerable<HeuristicLab.Data.IntRange> ranges);
     40    void ShuffleWithRanges(bool shuffleRangesSeparately);
     41    void ShuffleWithRanges(IEnumerable<HeuristicLab.Data.IntRange> ranges, bool shuffleRangesSeparately);
    4242    List<int> RowsWithMissingValuesGreater(double percent);
    4343    List<int> ColumnsWithMissingValuesGreater(double percent);
Note: See TracChangeset for help on using the changeset viewer.