Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/14/17 10:29:51 (7 years ago)
Author:
pfleck
Message:

#2709 merged to stable

Location:
stable
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.DataPreprocessing

    • Property svn:mergeinfo set to (toggle deleted branches)
      /branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessingmergedeligible
      /branches/crossvalidation-2434/HeuristicLab.DataPreprocessingmergedeligible
      /trunk/sources/HeuristicLab.DataPreprocessingmergedeligible
      /branches/1721-RandomForestPersistence/HeuristicLab.DataPreprocessing10321-10322
      /branches/Algorithms.GradientDescent/HeuristicLab.DataPreprocessing5516-5520
      /branches/Benchmarking/sources/HeuristicLab.DataPreprocessing6917-7005
      /branches/CloningRefactoring/HeuristicLab.DataPreprocessing4656-4721
      /branches/CodeEditor/HeuristicLab.DataPreprocessing11700-11806
      /branches/DataAnalysis Refactoring/HeuristicLab.DataPreprocessing5471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.DataPreprocessing5815-6180
      /branches/DataAnalysis/HeuristicLab.DataPreprocessing4458-4459,​4462,​4464
      /branches/DataPreprocessing/HeuristicLab.DataPreprocessing10085-11101
      /branches/GP.Grammar.Editor/HeuristicLab.DataPreprocessing6284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.DataPreprocessing5060
      /branches/HLScript/HeuristicLab.DataPreprocessing10331-10358
      /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.DataPreprocessing11570-12508
      /branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.DataPreprocessing6123-9799
      /branches/HeuristicLab.Problems.Orienteering/HeuristicLab.DataPreprocessing11130-12721
      /branches/HiveStatistics/sources/HeuristicLab.DataPreprocessing12440-12877
      /branches/LogResidualEvaluator/HeuristicLab.DataPreprocessing10202-10483
      /branches/NET40/sources/HeuristicLab.DataPreprocessing5138-5162
      /branches/NSGA-II Changes/HeuristicLab.DataPreprocessing12033-12122
      /branches/ParallelEngine/HeuristicLab.DataPreprocessing5175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.DataPreprocessing7568-7810
      /branches/QAPAlgorithms/HeuristicLab.DataPreprocessing6350-6627
      /branches/Restructure trunk solution/HeuristicLab.DataPreprocessing6828
      /branches/RuntimeOptimizer/HeuristicLab.DataPreprocessing8943-9078
      /branches/ScatterSearch (trunk integration)/HeuristicLab.DataPreprocessing7787-8333
      /branches/SlaveShutdown/HeuristicLab.DataPreprocessing8944-8956
      /branches/SpectralKernelForGaussianProcesses/HeuristicLab.DataPreprocessing10204-10479
      /branches/SuccessProgressAnalysis/HeuristicLab.DataPreprocessing5370-5682
      /branches/Trunk/HeuristicLab.DataPreprocessing6829-6865
      /branches/UnloadJobs/HeuristicLab.DataPreprocessing9168-9215
      /branches/VNS/HeuristicLab.DataPreprocessing5594-5752
      /branches/histogram/HeuristicLab.DataPreprocessing5959-6341
      /branches/symbreg-factors-2650/HeuristicLab.DataPreprocessing14232-14825
      /trunk/sources/HeuristicLab.Problems.TestFunctions.MultiObjective/HeuristicLab.DataPreprocessing14175
  • stable/HeuristicLab.DataPreprocessing/3.4

  • stable/HeuristicLab.DataPreprocessing/3.4/Content/PreprocessingChartContent.cs

    r14963 r15242  
    2323using System.Collections.Generic;
    2424using System.Drawing;
     25using System.Linq;
    2526using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
     28using HeuristicLab.Common.Resources;
    2729using HeuristicLab.Core;
    2830using HeuristicLab.Data;
     
    3032namespace HeuristicLab.DataPreprocessing {
    3133  [Item("PreprocessingChart", "Represents a preprocessing chart.")]
    32   public class PreprocessingChartContent : Item, IViewChartShortcut {
    33     public static new Image StaticItemImage {
    34       get { return HeuristicLab.Common.Resources.VSImageLibrary.PieChart; }
     34  public class PreprocessingChartContent : Item, IViewShortcut {
     35    public enum LegendOrder {
     36      Alphabetically,
     37      Appearance
    3538    }
    3639
    37     private bool allInOneMode = true;
    38     public bool AllInOneMode {
    39       get { return this.allInOneMode; }
    40       set { this.allInOneMode = value; }
     40    public static new Image StaticItemImage {
     41      get { return VSImageLibrary.PieChart; }
    4142    }
    4243
    4344    private ICheckedItemList<StringValue> variableItemList = null;
    4445    public ICheckedItemList<StringValue> VariableItemList {
    45       get { return this.variableItemList; }
    46       set { this.variableItemList = value; }
     46      get {
     47        if (variableItemList == null)
     48          variableItemList = CreateVariableItemList(PreprocessingData);
     49        return this.variableItemList;
     50      }
    4751    }
    4852
    4953    public IFilteredPreprocessingData PreprocessingData { get; private set; }
     54    public event DataPreprocessingChangedEventHandler Changed {
     55      add { PreprocessingData.Changed += value; }
     56      remove { PreprocessingData.Changed -= value; }
     57    }
    5058
    5159    public PreprocessingChartContent(IFilteredPreprocessingData preprocessingData) {
     
    5563    public PreprocessingChartContent(PreprocessingChartContent content, Cloner cloner)
    5664      : base(content, cloner) {
    57       this.allInOneMode = content.allInOneMode;
    5865      this.PreprocessingData = content.PreprocessingData;
    5966      this.variableItemList = cloner.Clone<ICheckedItemList<StringValue>>(variableItemList);
     
    6370    }
    6471
     72    public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
     73      return CreateDataRow(PreprocessingData, variableName, chartType);
     74    }
    6575
    66     public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
    67       IList<double> values = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableName));
     76    public static DataRow CreateDataRow(IFilteredPreprocessingData preprocessingData, string variableName, DataRowVisualProperties.DataRowChartType chartType) {
     77      IList<double> values = preprocessingData.GetValues<double>(preprocessingData.GetColumnIndex(variableName));
    6878      DataRow row = new DataRow(variableName, "", values);
    6979      row.VisualProperties.ChartType = chartType;
     
    7181    }
    7282
    73     public List<DataRow> CreateAllDataRows(DataRowVisualProperties.DataRowChartType chartType) {
    74       List<DataRow> dataRows = new List<DataRow>();
    75       foreach (var name in PreprocessingData.GetDoubleVariableNames())
    76         dataRows.Add(CreateDataRow(name, chartType));
    77       return dataRows;
    78     }
    79 
    80     public DataRow CreateSelectedDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
    81 
    82       IDictionary<int, IList<int>> selection = PreprocessingData.Selection;
    83       int variableIndex = PreprocessingData.GetColumnIndex(variableName);
    84 
    85       if (selection.Keys.Contains(variableIndex)) {
    86         List<int> selectedIndices = new List<int>(selection[variableIndex]);
    87         //need selection with more than 1 value
    88         if (selectedIndices.Count < 2)
    89           return null;
    90 
    91         selectedIndices.Sort();
    92         int start = selectedIndices[0];
    93         int end = selectedIndices[selectedIndices.Count - 1];
    94 
    95         DataRow rowSelect = CreateDataRowRange(variableName, start, end, chartType);
    96         return rowSelect;
    97       } else
    98         return null;
    99     }
    100 
    101     public DataRow CreateDataRowRange(string variableName, int start, int end, DataRowVisualProperties.DataRowChartType chartType) {
    102       IList<double> values = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableName));
    103       IList<double> valuesRange = new List<double>();
    104       for (int i = 0; i < values.Count; i++) {
    105         if (i >= start && i <= end)
    106           valuesRange.Add(values[i]);
    107         else
    108           valuesRange.Add(Double.NaN);
    109       }
    110 
    111       DataRow row = new DataRow(variableName, "", valuesRange);
    112       row.VisualProperties.ChartType = chartType;
    113       return row;
    114     }
    115 
    116     public List<DataRow> CreateAllSelectedDataRows(DataRowVisualProperties.DataRowChartType chartType) {
    117       List<DataRow> dataRows = new List<DataRow>();
    118       foreach (var name in PreprocessingData.GetDoubleVariableNames()) {
    119         DataRow row = CreateSelectedDataRow(name, chartType);
    120         if (row != null)
    121           dataRows.Add(row);
    122       }
    123       return dataRows;
    124     }
    125 
    126 
    127     public ICheckedItemList<StringValue> CreateVariableItemList(IList<string> checkedItems = null) {
    128       if (checkedItems == null) checkedItems = new string[0];
     83    private static ICheckedItemList<StringValue> CreateVariableItemList(IPreprocessingData preprocessingData) {
    12984      ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>();
    130       foreach (string name in PreprocessingData.GetDoubleVariableNames()) {
     85      foreach (string name in preprocessingData.GetDoubleVariableNames()) {
    13186        var n = new StringValue(name);
    132         itemList.Add(n, checkedItems.Contains(name));
     87        bool isInputTarget = preprocessingData.InputVariables.Contains(name) || preprocessingData.TargetVariable == name;
     88        itemList.Add(n, isInputTarget);
    13389      }
    13490      return new ReadOnlyCheckedItemList<StringValue>(itemList);
    13591    }
    13692
    137     public event DataPreprocessingChangedEventHandler Changed {
    138       add { PreprocessingData.Changed += value; }
    139       remove { PreprocessingData.Changed -= value; }
     93    public static IEnumerable<string> GetVariableNamesForGrouping(IPreprocessingData preprocessingData, int maxDistinctValues = 20) {
     94      var variableNames = new List<string>();
     95
     96      for (int i = 0; i < preprocessingData.Columns; ++i) {
     97        int distinctValues = Int32.MaxValue;
     98        if (preprocessingData.VariableHasType<double>(i))
     99          distinctValues = preprocessingData.GetValues<double>(i).GroupBy(x => x).Count();
     100        else if (preprocessingData.VariableHasType<string>(i))
     101          distinctValues = preprocessingData.GetValues<string>(i).GroupBy(x => x).Count();
     102        else if (preprocessingData.VariableHasType<DateTime>(i))
     103          distinctValues = preprocessingData.GetValues<DateTime>(i).GroupBy(x => x).Count();
     104
     105        if (distinctValues <= maxDistinctValues)
     106          variableNames.Add(preprocessingData.GetVariableName(i));
     107      }
     108      return variableNames;
    140109    }
    141 
    142110  }
    143111}
Note: See TracChangeset for help on using the changeset viewer.