jsat.driftdetectors
Class BaseDriftDetector<V>
- java.lang.Object
-
- jsat.driftdetectors.BaseDriftDetector<V>
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public abstract class BaseDriftDetector<V> extends java.lang.Object implements java.lang.Cloneable, java.io.SerializableBase class for providing common functionality to drift detection algorithms- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract booleanaddSample(double value, V obj)Adds a new point to the drift detector.voidclearHistory()Clears the current historyabstract java.lang.Objectclone()voiddriftHandled()This method should be called once the drift is handled.intgetDriftAge()Returns the number of items in recent history that differed from the historical values, or-1if there has not been any detected drift.java.util.List<V>getDriftedHistory()Returns a new list containing up togetMaxHistory()objects in the history that drifted away from the prior state of the model.intgetMaxHistory()Returns the maximum number of items that will be kept in the history.booleanisDrifting()Returnstrueif the algorithm believes that drift has definitely occurred.booleanisWarning()Returnstrueif the algorithm is in a warning state.voidsetMaxHistory(int maxHistory)Sets the maximum number of items to store in history.
-
-
-
Method Detail
-
isWarning
public boolean isWarning()
Returnstrueif the algorithm is in a warning state. This state indicates that the algorithm believes concept drift may be occurring, but is not confident enough to say that is had definitely occurred.
Not all algorithms will raise a warning state, and some may only begin keeping track of history once in the warning state.- Returns:
trueif concept drift may have started, but is not sure
-
isDrifting
public boolean isDrifting()
Returnstrueif the algorithm believes that drift has definitely occurred. At this- Returns:
-
getMaxHistory
public int getMaxHistory()
Returns the maximum number of items that will be kept in the history.- Returns:
- the maximum number of items that will be kept in the history.
-
setMaxHistory
public void setMaxHistory(int maxHistory)
Sets the maximum number of items to store in history. Setting this to0will keep the detector from ever storing history.
The user can still keep their own independent history or checkpoints by using theisDrifting()andisWarning()methods.
The history size may be changed at any time, but may result in the loss of history.- Parameters:
maxHistory- the new maximum history size of objects added
-
clearHistory
public void clearHistory()
Clears the current history
-
getDriftAge
public int getDriftAge()
Returns the number of items in recent history that differed from the historical values, or-1if there has not been any detected drift. This method will return-1even ifisWarning()istrue.- Returns:
- the number of updates ago that the drift started, or
-1if no drift has occurred
-
getDriftedHistory
public java.util.List<V> getDriftedHistory()
Returns a new list containing up togetMaxHistory()objects in the history that drifted away from the prior state of the model.
The 0 index in the list will be the most recently added item, and the largest index will be the oldest item.- Returns:
- the list of objects that make up the effected history
-
addSample
public abstract boolean addSample(double value, V obj)Adds a new point to the drift detector. If an escalation in state occurs,truewill be returned. A change of state could be either drift occurringisDrifting()or a warning stateisWarning(). If the detector was in a warning state and then goes back to normal,falsewill be returned.
For binary (true / false) drift detectors,valuewill be consideredfalseif and only if its value is equal to zero. Any non zero value will be treated astrue
Objects added with the value may or may not be added to the history, the behavior is algorithm dependent. Some may always add it to the history, while others will only begin collecting history once a warning state occurs.- Parameters:
value- the numeric value to add to the drift detectorobj- the object associated with this value. It may or may not be stored in the detectors history- Returns:
trueif a drift has or may be starting.- Throws:
UnhandledDriftException- ifdriftHandled()is not called after drifting is detected
-
driftHandled
public void driftHandled()
This method should be called once the drift is handled. Once done, this method will clear the flags and prepare the detector to continue tracking drift again.
By using this method, one can continue to track multiple future drift changes without having to feed the history data (which may be incomplete) into a new detector object.
-
clone
public abstract java.lang.Object clone()
- Overrides:
clonein classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG