Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/18/17 11:17:19 (8 years ago)
Author:
mkommend
Message:

#2709: Refactored histogram view and content to support grouping by string and datetime variables.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/HistogramContent.cs

    r14459 r14579  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Drawing;
     
    3334      get { return HeuristicLab.Common.Resources.VSImageLibrary.Statistics; }
    3435    }
    35     private const int MAX_DISTINCT_VALUES_FOR_CLASSIFCATION = 20;
    3636
    37     public int ClassifierVariableIndex { get; set; }
     37    private const int MAX_DISTINCT_VALUES_FOR_GROUPING = 20;
     38
     39    public string GroupingVariableName { get; set; }
    3840
    3941    public int Bins { get; set; }
     
    5355    }
    5456
    55     public IEnumerable<string> GetVariableNamesForHistogramClassification() {
    56       List<string> doubleVariableNames = new List<string>();
     57    public IEnumerable<string> GetVariableNamesForGrouping() {
     58      var variableNames = new List<string>();
    5759
    58       //only return variable names from type double
    5960      for (int i = 0; i < PreprocessingData.Columns; ++i) {
    60         if (PreprocessingData.VariableHasType<double>(i)) {
    61           double distinctValueCount = PreprocessingData.GetValues<double>(i).GroupBy(x => x).Count();
    62           bool distinctValuesOk = distinctValueCount <= MAX_DISTINCT_VALUES_FOR_CLASSIFCATION;
    63           if (distinctValuesOk)
    64             doubleVariableNames.Add(PreprocessingData.GetVariableName(i));
    65         }
     61        int distinctValues = int.MaxValue;
     62        if (PreprocessingData.VariableHasType<double>(i))
     63          distinctValues = PreprocessingData.GetValues<double>(i).GroupBy(x => x).Count();
     64        else if (PreprocessingData.VariableHasType<string>(i))
     65          distinctValues = PreprocessingData.GetValues<string>(i).GroupBy(x => x).Count();
     66        else if (PreprocessingData.VariableHasType<DateTime>(i))
     67          distinctValues = PreprocessingData.GetValues<DateTime>(i).GroupBy(x => x).Count();
     68
     69        if (distinctValues <= MAX_DISTINCT_VALUES_FOR_GROUPING)
     70          variableNames.Add(PreprocessingData.GetVariableName(i));
    6671      }
    67       return doubleVariableNames;
     72      return variableNames;
    6873    }
    6974  }
Note: See TracChangeset for help on using the changeset viewer.