Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/05/17 20:06:42 (8 years ago)
Author:
gkronber
Message:

#2718: merged r14483 and r14486 from trunk to stable

Location:
stable
Files:
2 edited
6 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualsLineChartView.cs

    r14483 r14940  
    2727
    2828namespace HeuristicLab.Problems.DataAnalysis.Views {
    29   [View("Line Chart (residuals)")]
     29  [View("Residuals Line Chart")]
    3030  [Content(typeof(IRegressionSolution))]
    31   public partial class RegressionSolutionResidualsLineChartView : RegressionSolutionLineChartView, IDataAnalysisSolutionEvaluationView {
     31  public partial class RegressionSolutionResidualsLineChartView : RegressionSolutionLineChartViewBase, IDataAnalysisSolutionEvaluationView {
    3232
    3333
     
    3737    }
    3838
    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) {
    4146      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];
    4550      }
    4651    }
    4752
    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);
    5557    }
    5658
    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);
    6463    }
    6564
     
    7069
    7170    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      }
    7591    }
    7692
Note: See TracChangeset for help on using the changeset viewer.