Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GradientBoostedTreesModelView.cs @ 15127

Last change on this file since 15127 was 15127, checked in by gkronber, 7 years ago

#2690: merged r14345, r14346, r14368 from trunk to stable

File size: 2.7 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.Drawing;
23using HeuristicLab.MainForm;
24using HeuristicLab.Problems.DataAnalysis;
25using HeuristicLab.Problems.DataAnalysis.Views;
26
27namespace HeuristicLab.Algorithms.DataAnalysis.Views {
28  [View("Gradient boosted tree model")]
29  [Content(typeof(GradientBoostedTreesSolution), false)]
30  public partial class GradientBoostedTreesModelView : DataAnalysisSolutionEvaluationView {
31    public override Image ViewImage {
32      get { return HeuristicLab.Common.Resources.VSImageLibrary.Function; }
33    }
34
35    public new GradientBoostedTreesSolution Content {
36      get { return (GradientBoostedTreesSolution)base.Content; }
37      set { base.Content = value; }
38    }
39
40    protected override void SetEnabledStateOfControls() {
41      base.SetEnabledStateOfControls();
42      listBox.Enabled = Content != null;
43      viewHost.Enabled = Content != null;
44    }
45
46    public GradientBoostedTreesModelView()
47      : base() {
48      InitializeComponent();
49    }
50
51    protected override void OnContentChanged() {
52      base.OnContentChanged();
53      if (Content == null) {
54        viewHost.Content = null;
55        listBox.Items.Clear();
56      } else {
57        viewHost.Content = null;
58        listBox.Items.Clear();
59        foreach (var e in Content.Model.Models) {
60          listBox.Items.Add(e);
61        }
62      }
63    }
64
65    private void listBox_SelectedIndexChanged(object sender, System.EventArgs e) {
66      var model = listBox.SelectedItem;
67      if (model == null) viewHost.Content = null;
68      else {
69        var treeModel = model as RegressionTreeModel;
70        if (treeModel != null)
71          viewHost.Content = treeModel.CreateSymbolicRegressionSolution(Content.ProblemData);
72        else {
73          var regModel = model as IRegressionModel;
74          viewHost.Content = regModel;
75        }
76      }
77    }
78  }
79}
Note: See TracBrowser for help on using the repository browser.