Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10718


Ignore:
Timestamp:
04/02/14 16:08:56 (10 years ago)
Author:
mleitner
Message:

Add shuffletoindices

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ManipulationLogic.cs

    r10715 r10718  
    203203          }
    204204
    205           ReOrderToIndices(shuffledIndices);
     205          ShuffleToIndices(shuffledIndices);
    206206        }
    207207      });
     
    232232    }
    233233
     234    public void ShuffleToIndices(IList<System.Tuple<int, int>> indices)
     235    {
     236      preprocessingData.InTransaction(() =>
     237      {
     238        for (int i = 0; i < preprocessingData.Columns; ++i)
     239        {
     240          if (preprocessingData.IsType<double>(i))
     241          {
     242            ShuffleToIndices<double>(i, indices);
     243          }
     244          else if (preprocessingData.IsType<string>(i))
     245          {
     246            ShuffleToIndices<string>(i, indices);
     247          }
     248          else if (preprocessingData.IsType<DateTime>(i))
     249          {
     250            ShuffleToIndices<DateTime>(i, indices);
     251          }
     252        }
     253      });
     254    }
     255
    234256    private void reOrderToIndices<T>(int columnIndex, IList<Tuple<int, int>> indices) {
    235257
     
    246268    }
    247269
     270    private void ShuffleToIndices<T>(int columnIndex, IList<Tuple<int, int>> indices)
     271    {
     272      // process all columns equally
     273      foreach (Tuple<int, int> index in indices)
     274      {
     275        int originalIndex = index.Item1;
     276        int replaceIndex = index.Item2;
     277
     278        T tmp = preprocessingData.GetCell<T>(columnIndex, originalIndex);
     279        T replaceValue = preprocessingData.GetCell<T>(columnIndex, replaceIndex);
     280
     281        preprocessingData.SetCell<T>(columnIndex, originalIndex, replaceValue);
     282        preprocessingData.SetCell<T>(columnIndex, replaceIndex, tmp);
     283      }
     284    }
     285
    248286    public void ReplaceIndicesByValue(IDictionary<int, IList<int>> cells, string value) {
    249287      preprocessingData.InTransaction(() => {
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IManipulationLogic.cs

    r10715 r10718  
    2727    void ReOrderToIndices(IEnumerable<int> indices);
    2828    void ReOrderToIndices(IList<Tuple<int, int>> indices);
     29    void ShuffleToIndices(IList<System.Tuple<int, int>> indices);
    2930    void ReplaceIndicesByAverageValue(IDictionary<int, IList<int>> cells);
    3031    void ReplaceIndicesByLinearInterpolationOfNeighbours(IDictionary<int, IList<int>> cells);
Note: See TracChangeset for help on using the changeset viewer.