source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionErrorCharacteristicsCurveView.cs @ 14390

Last change on this file since 14390 was 14390, checked in by gkronber, 5 years ago

#2697:

  • renaming of folder "Transformation" to "Converters" to distinguish between transformations for variables (from data preprocessing) and classes for transformation of trees.
  • renamed SymbolicDataAnalysisExpressionTreeSimplifier -> TreeSimplifier
  • Implemented a converter to create a linar model as a symbolic expression tree
File size: 2.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 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
21
22using System;
23using System.Collections.Generic;
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();
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)
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.VariablesUsedForPrediction;
56      foreach (var variable in usedVariables) {
57        problemData.InputVariables.SetItemCheckedState(
58          problemData.InputVariables.First(x => x.Value == variable), true);
59      }
60
61      var solution = LinearRegression.CreateLinearRegressionSolution(problemData, out rmse, out cvRmsError);
62      solution.Name = "Baseline (linear subset)";
63      return solution;
64    }
65
66
67    protected override IEnumerable<IRegressionSolution> CreateBaselineSolutions() {
68      foreach (var sol in base.CreateBaselineSolutions()) yield return sol;
69      yield return CreateLinearRegressionSolution();
70    }
71  }
72}
Note: See TracBrowser for help on using the repository browser.