88class PrequentialError (BaseMetric ):
99 """Prequential error [dawid1984present]_ using fading factor [gama2009issues]_ metric.
1010
11+ :param alpha: fading factor value, defaults to 1.0
12+ :type alpha: Union[int, float]
13+ :param name: name value, defaults to None. If None, the name will be set to `PrequentialError`.
14+ :type name: Optional[str]
15+
1116 :References:
1217
1318 .. [dawid1984present] Dawid, A. Philip.
@@ -19,20 +24,30 @@ class PrequentialError(BaseMetric):
1924 "Issues in evaluation of stream learning algorithms."
2025 Proceedings of the 15th ACM SIGKDD international conference on Knowledge
2126 discovery and data mining. 2009.
22- """
2327
24- def __init__ (
28+ :Example:
29+
30+ >>> from frouros.metrics import PrequentialError
31+ >>> metric = PrequentialError(alpha=0.9)
32+ >>> X = [1, 1, 0, 1, 0, 0]
33+ >>> Y = [1, 0, 0, 0, 1, 1]
34+ >>> for i, (X_sample, Y_sample) in enumerate(zip(X, Y)):
35+ ... error_value = 1 - (X_sample == Y_sample)
36+ ... prequential_error = metric(error_value=error_value)
37+ ... print(f"Metric={prequential_error:.5f} at step {i}")
38+ Metric=0.00000 at step 0
39+ Metric=0.52632 at step 1
40+ Metric=0.33210 at step 2
41+ Metric=0.52632 at step 3
42+ Metric=0.64199 at step 4
43+ Metric=0.71839 at step 5
44+ """ # noqa: E501 # pylint: disable=line-too-long
45+
46+ def __init__ ( # noqa: D107
2547 self ,
2648 alpha : Union [int , float ] = 1.0 ,
2749 name : Optional [str ] = None ,
2850 ) -> None :
29- """Init method.
30-
31- :param alpha: fading factor value
32- :type alpha: Union[int, float]
33- :param name: metric´s name
34- :type name: Optional[str]
35- """
3651 super ().__init__ (name = name )
3752 self .alpha = alpha
3853 self .cumulative_error = 0.0
0 commit comments