@@ -128,6 +128,17 @@ class HDDMAConfig(BaseHDDMConfig):
128128class HDDMWConfig (BaseHDDMConfig ):
129129 """HDDM-W (Hoeffding's drift detection method W-Test) [frias2014online]_ configuration.
130130
131+ :param alpha_d: significance value for drift, defaults to 0.001
132+ :type alpha_d: float
133+ :param alpha_w: significance value for warning, defaults to 0.005
134+ :type alpha_w: float
135+ :param two_sided_test: flag that indicates if a two-sided test is performed, defaults to False
136+ :type two_sided_test: bool
137+ :param lambda_: weight given to recent data compared to older data, defaults to 0.05
138+ :type lambda_: float
139+ :param min_num_instances: minimum numbers of instances to start looking for changes, defaults to 30
140+ :type min_num_instances: int
141+
131142 :References:
132143
133144 .. [frias2014online] Frias-Blanco, Isvani, et al.
@@ -136,28 +147,14 @@ class HDDMWConfig(BaseHDDMConfig):
136147 810-823.
137148 """
138149
139- def __init__ (
150+ def __init__ ( # noqa: D107
140151 self ,
141152 alpha_d : float = 0.001 ,
142153 alpha_w : float = 0.005 ,
143154 two_sided_test : bool = False ,
144155 lambda_ : float = 0.05 ,
145156 min_num_instances : int = 30 ,
146157 ) -> None :
147- """Init method.
148-
149- :param alpha_d: significance value for drift
150- :type alpha_d: float
151- :param alpha_w: significance value for warning
152- :type alpha_w: float
153- :param two_sided_test: flag that indicates if a two-sided test is performed
154- :param two_sided_test: bool
155- :param lambda_: weight given to recent data compared to older data
156- :type lambda_: float
157- :param min_num_instances: minimum numbers of instances
158- to start looking for changes
159- :type min_num_instances: int
160- """
161158 super ().__init__ (
162159 alpha_d = alpha_d ,
163160 alpha_w = alpha_w ,
@@ -620,31 +617,49 @@ def update_stats(self, value: float, alpha: float) -> None:
620617class HDDMW (BaseSPC ):
621618 """HDDM-W (Hoeffding's drift detection method with W-Test) [frias2014online]_ detector.
622619
620+ :param config: configuration object of the detector, defaults to None. If None, the default configuration of :class:`HDDMWConfig` is used.
621+ :type config: Optional[HDDMWConfig]
622+ :param callbacks: callbacks, defaults to None
623+ :type callbacks: Optional[Union[BaseCallbackStreaming, List[BaseCallbackStreaming]]]
624+
623625 :References:
624626
625627 .. [frias2014online] Frias-Blanco, Isvani, et al.
626628 "Online and non-parametric drift detection methods based on Hoeffding’s bounds."
627629 IEEE Transactions on Knowledge and Data Engineering 27.3 (2014):
628630 810-823.
629- """
631+
632+ :Example:
633+
634+ >>> from frouros.detectors.concept_drift import HDDMW
635+ >>> import numpy as np
636+ >>> np.random.seed(seed=31)
637+ >>> dist_a = np.random.binomial(n=1, p=0.6, size=1000)
638+ >>> dist_b = np.random.binomial(n=1, p=0.8, size=1000)
639+ >>> stream = np.concatenate((dist_a, dist_b))
640+ >>> detector = HDDMW()
641+ >>> warning_flag = False
642+ >>> for i, value in enumerate(stream):
643+ ... _ = detector.update(value=value)
644+ ... if detector.drift:
645+ ... print(f"Change detected at index {i}")
646+ ... break
647+ ... if not warning_flag and detector.warning:
648+ ... print(f"Warning detected at index {i}")
649+ ... warning_flag = True
650+ Warning detected at index 1017
651+ Change detected at index 1029
652+ """ # noqa: E501
630653
631654 config_type = HDDMWConfig # type: ignore
632655
633- def __init__ (
656+ def __init__ ( # noqa: D107
634657 self ,
635658 config : Optional [HDDMWConfig ] = None ,
636659 callbacks : Optional [
637660 Union [BaseCallbackStreaming , List [BaseCallbackStreaming ]]
638661 ] = None ,
639662 ) -> None :
640- """Init method.
641-
642- :param config: configuration parameters
643- :type config: Optional[HDDMWConfig]
644- :param callbacks: callbacks
645- :type callbacks: Optional[Union[BaseCallbackStreaming,
646- List[BaseCallbackStreaming]]]
647- """
648663 super ().__init__ (
649664 config = config ,
650665 callbacks = callbacks ,
0 commit comments