Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GaussianProcessRegressionSolutionEstimatedValuesView.cs @ 13799

Last change on this file since 13799 was 13592, checked in by mkommend, 9 years ago

#2542: Refactored EstimatedValuesView for GaussianProcessRegressionSolution.

File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21using System.Linq;
22using System.Windows.Forms;
23using HeuristicLab.Data;
24using HeuristicLab.MainForm;
25using HeuristicLab.Problems.DataAnalysis.Views;
26
27namespace HeuristicLab.Algorithms.DataAnalysis.Views {
28  [View("Estimated Values")]
29  [Content(typeof(GaussianProcessRegressionSolution), false)]
30  public partial class GaussianProcessRegressionSolutionEstimatedValuesView : RegressionSolutionEstimatedValuesView {
31    private const string ESTIMATEDVARIANCE_TRAINING_SERIES_NAME = "Estimated Variance (training)";
32    private const string ESTIMATEDVARIANCE_TEST_SERIES_NAME = "Estimated Variance (test)";
33
34    public new GaussianProcessRegressionSolution Content {
35      get { return (GaussianProcessRegressionSolution)base.Content; }
36      set { base.Content = value; }
37    }
38
39    public GaussianProcessRegressionSolutionEstimatedValuesView()
40      : base() {
41      InitializeComponent();
42    }
43
44
45    protected override StringMatrix CreateValueMatrix() {
46      var matrix = base.CreateValueMatrix();
47
48      var columnNames = matrix.ColumnNames.Concat(new[] { ESTIMATEDVARIANCE_TRAINING_SERIES_NAME, ESTIMATEDVARIANCE_TEST_SERIES_NAME }).ToList();
49      ((IStringConvertibleMatrix)matrix).Columns += 2;
50      matrix.ColumnNames = columnNames;
51
52      var trainingRows = Content.ProblemData.TrainingIndices;
53      var testRows = Content.ProblemData.TestIndices;
54
55      var estimated_var_training = Content.GetEstimatedVariance(trainingRows).GetEnumerator();
56      var estimated_var_test = Content.GetEstimatedVariance(testRows).GetEnumerator();
57
58      foreach (var row in Content.ProblemData.TrainingIndices) {
59        estimated_var_training.MoveNext();
60        matrix[row, 7] = estimated_var_training.Current.ToString();
61      }
62
63      foreach (var row in Content.ProblemData.TestIndices) {
64        estimated_var_test.MoveNext();
65        matrix[row, 8] = estimated_var_test.Current.ToString();
66      }
67
68
69      return matrix;
70    }
71  }
72}
Note: See TracBrowser for help on using the repository browser.