-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractEvolvingChangeDetector.java
More file actions
165 lines (142 loc) · 4.5 KB
/
AbstractEvolvingChangeDetector.java
File metadata and controls
165 lines (142 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
* AbstractChangeDetector.java
* Copyright (C) 2011 University of Waikato, Hamilton, New Zealand
* @author Albert Bifet (abifet at cs dot waikato dot ac dot nz)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package moa.classifiers.core.driftdetection;
import moa.options.AbstractOptionHandler;
/**
* Abstract Change Detector. All change detectors in MOA extend this class.
*
* @author Albert Bifet (abifet at cs dot waikato dot ac dot nz)
* @version $Revision: 7 $
*/
public abstract class AbstractEvolvingChangeDetector extends AbstractOptionHandler
implements EvolvingChangeDetector {
/**
* Change was detected
*/
protected boolean isChangeDetected;
/**
* Warning Zone: after a warning and before a change
*/
protected boolean isWarningZone;
/**
* Prediction for the next value based in previous seen values
*/
protected double estimation;
/**
* Delay in detecting change
*/
protected double delay;
/**
* The change detector has been initialized with the option values
*/
protected boolean isInitialized;
/**
* Resets this change detector. It must be similar to starting a new change
* detector from scratch.
*
*/
public void resetLearning() {
this.isChangeDetected = false;
this.isWarningZone = false;
this.estimation = 0.0;
this.delay = 0.0;
this.isInitialized = false;
}
/* added by asuarez for RCARF 22/05/2018 */
/**
* Sets the change detector confidence interval
*/
public abstract void setDelta (double d);
/**
* Gets the change detector confidence interval
*
* @return the current change detector confidence interval
*/
public abstract double getDelta();
/* ***************************************/
/**
* Adding a numeric value to the change detector<br><br>
*
* The output of the change detector is modified after the insertion of a
* new item inside.
*
* @param inputValue the number to insert into the change detector
*/
public abstract void input(double inputValue);
/**
* Gets whether there is change detected.
*
* @return true if there is change
*/
public boolean getChange() {
return this.isChangeDetected;
}
/**
* Gets whether the change detector is in the warning zone, after a warning
* alert and before a change alert.
*
* @return true if the change detector is in the warning zone
*/
public boolean getWarningZone() {
return this.isWarningZone;
}
/**
* Gets the prediction of next values.
*
* @return a prediction of the next value
*/
public double getEstimation() {
return this.estimation;
}
/**
* Gets the length of the delay in the change detected.
*
* @return he length of the delay in the change detected
*/
public double getDelay() {
return this.delay;
}
/**
* Gets the output state of the change detection.
*
* @return an array with the number of change detections, number of
* warnings, delay, and estimation.
*/
public double[] getOutput() {
double[] res = {this.isChangeDetected ? 1 : 0, this.isWarningZone ? 1 : 0, this.delay, this.estimation};
return res;
}
/**
* Returns a string representation of the model.
*
* @param out the stringbuilder to add the description
* @param indent the number of characters to indent
*/
@Override
public abstract void getDescription(StringBuilder sb, int indent);
/**
* Produces a copy of this change detector method
*
* @return the copy of this change detector method
*/
@Override
public EvolvingChangeDetector copy() {
return (EvolvingChangeDetector) super.copy();
}
}