Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13951 for stable


Ignore:
Timestamp:
06/29/16 14:02:03 (8 years ago)
Author:
mkommend
Message:

#2542: Merged r13439 and r13592 into stable.

Location:
stable
Files:
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.DataAnalysis.Views

  • stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GaussianProcessRegressionSolutionEstimatedValuesView.cs

    r13439 r13951  
    1919 */
    2020#endregion
    21 using System;
    2221using System.Linq;
    2322using System.Windows.Forms;
    2423using HeuristicLab.Data;
    25 using HeuristicLab.Data.Views;
    2624using HeuristicLab.MainForm;
    2725using HeuristicLab.Problems.DataAnalysis.Views;
     
    3129  [Content(typeof(GaussianProcessRegressionSolution), false)]
    3230  public partial class GaussianProcessRegressionSolutionEstimatedValuesView : RegressionSolutionEstimatedValuesView {
    33     private const string TARGETVARIABLE_SERIES_NAME = "Target Variable";
    34     private const string ESTIMATEDVALUES_SERIES_NAME = "Estimated Values (all)";
    35     private const string ESTIMATEDVALUES_TRAINING_SERIES_NAME = "Estimated Values (training)";
    36     private const string ESTIMATEDVALUES_TEST_SERIES_NAME = "Estimated Values (test)";
    3731    private const string ESTIMATEDVARIANCE_TRAINING_SERIES_NAME = "Estimated Variance (training)";
    3832    private const string ESTIMATEDVARIANCE_TEST_SERIES_NAME = "Estimated Variance (test)";
     
    4034    public new GaussianProcessRegressionSolution Content {
    4135      get { return (GaussianProcessRegressionSolution)base.Content; }
    42       set {
    43         base.Content = value;
    44       }
     36      set { base.Content = value; }
    4537    }
    4638
     
    5042    }
    5143
    52     #region events
    53     protected override void RegisterContentEvents() {
    54       base.RegisterContentEvents();
    55       Content.ModelChanged += new EventHandler(Content_ModelChanged);
    56       Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged);
     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;
    5770    }
    58 
    59     protected override void DeregisterContentEvents() {
    60       base.DeregisterContentEvents();
    61       Content.ModelChanged -= new EventHandler(Content_ModelChanged);
    62       Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged);
    63     }
    64 
    65     private void Content_ProblemDataChanged(object sender, EventArgs e) {
    66       OnContentChanged();
    67     }
    68 
    69     private void Content_ModelChanged(object sender, EventArgs e) {
    70       OnContentChanged();
    71     }
    72 
    73     protected override void OnContentChanged() {
    74       base.OnContentChanged();
    75       UpdateEstimatedValues();
    76     }
    77 
    78     private void UpdateEstimatedValues() {
    79       if (InvokeRequired) Invoke((Action)UpdateEstimatedValues);
    80       else {
    81         StringMatrix matrix = null;
    82         if (Content != null) {
    83           string[,] values = new string[Content.ProblemData.Dataset.Rows, 9];
    84 
    85           var trainingRows = Content.ProblemData.TrainingIndices;
    86           var testRows = Content.ProblemData.TestIndices;
    87 
    88           double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
    89           var estimated = Content.EstimatedValues.GetEnumerator();
    90           var estimated_training = Content.EstimatedTrainingValues.GetEnumerator();
    91           var estimated_test = Content.EstimatedTestValues.GetEnumerator();
    92           var estimated_var_training = Content.GetEstimatedVariance(trainingRows).GetEnumerator();
    93           var estimated_var_test = Content.GetEstimatedVariance(testRows).GetEnumerator();
    94 
    95           foreach (var row in Content.ProblemData.TrainingIndices) {
    96             estimated_training.MoveNext();
    97             estimated_var_training.MoveNext();
    98             values[row, 3] = estimated_training.Current.ToString();
    99             values[row, 7] = estimated_var_training.Current.ToString();
    100           }
    101 
    102           foreach (var row in Content.ProblemData.TestIndices) {
    103             estimated_test.MoveNext();
    104             estimated_var_test.MoveNext();
    105             values[row, 4] = estimated_test.Current.ToString();
    106             values[row, 8] = estimated_var_test.Current.ToString();
    107           }
    108 
    109           foreach (var row in Enumerable.Range(0, Content.ProblemData.Dataset.Rows)) {
    110             estimated.MoveNext();
    111             double est = estimated.Current;
    112             double res = Math.Abs(est - target[row]);
    113             values[row, 0] = row.ToString();
    114             values[row, 1] = target[row].ToString();
    115             values[row, 2] = est.ToString();
    116             values[row, 5] = Math.Abs(res).ToString();
    117             values[row, 6] = Math.Abs(res / est).ToString();
    118           }
    119 
    120           matrix = new StringMatrix(values);
    121           matrix.ColumnNames = new string[] { "Id", TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME, ESTIMATEDVALUES_TRAINING_SERIES_NAME, ESTIMATEDVALUES_TEST_SERIES_NAME, "Absolute Error (all)", "Relative Error (all)", ESTIMATEDVARIANCE_TRAINING_SERIES_NAME, ESTIMATEDVARIANCE_TEST_SERIES_NAME };
    122           matrix.SortableView = true;
    123         }
    124         matrixView.Content = matrix;
    125       }
    126     }
    127     #endregion
    12871  }
    12972}
  • stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/HeuristicLab.Algorithms.DataAnalysis.Views-3.4.csproj

    r13298 r13951  
    125125  </ItemGroup>
    126126  <ItemGroup>
     127    <Compile Include="GaussianProcessRegressionSolutionEstimatedValuesView.cs">
     128      <SubType>UserControl</SubType>
     129    </Compile>
     130    <Compile Include="GaussianProcessRegressionSolutionEstimatedValuesView.Designer.cs">
     131      <DependentUpon>GaussianProcessRegressionSolutionEstimatedValuesView.cs</DependentUpon>
     132    </Compile>
    127133    <Compile Include="MeanProdView.cs">
    128134      <SubType>UserControl</SubType>
  • stable/HeuristicLab.Problems.DataAnalysis.Views

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

    r12009 r13951  
    2525using HeuristicLab.Data.Views;
    2626using HeuristicLab.MainForm;
    27 using HeuristicLab.MainForm.WindowsForms;
    2827
    2928namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    6867    }
    6968
    70     private void Content_ProblemDataChanged(object sender, EventArgs e) {
     69    protected virtual void Content_ProblemDataChanged(object sender, EventArgs e) {
    7170      OnContentChanged();
    7271    }
    7372
    74     private void Content_ModelChanged(object sender, EventArgs e) {
     73    protected virtual void Content_ModelChanged(object sender, EventArgs e) {
    7574      OnContentChanged();
    7675    }
     
    8180    }
    8281
    83     private void UpdateEstimatedValues() {
     82    protected virtual StringMatrix CreateValueMatrix() {
     83      string[,] values = new string[Content.ProblemData.Dataset.Rows, 7];
     84
     85      double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
     86      var estimated = Content.EstimatedValues.GetEnumerator();
     87      var estimated_training = Content.EstimatedTrainingValues.GetEnumerator();
     88      var estimated_test = Content.EstimatedTestValues.GetEnumerator();
     89
     90      foreach (var row in Content.ProblemData.TrainingIndices) {
     91        estimated_training.MoveNext();
     92        values[row, 3] = estimated_training.Current.ToString();
     93      }
     94
     95      foreach (var row in Content.ProblemData.TestIndices) {
     96        estimated_test.MoveNext();
     97        values[row, 4] = estimated_test.Current.ToString();
     98      }
     99
     100      foreach (var row in Enumerable.Range(0, Content.ProblemData.Dataset.Rows)) {
     101        estimated.MoveNext();
     102        double est = estimated.Current;
     103        double res = Math.Abs(est - target[row]);
     104        values[row, 0] = row.ToString();
     105        values[row, 1] = target[row].ToString();
     106        values[row, 2] = est.ToString();
     107        values[row, 5] = Math.Abs(res).ToString();
     108        values[row, 6] = Math.Abs(res / target[row]).ToString();
     109      }
     110
     111      var matrix = new StringMatrix(values);
     112      matrix.ColumnNames = new string[] { "Id", TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME, ESTIMATEDVALUES_TRAINING_SERIES_NAME, ESTIMATEDVALUES_TEST_SERIES_NAME, "Absolute Error (all)", "Relative Error (all)" };
     113      matrix.SortableView = true;
     114      return matrix;
     115    }
     116
     117    protected virtual void UpdateEstimatedValues() {
    84118      if (InvokeRequired) Invoke((Action)UpdateEstimatedValues);
    85119      else {
    86120        StringMatrix matrix = null;
    87121        if (Content != null) {
    88           string[,] values = new string[Content.ProblemData.Dataset.Rows, 7];
    89 
    90           double[] target = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.TargetVariable).ToArray();
    91           var estimated = Content.EstimatedValues.GetEnumerator();
    92           var estimated_training = Content.EstimatedTrainingValues.GetEnumerator();
    93           var estimated_test = Content.EstimatedTestValues.GetEnumerator();
    94 
    95           foreach (var row in Content.ProblemData.TrainingIndices) {
    96             estimated_training.MoveNext();
    97             values[row, 3] = estimated_training.Current.ToString();
    98           }
    99 
    100           foreach (var row in Content.ProblemData.TestIndices) {
    101             estimated_test.MoveNext();
    102             values[row, 4] = estimated_test.Current.ToString();
    103           }
    104 
    105           foreach (var row in Enumerable.Range(0, Content.ProblemData.Dataset.Rows)) {
    106             estimated.MoveNext();
    107             double est = estimated.Current;
    108             double res = Math.Abs(est - target[row]);
    109             values[row, 0] = row.ToString();
    110             values[row, 1] = target[row].ToString();
    111             values[row, 2] = est.ToString();
    112             values[row, 5] = Math.Abs(res).ToString();
    113             values[row, 6] = Math.Abs(res / target[row]).ToString();
    114           }
    115 
    116           matrix = new StringMatrix(values);
    117           matrix.ColumnNames = new string[] { "Id", TARGETVARIABLE_SERIES_NAME, ESTIMATEDVALUES_SERIES_NAME, ESTIMATEDVALUES_TRAINING_SERIES_NAME, ESTIMATEDVALUES_TEST_SERIES_NAME, "Absolute Error (all)", "Relative Error (all)" };
    118           matrix.SortableView = true;
     122          matrix = CreateValueMatrix();
    119123        }
    120124        matrixView.Content = matrix;
Note: See TracChangeset for help on using the changeset viewer.