Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/27/13 17:09:42 (11 years ago)
Author:
mleitner
Message:

Implement GetMostCommonValue

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/PreprocessingDataStatisticInfo.cs

    r10166 r10167  
    22using System.Linq;
    33using HeuristicLab.DataPreprocessing.Interfaces;
    4 using System.Linq;
    54
    65namespace HeuristicLab.DataPreprocessing {
     
    8079    }
    8180
    82     public double GetMostCommonValue(int columnIndex) {
    83       double result = 0;
    84       for (int i = 0; i < preprocessingData.Rows; ++i) {
     81    public T GetMostCommonValue<T>(int columnIndex) {
     82       return preprocessingData.GetValues<T>(columnIndex)
     83                               .GroupBy( x => x )
     84                               .OrderByDescending( g => g.Count() )
     85                               .Select( g => g.Key )
     86                               .First();
     87    }
    8588
    86       }
    87       return result;
    88     }
    8989
    9090    public double GetStandardDeviation(int columnIndex) {
Note: See TracChangeset for help on using the changeset viewer.