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

Replaced kstest p-value calculation to match scipy's ks_2samp #483

Merged
merged 3 commits into from
Mar 22, 2022
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
9 changes: 6 additions & 3 deletions src/whylogs/core/summaryconverters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
kll_floats_sketch,
update_theta_sketch,
)
from scipy import special, stats
from scipy import stats

from whylogs.proto import (
ColumnSummary,
Expand Down Expand Up @@ -289,8 +289,11 @@ def ks_test_compute_p_value(target_distribution: kll_floats_sketch, reference_di
D_max = D
j += 1

n_samples = min(target_distribution.get_n(), reference_distribution.get_n())
p_value = special.kolmogorov(np.sqrt(n_samples) * D_max)
m, n = sorted([target_distribution.get_n(), reference_distribution.get_n()], reverse=True)
en = m * n / (m + n)

p_value = stats.distributions.kstwo.sf(D_max, np.round(en))

return type("Object", (), {"ks_test": p_value})


Expand Down