Skip to content

Commit

Permalink
Add nan check to kernel based independence test.
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Bloebaum <bloebp@amazon.com>
  • Loading branch information
bloebp committed Jan 18, 2024
1 parent 499019c commit df09897
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dowhy/gcm/independence_test/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ def evaluate_kernel_test_on_samples(

if Z is None:
X, Y = _convert_to_numeric(*shape_into_2d(X, Y))
if np.any(np.isnan(X)) or np.any(np.isnan(Y)):
raise ValueError("Data contains NaN values! Remove or replace missing values first.")
return KCI_UInd(**kwargs).compute_pvalue(X, Y)[0]
else:
X, Y, Z = _convert_to_numeric(*shape_into_2d(X, Y, Z))
if np.any(np.isnan(X)) or np.any(np.isnan(Y)) or np.any(np.isnan(Z)):
raise ValueError("Data contains NaN values! Remove or replace missing values first.")
return KCI_CInd(**kwargs).compute_pvalue(X, Y, Z)[0]

random_indices = [
Expand Down

0 comments on commit df09897

Please sign in to comment.