Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/12/16 17:05:37 (9 years ago)
Author:
pfleck
Message:

#2559

  • Adapted import and export for preprocessing.
  • Added MenuItem to be able to open Preprocessing without creating a DataAnalysisProblem before.
  • Added coloring in ScatterPlot.
  • Removed IPreprocessingContext interface.
  • Reformatted code:
    • Added missing copyright headers.
    • Corrected namespaces.
    • Deleted unnecessary usings.
    • Applied correct formatting.
Location:
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/CorrelationMatrixContent.cs

    r12012 r13502  
    2121
    2222using System.Drawing;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    3233    }
    3334
    34     private IPreprocessingContext Context { get; set; }
     35    private PreprocessingContext Context { get; set; }
    3536    private ITransactionalPreprocessingData PreprocessingData {
    3637      get { return Context.Data; }
     
    3940    public DataAnalysisProblemData ProblemData {
    4041      get {
    41         var creator = new ProblemDataCreator(Context);
    42         return (DataAnalysisProblemData)creator.CreateProblemData();
     42        // ToDo: avoid iterating
     43        return Context.ExportPossibilities.Select(p => p.Value()).OfType<DataAnalysisProblemData>().Single();
     44        //var creator = new ProblemDataCreator(Context);
     45        //return (DataAnalysisProblemData)creator.CreateProblemData();
    4346      }
    4447    }
    4548
    46     public CorrelationMatrixContent(IPreprocessingContext context) {
     49    public CorrelationMatrixContent(PreprocessingContext context) {
    4750      Context = context;
    4851    }
     
    5053    public CorrelationMatrixContent(CorrelationMatrixContent original, Cloner cloner)
    5154      : base(original, cloner) {
    52         Context = original.Context;
     55      Context = original.Context;
    5356    }
    5457
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/Filter/IFilter.cs

    r10667 r13502  
    1 using HeuristicLab.Core;
    2 using System;
    3 using System.Collections.Generic;
    4 using System.Linq;
    5 using System.Text;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
    621
    7 namespace HeuristicLab.DataPreprocessing.Filter
    8 {
    9   public interface IFilter : IConstraint
    10   {
     22using HeuristicLab.Core;
     23
     24namespace HeuristicLab.DataPreprocessing.Filter {
     25  public interface IFilter : IConstraint {
    1126    new bool[] Check();
    1227    new bool[] Check(out string errorMessage);
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/FilterLogic.cs

    r12012 r13502  
    2424using System.Linq;
    2525using HeuristicLab.DataPreprocessing.Filter;
    26 using HeuristicLab.DataPreprocessing.Interfaces;
     26
    2727namespace HeuristicLab.DataPreprocessing {
    2828  public class FilterLogic : IFilterLogic {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/FilteredPreprocessingData.cs

    r13252 r13502  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Collections.Generic;
    324using HeuristicLab.Common;
    425using HeuristicLab.Core;
    526using HeuristicLab.Data;
    6 using HeuristicLab.DataPreprocessing.Interfaces;
    727using HeuristicLab.Problems.DataAnalysis;
    828
    9 namespace HeuristicLab.DataPreprocessing.Implementations {
     29namespace HeuristicLab.DataPreprocessing {
    1030  public class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData {
    1131    private readonly ITransactionalPreprocessingData originalData;
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/HistogramContent.cs

    r12676 r13502  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.DataPreprocessing.Interfaces;
    2827
    2928namespace HeuristicLab.DataPreprocessing {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/LineChartContent.cs

    r12012 r13502  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.DataPreprocessing.Interfaces;
    2625
    2726namespace HeuristicLab.DataPreprocessing {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingChartContent.cs

    r12676 r13502  
    2828using HeuristicLab.Core;
    2929using HeuristicLab.Data;
    30 using HeuristicLab.DataPreprocessing.Interfaces;
    3130
    3231namespace HeuristicLab.DataPreprocessing {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingData.cs

    r13427 r13502  
    9494      selection = new Dictionary<int, IList<int>>();
    9595
     96      Import(problemData);
     97
     98      RegisterEventHandler();
     99    }
     100
     101    public void Import(IDataAnalysisProblemData problemData) {
    96102      Dataset dataset = (Dataset)problemData.Dataset;
    97103      variableNames = new List<string>(problemData.Dataset.VariableNames);
     
    114120      TrainingPartition = new IntRange(problemData.TrainingPartition.Start, problemData.TrainingPartition.End);
    115121      TestPartition = new IntRange(problemData.TestPartition.Start, problemData.TestPartition.End);
    116 
    117       RegisterEventHandler();
    118122    }
    119123
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingDataTable.cs

    r11114 r13502  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using HeuristicLab.Analysis;
    324using HeuristicLab.Common;
    425using HeuristicLab.Core;
    526
    6 namespace HeuristicLab.DataPreprocessing.Implementations {
     27namespace HeuristicLab.DataPreprocessing {
    728  [Item("PreprossingDataTable", "A table of data values.")]
    829  public class PreprocessingDataTable : DataTable {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/ScatterPlotContent.cs

    r12012 r13502  
    2222using System.Collections.Generic;
    2323using System.Drawing;
     24using System.Linq;
    2425using HeuristicLab.Analysis;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    27 using HeuristicLab.DataPreprocessing.Interfaces;
    2828
    2929namespace HeuristicLab.DataPreprocessing {
     
    3434    public string SelectedXVariable { get; set; }
    3535    public string SelectedYVariable { get; set; }
     36    public string SelectedColorVariable { get; set; }
    3637
    3738    public ScatterPlotContent(IFilteredPreprocessingData preprocessingData)
     
    4344      this.SelectedXVariable = content.SelectedXVariable;
    4445      this.SelectedYVariable = content.SelectedYVariable;
     46      this.SelectedColorVariable = content.SelectedColorVariable;
    4547    }
    4648
    47     public static new Image StaticItemImage
    48     {
     49    public static new Image StaticItemImage {
    4950      get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; }
    5051    }
     
    5455    }
    5556
    56     public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY) {
     57    public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY, string variableNameColor = "-") {
    5758      ScatterPlot scatterPlot = new ScatterPlot();
    5859
    5960      IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX));
    6061      IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY));
     62      if (variableNameColor == null || variableNameColor == "-") {
     63        List<Point2D<double>> points = new List<Point2D<double>>();
    6164
    62       List<Point2D<double>> points = new List<Point2D<double>>();
     65        for (int i = 0; i < xValues.Count; i++) {
     66          Point2D<double> point = new Point2D<double>(xValues[i], yValues[i]);
     67          points.Add(point);
     68        }
    6369
    64       for (int i = 0; i < xValues.Count; i++) {
    65         Point2D<double> point = new Point2D<double>(xValues[i], yValues[i]);
    66         points.Add(point);
     70        ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points);
     71        scatterPlot.Rows.Add(scdr);
     72
     73      } else {
     74        var colorValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameColor));
     75        var data = xValues.Zip(yValues, (x, y) => new { x, y }).Zip(colorValues, (v, c) => new { v.x, v.y, c }).ToList();
     76        var gradients = ColorGradient.Colors;
     77        int curGradient = 0;
     78        int numColors = colorValues.Distinct().Count();
     79        foreach (var colorValue in colorValues.Distinct()) {
     80          var values = data.Where(x => x.c == colorValue);
     81          var row = new ScatterPlotDataRow(
     82            variableNameX + " - " + variableNameY + " (" + colorValue + ")",
     83            "",
     84            values.Select(v => new Point2D<double>(v.x, v.y)),
     85            new ScatterPlotDataRowVisualProperties() { Color = gradients[curGradient] });
     86          curGradient += gradients.Count / numColors;
     87          scatterPlot.Rows.Add(row);
     88        }
    6789      }
    68 
    69       ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points);
    70       scatterPlot.Rows.Add(scdr);
    7190      return scatterPlot;
    7291    }
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/StatisticsContent.cs

    r12012 r13502  
    1919 */
    2020#endregion
     21
    2122using System.Drawing;
    2223using HeuristicLab.Common;
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/StatisticsLogic.cs

    r13051 r13502  
    2626
    2727namespace HeuristicLab.DataPreprocessing {
    28 
    2928  public class StatisticsLogic : IStatisticsLogic {
    3029
Note: See TracChangeset for help on using the changeset viewer.