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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using System.Text;
|
---|
26 | using HeuristicLab.Collections;
|
---|
27 | using HeuristicLab.Common;
|
---|
28 | using HeuristicLab.Core;
|
---|
29 | using HeuristicLab.Data;
|
---|
30 | using HeuristicLab.Parameters;
|
---|
31 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
32 | using HeuristicLab.Problems.DataAnalysis;
|
---|
33 | namespace HeuristicLab.DatastreamAnalysis {
|
---|
34 | [StorableClass]
|
---|
35 | [Item("Proxy Ensemble Model", "Represents a named and rated collection of models which acts as a model yet again.")]
|
---|
36 | [Creatable(CreatableAttribute.Categories.DataAnalysis)]
|
---|
37 | public class ProxyEnsembleModel : ParameterizedNamedItem, IProxyEnsembleModel {
|
---|
38 | protected const string ModelParameterName = "Model";
|
---|
39 | protected const string QualityThresholdParameterName = "QualityThreshold";
|
---|
40 | protected const string ConfidenceThresholdParameterName = "ConfidenceThreshold";
|
---|
41 |
|
---|
42 | #region parameter properties
|
---|
43 |
|
---|
44 | public IValueParameter<RegressionEnsembleModel> ModelParameter {
|
---|
45 | get { return (IValueParameter<RegressionEnsembleModel>) Parameters[ModelParameterName]; }
|
---|
46 | }
|
---|
47 |
|
---|
48 | public IValueParameter<DoubleRange> QualityThresholdParameter {
|
---|
49 | get { return (IValueParameter<DoubleRange>) Parameters[QualityThresholdParameterName]; }
|
---|
50 | }
|
---|
51 |
|
---|
52 | public IValueParameter<DoubleRange> ConfidenceThresholdParameter {
|
---|
53 | get { return (IValueParameter<DoubleRange>)Parameters[ConfidenceThresholdParameterName]; }
|
---|
54 | }
|
---|
55 |
|
---|
56 | public RegressionEnsembleModel Model {
|
---|
57 | get { return ModelParameter.Value; }
|
---|
58 | set {
|
---|
59 | if(value == null) throw new ArgumentNullException("Model", "The provided value for model is null.");
|
---|
60 | ModelParameter.Value = value;
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | public DoubleRange QualityThreshold {
|
---|
65 | get { return QualityThresholdParameter.Value; }
|
---|
66 | set { QualityThresholdParameter.Value = value; }
|
---|
67 | }
|
---|
68 |
|
---|
69 | public DoubleRange ConfidenceThreshold {
|
---|
70 | get { return ConfidenceThresholdParameter.Value; }
|
---|
71 | set { ConfidenceThresholdParameter.Value = value; }
|
---|
72 | }
|
---|
73 |
|
---|
74 | #endregion
|
---|
75 |
|
---|
76 | #region constructors, clone ...
|
---|
77 | [StorableConstructor]
|
---|
78 | protected ProxyEnsembleModel(bool deserializing) : base(deserializing) { }
|
---|
79 | protected ProxyEnsembleModel(ProxyEnsembleModel original, Cloner cloner) : base(original, cloner) {
|
---|
80 | RegisterParameterEvents();
|
---|
81 | }
|
---|
82 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
83 | return new ProxyEnsembleModel(this, cloner);
|
---|
84 | }
|
---|
85 | public ProxyEnsembleModel() : base() {
|
---|
86 | Parameters.Add(new ValueParameter<RegressionEnsembleModel>(ModelParameterName, "Collection of models.", null));
|
---|
87 | Parameters.Add(new FixedValueParameter<DoubleRange>(QualityThresholdParameterName, "Quality threshold for the ensemble evaluation [0.0,1.0]", new DoubleRange(0.8,0.9)));
|
---|
88 | Parameters.Add(new FixedValueParameter<DoubleRange>(ConfidenceThresholdParameterName, "Confidence threshold for the ensemble evaluation [0.0,1.0]", new DoubleRange(0.8, 0.9)));
|
---|
89 | RegisterParameterEvents();
|
---|
90 | }
|
---|
91 | [StorableHook(HookType.AfterDeserialization)]
|
---|
92 | private void AfterDeserialization() {
|
---|
93 | RegisterParameterEvents();
|
---|
94 | }
|
---|
95 | #endregion
|
---|
96 |
|
---|
97 | public event EventHandler Reset;
|
---|
98 | public event EventHandler ModelChanged;
|
---|
99 | public event EventHandler QualityThresholdChanged;
|
---|
100 | public event EventHandler ConfidenceThresholdChanged;
|
---|
101 |
|
---|
102 | private void RegisterParameterEvents() {
|
---|
103 | ModelParameter.ValueChanged += new EventHandler(Model_ValueChanged);
|
---|
104 | QualityThresholdParameter.ValueChanged += new EventHandler(QualityTreshold_ValueChanged);
|
---|
105 | ConfidenceThresholdParameter.ValueChanged += new EventHandler(ConfidenceTreshold_ValueChanged);
|
---|
106 | }
|
---|
107 |
|
---|
108 | private void Model_ValueChanged(object sender, EventArgs e) {
|
---|
109 | if (e == null) return;
|
---|
110 | DatastreamAnalysisUtil.RaiseEvent(this, ModelChanged);
|
---|
111 | }
|
---|
112 |
|
---|
113 | private void QualityTreshold_ValueChanged(object sender, EventArgs e) {
|
---|
114 | if (e == null) return;
|
---|
115 | DatastreamAnalysisUtil.RaiseEvent(this, QualityThresholdChanged);
|
---|
116 | }
|
---|
117 |
|
---|
118 | private void ConfidenceTreshold_ValueChanged(object sender, EventArgs e) {
|
---|
119 | if (e == null) return;
|
---|
120 | DatastreamAnalysisUtil.RaiseEvent(this, ConfidenceThresholdChanged);
|
---|
121 | }
|
---|
122 |
|
---|
123 | // TODO
|
---|
124 | public IEnumerable<IParameterizedItem> ExecutionContextItems { get; }
|
---|
125 | }
|
---|
126 | }
|
---|