1414class RDDMConfig (BaseSPCConfig ):
1515 """RDDM (Reactive Drift detection method) [barros2017rddm]_ configuration.
1616
17+ :param warning_level: warning level factor, defaults to 1.773
18+ :type warning_level: float
19+ :param drift_level: drift level factor, defaults to 2.258
20+ :type drift_level: float
21+ :param max_concept_size: maximum size of a concept, defaults to 40000
22+ :type max_concept_size: int
23+ :param min_concept_size: reduced size of a concept, defaults to 7000
24+ :type min_concept_size: int
25+ :param max_num_instances_warning: maximum number of instances at warning level, defaults to 1400
26+ :type max_num_instances_warning: int
27+ :param min_num_instances: minimum numbers of instances to start looking for changes, defaults to 129
28+ :type min_num_instances: int
29+
1730 :References:
1831
1932 .. [barros2017rddm] Barros, Roberto SM, et al.
2033 "RDDM: Reactive drift detection method."
2134 Expert Systems with Applications 90 (2017): 344-355.
22- """
35+ """ # noqa: E501
2336
24- def __init__ (
37+ def __init__ ( # noqa: D107
2538 self ,
2639 warning_level : float = 1.773 ,
2740 drift_level : float = 2.258 ,
@@ -30,22 +43,6 @@ def __init__(
3043 max_num_instances_warning : int = 1400 ,
3144 min_num_instances : int = 129 ,
3245 ) -> None :
33- """Init method.
34-
35- :param warning_level: warning level factor
36- :type warning_level: float
37- :param drift_level: drift level factor
38- :type drift_level: float
39- :param max_concept_size: maximum size of a concept
40- :type max_concept_size: int
41- :param min_concept_size: reduced size of a concept
42- :type min_concept_size: int
43- :param max_num_instances_warning: maximum number of instances at warning level
44- :type max_num_instances_warning: int
45- :param min_num_instances: minimum numbers of instances
46- to start looking for changes
47- :type min_num_instances: int
48- """
4946 super ().__init__ (
5047 drift_level = drift_level ,
5148 warning_level = warning_level ,
@@ -113,30 +110,51 @@ def max_num_instances_warning(self, value: int) -> None:
113110class RDDM (BaseSPCError ):
114111 """RDDM (Reactive Drift detection method) [barros2017rddm]_ detector.
115112
113+ :param config: configuration object of the detector, defaults to None. If None, the default configuration of :class:`RDDMConfig` is used.
114+ :type config: Optional[RDDMConfig]
115+ :param callbacks: callbacks, defaults to None
116+ :type callbacks: Optional[Union[BaseCallbackStreaming, List[BaseCallbackStreaming]]]
117+
118+ :Note:
119+ :func:`update` method expects to receive a value of 0 if the instance is correctly classified (no error) and 1 otherwise (error).
120+
116121 :References:
117122
118123 .. [barros2017rddm] Barros, Roberto SM, et al.
119124 "RDDM: Reactive drift detection method."
120125 Expert Systems with Applications 90 (2017): 344-355.
121- """
126+
127+ :Example:
128+
129+ >>> from frouros.detectors.concept_drift import RDDM
130+ >>> import numpy as np
131+ >>> np.random.seed(seed=31)
132+ >>> dist_a = np.random.binomial(n=1, p=0.6, size=1000)
133+ >>> dist_b = np.random.binomial(n=1, p=0.8, size=1000)
134+ >>> stream = np.concatenate((dist_a, dist_b))
135+ >>> detector = RDDM()
136+ >>> warning_flag = False
137+ >>> for i, value in enumerate(stream):
138+ ... _ = detector.update(value=value)
139+ ... if detector.drift:
140+ ... print(f"Change detected at index {i}")
141+ ... break
142+ ... if not warning_flag and detector.warning:
143+ ... print(f"Warning detected at index {i}")
144+ ... warning_flag = True
145+ Warning detected at index 1036
146+ Change detected at index 1066
147+ """ # noqa: E501
122148
123149 config_type = RDDMConfig # type: ignore
124150
125- def __init__ (
151+ def __init__ ( # noqa: D107
126152 self ,
127153 config : Optional [RDDMConfig ] = None ,
128154 callbacks : Optional [
129155 Union [BaseCallbackStreaming , List [BaseCallbackStreaming ]]
130156 ] = None ,
131157 ) -> None :
132- """Init method.
133-
134- :param config: configuration parameters
135- :type config: Optional[RDDMConfig]
136- :param callbacks: callbacks
137- :type callbacks: Optional[Union[BaseCallbackStreaming,
138- List[BaseCallbackStreaming]]]
139- """
140158 super ().__init__ (
141159 config = config ,
142160 callbacks = callbacks ,
0 commit comments