Changeset 15012


Ignore:
Timestamp:
05/31/17 14:12:56 (5 years ago)
Author:
pfleck
Message:

#2709 Merged trunk changes to branch.

Location:
branches/DataPreprocessing Enhancements
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing

  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views

  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/CheckedFilterCollectionView.cs

    r14996 r15012  
    3434      InitializeComponent();
    3535    }
    36 
    37     protected override void addButton_Click(object sender, EventArgs e) {
    38       IFilter filter = new ComparisonFilter();
    39       Content.Add(filter);
    40       Content.SetItemCheckedState(filter, false);
    41     }
    42 
    4336  }
    4437}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj

    r14915 r15012  
    178178  <ItemGroup>
    179179    <Compile Include="DataPreprocessingMenuItem.cs" />
    180     <Compile Include="PreprocessingChartView.cs">
    181       <SubType>UserControl</SubType>
    182     </Compile>
    183     <Compile Include="PreprocessingChartView.Designer.cs">
    184       <DependentUpon>PreprocessingChartView.cs</DependentUpon>
     180    <Compile Include="PreprocessingCheckedVariablesView.cs">
     181      <SubType>UserControl</SubType>
     182    </Compile>
     183    <Compile Include="PreprocessingCheckedVariablesView.Designer.cs">
     184      <DependentUpon>PreprocessingCheckedVariablesView.cs</DependentUpon>
    185185    </Compile>
    186186    <Compile Include="PreprocessingFeatureCorrelationView.cs">
     
    281281    </Compile>
    282282    <Compile Include="Plugin.cs" />
    283     <Compile Include="PreprocessingCheckedVariablesView.cs">
    284       <SubType>UserControl</SubType>
    285     </Compile>
    286     <Compile Include="PreprocessingCheckedVariablesView.Designer.cs">
    287       <DependentUpon>PreprocessingCheckedVariablesView.cs</DependentUpon>
     283    <Compile Include="PreprocessingChartView.cs">
     284      <SubType>UserControl</SubType>
     285    </Compile>
     286    <Compile Include="PreprocessingChartView.Designer.cs">
     287      <DependentUpon>PreprocessingChartView.cs</DependentUpon>
    288288    </Compile>
    289289    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4

  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Data/PreprocessingData.cs

    r14996 r15012  
    145145
    146146    private void CheckPartitionRanges() {
    147       int maxRowIndex = Math.Max(0, Rows - 1);
     147      int maxRowIndex = Math.Max(0, Rows);
    148148      TrainingPartition.Start = Math.Min(TrainingPartition.Start, maxRowIndex);
    149149      TrainingPartition.End = Math.Min(TrainingPartition.End, maxRowIndex);
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj

    r14473 r15012  
    126126      <SpecificVersion>False</SpecificVersion>
    127127      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll</HintPath>
     128    </Reference>
     129    <Reference Include="HeuristicLab.Random-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     130      <SpecificVersion>False</SpecificVersion>
     131      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
    128132    </Reference>
    129133    <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Logic/ManipulationLogic.cs

    r14996 r15012  
    2424using System.Linq;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Random;
    2627
    2728namespace HeuristicLab.DataPreprocessing {
     
    8182    public void ReplaceIndicesByRandomValue(IDictionary<int, IList<int>> cells, bool considerSelection = false) {
    8283      preprocessingData.InTransaction(() => {
    83         Random r = new Random();
     84        System.Random r = new System.Random();
    8485
    8586        foreach (var column in cells) {
     
    219220
    220221    public void Shuffle(bool shuffleRangesSeparately) {
    221       Random random = new Random();
    222       var ranges = new[] { preprocessingData.TestPartition, preprocessingData.TrainingPartition };
     222      var random = new FastRandom();
     223
    223224      if (shuffleRangesSeparately) {
     225        var ranges = new[] { preprocessingData.TestPartition, preprocessingData.TrainingPartition };
    224226        preprocessingData.InTransaction(() => {
    225227          // process all given ranges - e.g. TrainingPartition, TestPartition
    226228          foreach (IntRange range in ranges) {
    227             List<Tuple<int, int>> shuffledIndices = new List<Tuple<int, int>>();
    228 
    229             // generate random indices used for shuffeling each column
    230             for (int i = range.End - 1; i >= range.Start; --i) {
    231               int rand = random.Next(range.Start, i);
    232               shuffledIndices.Add(new Tuple<int, int>(i, rand));
    233             }
    234 
    235             ShuffleToIndices(shuffledIndices);
     229            var indices = Enumerable.Range(0, preprocessingData.Rows).ToArray();
     230            var shuffledIndices = Enumerable.Range(range.Start, range.Size).Shuffle(random).ToArray();
     231            for (int i = range.Start, j = 0; i < range.End; i++, j++)
     232              indices[i] = shuffledIndices[j];
     233
     234            ReOrderToIndices(indices);
    236235          }
    237236        });
     237
    238238      } else {
    239239        preprocessingData.InTransaction(() => {
    240           var indices = ranges.SelectMany(x => Enumerable.Range(x.Start, x.Size)).ToList();
    241           var shuffledIndices = indices.OrderBy(x => random.Next());
    242           ShuffleToIndices(indices.Zip(shuffledIndices, (i, j) => new Tuple<int, int>(i, j)).ToList());
     240          var indices = Enumerable.Range(0, preprocessingData.Rows);
     241          var shuffledIndices = indices.Shuffle(random).ToArray();
     242          ReOrderToIndices(shuffledIndices);
    243243        });
    244244      }
    245245    }
    246246
    247     public void ReOrderToIndices(IEnumerable<int> indices) {
    248       List<Tuple<int, int>> indicesTuple = new List<Tuple<int, int>>();
    249 
    250       for (int i = 0; i < indices.Count(); ++i) {
    251         indicesTuple.Add(new Tuple<int, int>(i, indices.ElementAt(i)));
    252       }
    253 
    254       ReOrderToIndices(indicesTuple);
    255     }
    256 
    257     public void ReOrderToIndices(IList<System.Tuple<int, int>> indices) {
     247    public void ReOrderToIndices(int[] indices) {
    258248      preprocessingData.InTransaction(() => {
    259249        for (int i = 0; i < preprocessingData.Columns; ++i) {
     
    269259    }
    270260
    271     public void ShuffleToIndices(IList<System.Tuple<int, int>> indices) {
    272       preprocessingData.InTransaction(() => {
    273         for (int i = 0; i < preprocessingData.Columns; ++i) {
    274           if (preprocessingData.VariableHasType<double>(i)) {
    275             ShuffleToIndices<double>(i, indices);
    276           } else if (preprocessingData.VariableHasType<string>(i)) {
    277             ShuffleToIndices<string>(i, indices);
    278           } else if (preprocessingData.VariableHasType<DateTime>(i)) {
    279             ShuffleToIndices<DateTime>(i, indices);
    280           }
    281         }
    282       });
    283     }
    284 
    285     private void ReOrderToIndices<T>(int columnIndex, IList<Tuple<int, int>> indices) {
     261    private void ReOrderToIndices<T>(int columnIndex, int[] indices) {
    286262      List<T> originalData = new List<T>(preprocessingData.GetValues<T>(columnIndex));
    287 
    288       // process all columns equally
    289       foreach (Tuple<int, int> index in indices) {
    290         int originalIndex = index.Item1;
    291         int replaceIndex = index.Item2;
     263      if (indices.Length != originalData.Count) throw new InvalidOperationException("The number of provided indices does not match the values.");
     264
     265      for (int i = 0; i < indices.Length; i++) {
     266        int originalIndex = i;
     267        int replaceIndex = indices[i];
    292268
    293269        T replaceValue = originalData.ElementAt<T>(replaceIndex);
    294270        preprocessingData.SetCell<T>(columnIndex, originalIndex, replaceValue);
    295       }
    296     }
    297 
    298     private void ShuffleToIndices<T>(int columnIndex, IList<Tuple<int, int>> indices) {
    299       // process all columns equally
    300       foreach (Tuple<int, int> index in indices) {
    301         int originalIndex = index.Item1;
    302         int replaceIndex = index.Item2;
    303 
    304         T tmp = preprocessingData.GetCell<T>(columnIndex, originalIndex);
    305         T replaceValue = preprocessingData.GetCell<T>(columnIndex, replaceIndex);
    306 
    307         preprocessingData.SetCell<T>(columnIndex, originalIndex, replaceValue);
    308         preprocessingData.SetCell<T>(columnIndex, replaceIndex, tmp);
    309271      }
    310272    }
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Plugin.cs.frame

    r14472 r15012  
    3737  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    3838  [PluginDependency("HeuristicLab.Problems.DataAnalysis","3.4")]
     39  [PluginDependency("HeuristicLab.Random", "3.3")]
    3940  [PluginDependency("HeuristicLab.Visualization.ChartControlsExtensions", "3.3")]
    4041  public class HeuristicLabDataPreprocessingPlugin : PluginBase {
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/PreprocessingTransformator.cs

    r14400 r15012  
    113113      // don't apply when the check fails
    114114      if (success)
    115         return transformation.Apply(data);
     115        return transformation.ConfigureAndApply(data);
    116116      else
    117117        return data;
Note: See TracChangeset for help on using the changeset viewer.