Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14486 for trunk/sources


Ignore:
Timestamp:
12/13/16 12:30:39 (8 years ago)
Author:
gkronber
Message:

#2718: fixed residual line chart view

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
3 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r14483 r14486  
    245245    <Compile Include="Regression\RegressionFeatureCorrelationView.Designer.cs">
    246246      <DependentUpon>RegressionFeatureCorrelationView.cs</DependentUpon>
     247    </Compile>
     248    <Compile Include="Regression\RegressionSolutionLineChartViewBase.cs">
     249      <SubType>UserControl</SubType>
     250    </Compile>
     251    <Compile Include="Regression\RegressionSolutionLineChartViewBase.Designer.cs">
     252      <DependentUpon>RegressionSolutionLineChartViewBase.cs</DependentUpon>
    247253    </Compile>
    248254    <Compile Include="Regression\RegressionSolutionResidualsLineChartView.cs">
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.Designer.cs

    r14483 r14486  
    2020#endregion
    2121namespace HeuristicLab.Problems.DataAnalysis.Views {
    22   partial class RegressionSolutionResidualsLineChartView {
     22  partial class RegressionSolutionLineChartView {
    2323    /// <summary>
    2424    /// Required designer variable.
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs

    r14483 r14486  
    2727
    2828namespace HeuristicLab.Problems.DataAnalysis.Views {
    29   [View("Line Chart (residuals)")]
     29  [View("Line Chart")]
    3030  [Content(typeof(IRegressionSolution))]
    31   public partial class RegressionSolutionResidualsLineChartView : RegressionSolutionLineChartView, IDataAnalysisSolutionEvaluationView {
     31  public partial class RegressionSolutionLineChartView : RegressionSolutionLineChartViewBase {
    3232
    3333
    34     public RegressionSolutionResidualsLineChartView()
     34    public RegressionSolutionLineChartView()
    3535      : base() {
    3636      InitializeComponent();
    3737    }
    3838
    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();
    4642    }
    4743
    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();
    5547    }
    5648
    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();
    6452    }
    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 
    7753  }
    7854}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.Designer.cs

    r14485 r14486  
    2020#endregion
    2121namespace HeuristicLab.Problems.DataAnalysis.Views {
    22   partial class RegressionSolutionLineChartView {
     22  partial class RegressionSolutionLineChartViewBase {
    2323    /// <summary>
    2424    /// Required designer variable.
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartViewBase.cs

    r14485 r14486  
    3131  [View("Line Chart")]
    3232  [Content(typeof(IRegressionSolution))]
    33   public partial class RegressionSolutionLineChartView : DataAnalysisSolutionEvaluationView {
     33  public abstract partial class RegressionSolutionLineChartViewBase : DataAnalysisSolutionEvaluationView {
    3434    protected const string TARGETVARIABLE_SERIES_NAME = "Target Variable";
    3535    protected const string ESTIMATEDVALUES_TRAINING_SERIES_NAME = "Estimated Values (training)";
     
    4242    }
    4343
    44     public RegressionSolutionLineChartView()
     44    protected RegressionSolutionLineChartViewBase()
    4545      : base() {
    4646      InitializeComponent();
     
    5757    }
    5858
    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);
    7464
    7565    protected virtual void RedrawChart() {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualsLineChartView.cs

    r14483 r14486  
    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
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeSeriesPrognosis/TimeSeriesPrognosisLineChartView.cs

    r14422 r14486  
    4040    }
    4141
    42     protected override void GetTestSeries(out int[] x, out double[] y) {
     42    protected override void GetTrainingSeries(out int[] idx, out double[] y) {
     43      idx = Content.ProblemData.TrainingIndices.ToArray();
     44      y = Content.EstimatedTrainingValues.ToArray();
     45    }
     46
     47    protected override void GetTestSeries(out int[] idx, out double[] y) {
    4348      // treat the whole test partition as prognosis horizon
    44       x = Content.ProblemData.TestIndices.ToArray();
     49      idx = Content.ProblemData.TestIndices.ToArray();
    4550      y = Content.PrognosedTestValues.ToArray();
    4651    }
    4752
    48     protected override void GetAllValuesSeries(out int[] x, out double[] y) {
     53    protected override void GetAllValuesSeries(out int[] idx, out double[] y) {
    4954      // not supported
    50       x = new int[0];
     55      idx = new int[0];
    5156      y = new double[0];
    5257    }
Note: See TracChangeset for help on using the changeset viewer.