Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GradientBoostedTreesModelView.cs @ 15123

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

#2690 added missing files (related to r15105)

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