Skip to content

Commit

Permalink
Remove double leading underscore for variable min_samples within the …
Browse files Browse the repository at this point in the history
…implementation.
  • Loading branch information
hoanganhngo610 authored Sep 6, 2024
1 parent bc76563 commit 2caecae
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions river/drift/teda_cdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, m=3.0, alpha=0.95, jaccard_threshold=0.8):
self._evolving_model_mean = 0.0
self._evolving_model_var = 0.0

self.__min_samples = math.ceil(1.0 / (1.0 - self.alpha))
self._min_samples = math.ceil(1.0 / (1.0 - self.alpha))

if self.m <= 0.0:
raise ValueError("Parameter `m` must be greater than 0")
Expand Down Expand Up @@ -123,7 +123,7 @@ def jaccard_index(self):

@property
def min_samples(self):
return self.__min_samples
return self._min_samples

def _reset(self):
"""Reset the detector's state replacing the reference model by the evoling model."""
Expand All @@ -137,7 +137,7 @@ def update(self, x):
reference_model_teda_threshold = self._reference_model_teda_threshold()
if (
reference_model_teda_score <= reference_model_teda_threshold
or self.reference_model_n <= self.__min_samples
or self.reference_model_n <= self._min_samples
):
self._update_reference_model(x)

Expand All @@ -162,8 +162,8 @@ def update(self, x):
self._drift_detected = _drift_detected

def _is_detection_enabled(self):
if (self._evolving_model_n < self.__min_samples) or (
self._reference_model_n < self.__min_samples
if (self._evolving_model_n < self._min_samples) or (
self._reference_model_n < self._min_samples
):
return False
return True
Expand Down Expand Up @@ -201,7 +201,7 @@ def _update_reference_model(self, value):
)

def _update_evolving_model(self, value):
if self.evolving_model_n < self.__min_samples:
if self.evolving_model_n < self._min_samples:
self._evolving_model_n += 1.0
if self._evolving_model_mean != value:
alpha_weight = (
Expand All @@ -220,7 +220,7 @@ def _update_evolving_model(self, value):
)

def _replace_reference_model(self):
self._reference_model_n = min(self._evolving_model_n, self.__min_samples)
self._reference_model_n = min(self._evolving_model_n, self._min_samples)
self._reference_model_mean = self._evolving_model_mean
self._reference_model_var = self._evolving_model_var

Expand Down

0 comments on commit 2caecae

Please sign in to comment.