Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs @ 14035

Last change on this file since 14035 was 13062, checked in by gkronber, 9 years ago

#2452: merged r13002:13004 from trunk to stable

File size: 3.0 KB
RevLine 
[6642]1#region License Information
2/* HeuristicLab
[12009]3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[6642]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
21
22using System;
[13062]23using System.Collections.Generic;
[6642]24using System.Linq;
25using HeuristicLab.Algorithms.DataAnalysis;
26using HeuristicLab.MainForm;
27using HeuristicLab.Problems.DataAnalysis.Views;
28
29namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
30  [View("Error Characteristics Curve")]
31  [Content(typeof(ISymbolicRegressionSolution))]
32  public partial class SymbolicRegressionSolutionErrorCharacteristicsCurveView : RegressionSolutionErrorCharacteristicsCurveView {
33    public SymbolicRegressionSolutionErrorCharacteristicsCurveView() {
34      InitializeComponent();
35    }
36
37    public new ISymbolicRegressionSolution Content {
38      get { return (ISymbolicRegressionSolution)base.Content; }
39      set { base.Content = value; }
40    }
41
42    private IRegressionSolution CreateLinearRegressionSolution() {
43      if (Content == null) throw new InvalidOperationException();
44      double rmse, cvRmsError;
45      var problemData = (IRegressionProblemData)ProblemData.Clone();
[13062]46      if (!problemData.TrainingIndices.Any()) return null; // don't create an LR model if the problem does not have a training set (e.g. loaded into an existing model)
[6642]47
48      //clear checked inputVariables
49      foreach (var inputVariable in problemData.InputVariables.CheckedItems) {
50        problemData.InputVariables.SetItemCheckedState(inputVariable.Value, false);
51      }
52
53      //check inputVariables used in the symbolic regression model
54      var usedVariables =
55        Content.Model.SymbolicExpressionTree.IterateNodesPostfix().OfType<VariableTreeNode>().Select(
56          node => node.VariableName).Distinct();
57      foreach (var variable in usedVariables) {
58        problemData.InputVariables.SetItemCheckedState(
[8100]59          problemData.InputVariables.First(x => x.Value == variable), true);
[6642]60      }
61
62      var solution = LinearRegression.CreateLinearRegressionSolution(problemData, out rmse, out cvRmsError);
[13062]63      solution.Name = "Baseline (linear subset)";
[6642]64      return solution;
65    }
66
67
[13062]68    protected override IEnumerable<IRegressionSolution> CreateBaselineSolutions() {
69      foreach (var sol in base.CreateBaselineSolutions()) yield return sol;
70      yield return CreateLinearRegressionSolution();
[6642]71    }
72  }
73}
Note: See TracBrowser for help on using the repository browser.