Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store kdq-tree test statistic #144

Merged
merged 1 commit into from
May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions menelaus/data_drift/kdq_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def __init__(
self.bootstrap_samples = bootstrap_samples
self.count_ubound = count_ubound
self.cutpoint_proportion_lbound = cutpoint_proportion_lbound
self._test_dist = None
self._critical_dist = None

def reset(self):
"""
Expand All @@ -99,6 +101,7 @@ def reset(self):
self._test_data_size = 0
self._kdqtree = None
self._critical_dist = None
self._test_dist = None

def _evaluate_kdqtree(self, ary, input_type):
"""
Expand Down Expand Up @@ -135,6 +138,7 @@ def _evaluate_kdqtree(self, ary, input_type):
# window is full, or we're doing batch detection
if input_type == "batch" or (self._test_data_size >= self.window_size):
test_dist = self._kdqtree.kl_distance(tree_id1="build", tree_id2="test")
self._test_dist = test_dist
if test_dist > self._critical_dist:
if input_type == "stream":
self._drift_counter += 1
Expand Down