Skip to content

Commit

Permalink
Fix bug in statistical test features.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn committed Aug 15, 2023
1 parent be84252 commit 3ab8784
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions WORC/featureprocessing/StatisticalTestFeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,13 @@ def StatisticalTestFeatures(features, patientinfo, config, output_csv=None,
class1_count = [class1.count(i) for i in unique_values]
class2_count = [class2.count(i) for i in unique_values]
obs = np.array([class1_count, class2_count])

_, p, _, _ = chi2_contingency(obs)
pvalueschi2.append(p)

try:
_, p, _, _ = chi2_contingency(obs)
pvalueschi2.append(p)
except ValueError:
print("[WORC Warning] " + fl + " has a zero element in table of frequencies. Replacing chi2 metric value by NaN.")
pvalueschi2.append(np.nan)
else:
print("[WORC Warning] " + fl + " is no categorical variable. Replacing chi2 metric value by NaN.")
pvalueschi2.append(np.nan)
Expand Down

0 comments on commit 3ab8784

Please sign in to comment.