- Timestamp:
- 12/12/16 11:17:07 (8 years ago)
- Location:
- branches/DataPreprocessing Enhancements
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs
r14459 r14474 62 62 } else { 63 63 dt.VisualProperties.Title = variableName; 64 //var valuesPerClass = row.Values.Zip(Classification, (value, @class) => new { value, @class }) 65 // .GroupBy(x => x.@class) 66 // .ToDictionary(x => x.Key, x => x.Select(v => v.value)); 67 var valuesPerClass = row.Values.Select((i, index) => new { i, j = Classification.ToList()[index] }) 68 .GroupBy((x) => x.j) 69 .ToDictionary(x => x.Key, x => x.Select(v => v.i) 70 .ToList()); 64 var valuesPerClass = row.Values.Zip(Classification, (value, @class) => new { value, @class }) 65 .GroupBy(x => x.@class) 66 .ToDictionary(x => x.Key, x => x.Select(v => v.value)); 71 67 foreach (var entry in valuesPerClass) { 72 var classRow = new DataRow( entry.Key.ToString());68 var classRow = new DataRow(string.Format("{0} ({1})", classifierComboBox.SelectedItem, entry.Key)); 73 69 classRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram; 74 70 classRow.Values.AddRange(entry.Value); -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.cs
r14472 r14474 71 71 comboBoxGroup.SelectedIndex = 0; 72 72 UpdateScatterPlot(); 73 if (scatterPlotControl.Content != null)74 foreach (var row in scatterPlotControl.Content.Rows)75 row.VisualProperties.PointSize = 6;76 73 } 77 74 } -
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/ScatterPlotContent.cs
r14472 r14474 25 25 using HeuristicLab.Analysis; 26 26 using HeuristicLab.Common; 27 using HeuristicLab.Problems.DataAnalysis; 27 28 using HeuristicLab.Visualization.ChartControlsExtensions; 28 29 … … 38 39 } 39 40 40 public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY, string variableName Color= "-") {41 public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY, string variableNameGroup = "-") { 41 42 ScatterPlot scatterPlot = new ScatterPlot(); 42 43 … … 60 61 } catch (ArgumentOutOfRangeException) { } // missing values lead to NaNs 61 62 62 if (variableName Color == null || variableNameColor== "-") {63 if (variableNameGroup == null || variableNameGroup == "-") { 63 64 List<Point2D<double>> points = new List<Point2D<double>>(); 64 65 … … 68 69 } 69 70 70 ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points); 71 ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points) { 72 VisualProperties = { PointSize = 6 } 73 }; 71 74 scdr.VisualProperties.IsVisibleInLegend = false; 72 75 scatterPlot.Rows.Add(scdr); 73 76 74 77 } else { 75 var colorValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameColor)); 76 var data = xValues.Zip(yValues, (x, y) => new { x, y }).Zip(colorValues, (v, c) => new { v.x, v.y, c }).ToList(); 77 var gradients = ColorGradient.Colors; 78 int curGradient = 0; 79 int numColors = colorValues.Distinct().Count(); 80 foreach (var colorValue in colorValues.Distinct()) { 81 var values = data.Where(x => x.c == colorValue); 78 var groupValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameGroup)); 79 var data = xValues.Zip(yValues, (x, y) => new { x, y }).Zip(groupValues, (v, c) => new { v.x, v.y, c }).ToList(); 80 foreach (var groupValue in groupValues.Distinct()) { 81 var values = data.Where(x => x.c == groupValue); 82 82 var row = new ScatterPlotDataRow( 83 variableName X + " - " + variableNameY + " (" + colorValue + ")",83 variableNameGroup + " (" + groupValue + ")", 84 84 "", 85 values.Select(v => new Point2D<double>(v.x, v.y)) ,86 new ScatterPlotDataRowVisualProperties() { Color = gradients[curGradient] });87 curGradient += gradients.Count / numColors;85 values.Select(v => new Point2D<double>(v.x, v.y))) { 86 VisualProperties = { PointSize = 6 } 87 }; 88 88 scatterPlot.Rows.Add(row); 89 89 } … … 91 91 return scatterPlot; 92 92 } 93 94 public DataRow GetCorrelationRow(string variableNameX, string variableNameY) { 95 var xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX)); 96 var yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY)); 97 98 double k, d; 99 OnlineCalculatorError err; 100 OnlineLinearScalingParameterCalculator.Calculate(xValues, yValues, out k, out d, out err); 101 double p = OnlinePearsonsRCalculator.Calculate(xValues, yValues, out err); 102 103 var data = new double[xValues.Count]; 104 for (int i = 0; i < xValues.Count; i++) { 105 data[i]= k * i + d; 106 } 107 108 return new DataRow(string.Format("Correlation (R²={0})", p*p), "", data); 109 } 93 110 } 94 111 }
Note: See TracChangeset
for help on using the changeset viewer.