- Timestamp:
- 12/13/16 12:30:39 (8 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression
- Files:
-
- 1 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.Designer.cs
r14483 r14486 20 20 #endregion 21 21 namespace HeuristicLab.Problems.DataAnalysis.Views { 22 partial class RegressionSolution ResidualsLineChartView {22 partial class RegressionSolutionLineChartView { 23 23 /// <summary> 24 24 /// Required designer variable. -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs
r14483 r14486 27 27 28 28 namespace HeuristicLab.Problems.DataAnalysis.Views { 29 [View("Line Chart (residuals)")]29 [View("Line Chart")] 30 30 [Content(typeof(IRegressionSolution))] 31 public partial class RegressionSolution ResidualsLineChartView : RegressionSolutionLineChartView, IDataAnalysisSolutionEvaluationView{31 public partial class RegressionSolutionLineChartView : RegressionSolutionLineChartViewBase { 32 32 33 33 34 public RegressionSolution ResidualsLineChartView()34 public RegressionSolutionLineChartView() 35 35 : base() { 36 36 InitializeComponent(); 37 37 } 38 38 39 protected override void GetTrainingSeries(out int[] x, out double[] y) { 40 base.GetTrainingSeries(out x, out y); 41 var problemData = Content.ProblemData; 42 var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, x).ToArray(); 43 for (int i = 0; i < x.Length; i++) { 44 y[i] -= target[i]; 45 } 39 protected override void GetTrainingSeries(out int[] idx, out double[] y) { 40 idx = Content.ProblemData.TrainingIndices.ToArray(); 41 y = Content.EstimatedTrainingValues.ToArray(); 46 42 } 47 43 48 protected override void GetTestSeries(out int[] x, out double[] y) { 49 base.GetTestSeries(out x, out y); 50 var problemData = Content.ProblemData; 51 var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, x).ToArray(); 52 for (int i = 0; i < x.Length; i++) { 53 y[i] -= target[i]; 54 } 44 protected override void GetTestSeries(out int[] idx, out double[] y) { 45 idx = Content.ProblemData.TestIndices.ToArray(); 46 y = Content.EstimatedTestValues.ToArray(); 55 47 } 56 48 57 protected override void GetAllValuesSeries(out int[] x, out double[] y) { 58 base.GetAllValuesSeries(out x, out y); 59 var problemData = Content.ProblemData; 60 var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, x).ToArray(); 61 for (int i = 0; i < x.Length; i++) { 62 y[i] -= target[i]; 63 } 49 protected override void GetAllValuesSeries(out int[] idx, out double[] y) { 50 idx = Content.ProblemData.AllIndices.ToArray(); 51 y = Content.EstimatedValues.ToArray(); 64 52 } 65 66 protected override void RedrawChart() {67 base.RedrawChart();68 UpdateSeriesStyle();69 }70 71 private void UpdateSeriesStyle() {72 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_TRAINING_SERIES_NAME].YAxisType = AxisType.Secondary;73 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_TEST_SERIES_NAME].YAxisType = AxisType.Secondary;74 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_ALL_SERIES_NAME].YAxisType = AxisType.Secondary;75 }76 77 53 } 78 54 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.Designer.cs
r14485 r14486 20 20 #endregion 21 21 namespace HeuristicLab.Problems.DataAnalysis.Views { 22 partial class RegressionSolutionLineChartView {22 partial class RegressionSolutionLineChartViewBase { 23 23 /// <summary> 24 24 /// Required designer variable. -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.cs
r14485 r14486 31 31 [View("Line Chart")] 32 32 [Content(typeof(IRegressionSolution))] 33 public partial class RegressionSolutionLineChartView: DataAnalysisSolutionEvaluationView {33 public abstract partial class RegressionSolutionLineChartViewBase : DataAnalysisSolutionEvaluationView { 34 34 protected const string TARGETVARIABLE_SERIES_NAME = "Target Variable"; 35 35 protected const string ESTIMATEDVALUES_TRAINING_SERIES_NAME = "Estimated Values (training)"; … … 42 42 } 43 43 44 p ublic RegressionSolutionLineChartView()44 protected RegressionSolutionLineChartViewBase() 45 45 : base() { 46 46 InitializeComponent(); … … 57 57 } 58 58 59 protected virtual void GetTrainingSeries(out int[] x, out double[] y) { 60 x = Content.ProblemData.TrainingIndices.ToArray(); 61 y = Content.EstimatedTrainingValues.ToArray(); 62 } 63 64 protected virtual void GetTestSeries(out int[] x, out double[] y) { 65 x = Content.ProblemData.TestIndices.ToArray(); 66 y = Content.EstimatedTestValues.ToArray(); 67 } 68 69 protected virtual void GetAllValuesSeries(out int[] x, out double[] y) { 70 x = Enumerable.Range(0, Content.ProblemData.Dataset.Rows).Except(Content.ProblemData.TrainingIndices).Except(Content.ProblemData.TestIndices).ToArray(); 71 var tmp = Content.EstimatedValues.ToArray(); 72 y = x.Select(index => tmp[index]).ToArray(); 73 } 59 protected abstract void GetTrainingSeries(out int[] idx, out double[] y); 60 61 protected abstract void GetTestSeries(out int[] x, out double[] y); 62 63 protected abstract void GetAllValuesSeries(out int[] x, out double[] y); 74 64 75 65 protected virtual void RedrawChart() { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualsLineChartView.cs
r14483 r14486 27 27 28 28 namespace HeuristicLab.Problems.DataAnalysis.Views { 29 [View(" Line Chart (residuals)")]29 [View("Residuals Line Chart")] 30 30 [Content(typeof(IRegressionSolution))] 31 public partial class RegressionSolutionResidualsLineChartView : RegressionSolutionLineChartView , IDataAnalysisSolutionEvaluationView {31 public partial class RegressionSolutionResidualsLineChartView : RegressionSolutionLineChartViewBase, IDataAnalysisSolutionEvaluationView { 32 32 33 33 … … 37 37 } 38 38 39 protected override void GetTrainingSeries(out int[] x, out double[] y) { 40 base.GetTrainingSeries(out x, out y); 39 protected override void GetTrainingSeries(out int[] idx, out double[] y) { 40 idx = Content.ProblemData.TrainingIndices.ToArray(); 41 y = Content.EstimatedTrainingValues.ToArray(); 42 CalcResiduals(idx, y); 43 } 44 45 private void CalcResiduals(int[] idx, double[] x) { 41 46 var problemData = Content.ProblemData; 42 var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, x).ToArray();43 for (int i = 0; i < x.Length; i++) {44 y[i] -= target[i];47 var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, idx).ToArray(); 48 for (int i = 0; i < idx.Length; i++) { 49 x[i] -= target[i]; 45 50 } 46 51 } 47 52 48 protected override void GetTestSeries(out int[] x, out double[] y) { 49 base.GetTestSeries(out x, out y); 50 var problemData = Content.ProblemData; 51 var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, x).ToArray(); 52 for (int i = 0; i < x.Length; i++) { 53 y[i] -= target[i]; 54 } 53 protected override void GetTestSeries(out int[] idx, out double[] y) { 54 idx = Content.ProblemData.TestIndices.ToArray(); 55 y = Content.EstimatedTestValues.ToArray(); 56 CalcResiduals(idx, y); 55 57 } 56 58 57 protected override void GetAllValuesSeries(out int[] x, out double[] y) { 58 base.GetAllValuesSeries(out x, out y); 59 var problemData = Content.ProblemData; 60 var target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, x).ToArray(); 61 for (int i = 0; i < x.Length; i++) { 62 y[i] -= target[i]; 63 } 59 protected override void GetAllValuesSeries(out int[] idx, out double[] y) { 60 idx = Content.ProblemData.AllIndices.ToArray(); 61 y = Content.EstimatedValues.ToArray(); 62 CalcResiduals(idx, y); 64 63 } 65 64 … … 70 69 71 70 private void UpdateSeriesStyle() { 72 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_TRAINING_SERIES_NAME].YAxisType = AxisType.Secondary; 73 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_TEST_SERIES_NAME].YAxisType = AxisType.Secondary; 74 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_ALL_SERIES_NAME].YAxisType = AxisType.Secondary; 71 if (InvokeRequired) Invoke((Action)UpdateSeriesStyle); 72 else { 73 if (Content == null) return; 74 double[] res; 75 int[] idx; 76 GetTrainingSeries(out idx, out res); 77 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_TRAINING_SERIES_NAME].YAxisType = AxisType.Secondary; 78 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_TRAINING_SERIES_NAME].ChartType = SeriesChartType.RangeColumn; 79 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_TRAINING_SERIES_NAME].Points.DataBindXY(idx, res.Select(_ => 0.0).ToArray(), res); 80 81 GetTestSeries(out idx, out res); 82 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_TEST_SERIES_NAME].YAxisType = AxisType.Secondary; 83 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_TEST_SERIES_NAME].ChartType = SeriesChartType.RangeColumn; 84 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_TEST_SERIES_NAME].Points.DataBindXY(idx, res.Select(_ => 0.0).ToArray(), res); 85 86 GetAllValuesSeries(out idx, out res); 87 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_ALL_SERIES_NAME].YAxisType = AxisType.Secondary; 88 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_ALL_SERIES_NAME].ChartType = SeriesChartType.RangeColumn; 89 base.chart.Series[RegressionSolutionLineChartView.ESTIMATEDVALUES_ALL_SERIES_NAME].Points.DataBindXY(idx, res.Select(_ => 0.0).ToArray(), res); 90 } 75 91 } 76 92
Note: See TracChangeset
for help on using the changeset viewer.