- Timestamp:
- 07/14/17 10:29:51 (8 years ago)
- Location:
- stable
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15110,15119,15210
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing merged eligible /branches/crossvalidation-2434/HeuristicLab.DataPreprocessing merged eligible /trunk/sources/HeuristicLab.DataPreprocessing merged eligible /branches/1721-RandomForestPersistence/HeuristicLab.DataPreprocessing 10321-10322 /branches/Algorithms.GradientDescent/HeuristicLab.DataPreprocessing 5516-5520 /branches/Benchmarking/sources/HeuristicLab.DataPreprocessing 6917-7005 /branches/CloningRefactoring/HeuristicLab.DataPreprocessing 4656-4721 /branches/CodeEditor/HeuristicLab.DataPreprocessing 11700-11806 /branches/DataAnalysis Refactoring/HeuristicLab.DataPreprocessing 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.DataPreprocessing 5815-6180 /branches/DataAnalysis/HeuristicLab.DataPreprocessing 4458-4459,4462,4464 /branches/DataPreprocessing/HeuristicLab.DataPreprocessing 10085-11101 /branches/GP.Grammar.Editor/HeuristicLab.DataPreprocessing 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.DataPreprocessing 5060 /branches/HLScript/HeuristicLab.DataPreprocessing 10331-10358 /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.DataPreprocessing 11570-12508 /branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.DataPreprocessing 6123-9799 /branches/HeuristicLab.Problems.Orienteering/HeuristicLab.DataPreprocessing 11130-12721 /branches/HiveStatistics/sources/HeuristicLab.DataPreprocessing 12440-12877 /branches/LogResidualEvaluator/HeuristicLab.DataPreprocessing 10202-10483 /branches/NET40/sources/HeuristicLab.DataPreprocessing 5138-5162 /branches/NSGA-II Changes/HeuristicLab.DataPreprocessing 12033-12122 /branches/ParallelEngine/HeuristicLab.DataPreprocessing 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.DataPreprocessing 7568-7810 /branches/QAPAlgorithms/HeuristicLab.DataPreprocessing 6350-6627 /branches/Restructure trunk solution/HeuristicLab.DataPreprocessing 6828 /branches/RuntimeOptimizer/HeuristicLab.DataPreprocessing 8943-9078 /branches/ScatterSearch (trunk integration)/HeuristicLab.DataPreprocessing 7787-8333 /branches/SlaveShutdown/HeuristicLab.DataPreprocessing 8944-8956 /branches/SpectralKernelForGaussianProcesses/HeuristicLab.DataPreprocessing 10204-10479 /branches/SuccessProgressAnalysis/HeuristicLab.DataPreprocessing 5370-5682 /branches/Trunk/HeuristicLab.DataPreprocessing 6829-6865 /branches/UnloadJobs/HeuristicLab.DataPreprocessing 9168-9215 /branches/VNS/HeuristicLab.DataPreprocessing 5594-5752 /branches/histogram/HeuristicLab.DataPreprocessing 5959-6341 /branches/symbreg-factors-2650/HeuristicLab.DataPreprocessing 14232-14825 /trunk/sources/HeuristicLab.Problems.TestFunctions.MultiObjective/HeuristicLab.DataPreprocessing 14175
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
stable/HeuristicLab.DataPreprocessing/3.4
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing/3.4/Content/ScatterPlotContent.cs
r14186 r15242 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 using System.Drawing;24 24 using System.Linq; 25 25 using HeuristicLab.Analysis; 26 26 using HeuristicLab.Common; 27 using HeuristicLab. Core;27 using HeuristicLab.Visualization.ChartControlsExtensions; 28 28 29 29 namespace HeuristicLab.DataPreprocessing { 30 30 31 [Item("ScatterPlot", "Represents a scatter plot.")]32 public class ScatterPlotContent : PreprocessingChartContent {31 public abstract class ScatterPlotContent : PreprocessingChartContent { 32 public string GroupingVariable { get; set; } 33 33 34 public string SelectedXVariable { get; set; } 35 public string SelectedYVariable { get; set; } 36 public string SelectedColorVariable { get; set; } 37 38 public ScatterPlotContent(IFilteredPreprocessingData preprocessingData) 34 protected ScatterPlotContent(IFilteredPreprocessingData preprocessingData) 39 35 : base(preprocessingData) { 40 36 } 41 37 42 p ublicScatterPlotContent(ScatterPlotContent content, Cloner cloner)38 protected ScatterPlotContent(ScatterPlotContent content, Cloner cloner) 43 39 : base(content, cloner) { 44 this.SelectedXVariable = content.SelectedXVariable;45 this.SelectedYVariable = content.SelectedYVariable;46 this.SelectedColorVariable = content.SelectedColorVariable;47 40 } 48 41 49 public static new Image StaticItemImage { 50 get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; } 51 } 52 53 public override IDeepCloneable Clone(Cloner cloner) { 54 return new ScatterPlotContent(this, cloner); 55 } 56 57 public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY, string variableNameColor = "-") { 42 public static ScatterPlot CreateScatterPlot(IFilteredPreprocessingData preprocessingData, string variableNameX, string variableNameY, string variableNameGroup = "-", LegendOrder legendOrder = LegendOrder.Alphabetically) { 58 43 ScatterPlot scatterPlot = new ScatterPlot(); 59 44 60 IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX)); 61 IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY)); 62 if (variableNameColor == null || variableNameColor == "-") { 63 List<Point2D<double>> points = new List<Point2D<double>>(); 45 IList<double> xValues = preprocessingData.GetValues<double>(preprocessingData.GetColumnIndex(variableNameX)); 46 IList<double> yValues = preprocessingData.GetValues<double>(preprocessingData.GetColumnIndex(variableNameY)); 64 47 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 } 48 var points = xValues.Zip(yValues, (x, y) => new Point2D<double>(x, y)).ToList(); 49 var validPoints = points.Where(p => !double.IsNaN(p.X) && !double.IsNaN(p.Y) && !double.IsInfinity(p.X) && !double.IsInfinity(p.Y)).ToList(); 50 if (validPoints.Any()) { 51 try { 52 double axisMin, axisMax, axisInterval; 53 ChartUtil.CalculateOptimalAxisInterval(validPoints.Min(p => p.X), validPoints.Max(p => p.X), out axisMin, out axisMax, out axisInterval); 54 scatterPlot.VisualProperties.XAxisMinimumAuto = false; 55 scatterPlot.VisualProperties.XAxisMaximumAuto = false; 56 scatterPlot.VisualProperties.XAxisMinimumFixedValue = axisMin; 57 scatterPlot.VisualProperties.XAxisMaximumFixedValue = axisMax; 58 } catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 59 try { 60 double axisMin, axisMax, axisInterval; 61 ChartUtil.CalculateOptimalAxisInterval(validPoints.Min(p => p.Y), validPoints.Max(p => p.Y), out axisMin, out axisMax, out axisInterval); 62 scatterPlot.VisualProperties.YAxisMinimumAuto = false; 63 scatterPlot.VisualProperties.YAxisMaximumAuto = false; 64 scatterPlot.VisualProperties.YAxisMinimumFixedValue = axisMin; 65 scatterPlot.VisualProperties.YAxisMaximumFixedValue = axisMax; 66 } catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 67 } 69 68 70 ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points); 69 70 //No Grouping 71 if (string.IsNullOrEmpty(variableNameGroup) || variableNameGroup == "-") { 72 ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", validPoints); 73 scdr.VisualProperties.IsVisibleInLegend = false; 71 74 scatterPlot.Rows.Add(scdr); 75 return scatterPlot; 76 } 72 77 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 } 78 //Grouping 79 int groupVariableIndex = preprocessingData.GetColumnIndex(variableNameGroup); 80 var groupingValues = Enumerable.Empty<string>(); 81 82 if (preprocessingData.VariableHasType<double>(groupVariableIndex)) { 83 groupingValues = preprocessingData.GetValues<double>(groupVariableIndex).Select(x => x.ToString()); 84 } else if (preprocessingData.VariableHasType<string>(groupVariableIndex)) { 85 groupingValues = preprocessingData.GetValues<string>(groupVariableIndex); 86 } else if (preprocessingData.VariableHasType<DateTime>(groupVariableIndex)) { 87 groupingValues = preprocessingData.GetValues<DateTime>(groupVariableIndex).Select(x => x.ToString()); 88 } 89 var groups = groupingValues.Zip(validPoints, Tuple.Create).GroupBy(t => t.Item1, t => t.Item2); 90 91 if (legendOrder == LegendOrder.Alphabetically) 92 groups = groups.OrderBy(x => x.Key, new NaturalStringComparer()); 93 94 foreach (var group in groups) { 95 var scdr = new ScatterPlotDataRow { 96 Name = group.Key, 97 VisualProperties = { 98 IsVisibleInLegend = true, 99 PointSize = 6 100 } 101 }; 102 scdr.Points.AddRange(group); 103 scatterPlot.Rows.Add(scdr); 89 104 } 90 105 return scatterPlot;
Note: See TracChangeset
for help on using the changeset viewer.