With information="knn" on the package's own linear-Gaussian benchmark (n=5, T=500, max_lag=1), every run returns all 25 directed pairs including self-loops, regardless of the ground truth:
| seed |
true edges |
predicted |
TP |
FP |
runtime |
| 0 |
0 |
25 |
0 |
25 |
137 s |
| 1 |
5 |
25 |
5 |
20 |
131 s |
| 2 |
3 |
25 |
3 |
22 |
129 s |
| 3 |
3 |
25 |
3 |
22 |
129 s |
The unit test confirms this — test_standard_knn in causationentropy/tests/test_data_integration.py fails:
Standard KNN Estimate: TPR: 1.0, FPR: 1.3571428571428572
FAILED (assert fpr == 0)
Two likely contributing defects in knn_conditional_mutual_information (conditional_mutual_information.py:143):
- Line 201:
cdist(JS, JS, metric="minkowski", p=k+1) conflates the neighbour count k with the Minkowski order p. With discover_network's default k_means=5 this silently computes an order-6 Minkowski distance. These are independent parameters.
- The docstring states two mutually contradictory (and both incorrect) identities:
I(X;Y|Z) = I(X,Y) - I(X,Y;Z) and I(X;Y|Z) = I(X;Y) - I(X;Y|Z).
With
information="knn"on the package's own linear-Gaussian benchmark (n=5, T=500,max_lag=1), every run returns all 25 directed pairs including self-loops, regardless of the ground truth:The unit test confirms this —
test_standard_knnincausationentropy/tests/test_data_integration.pyfails:Two likely contributing defects in
knn_conditional_mutual_information(conditional_mutual_information.py:143):cdist(JS, JS, metric="minkowski", p=k+1)conflates the neighbour countkwith the Minkowski orderp. Withdiscover_network's defaultk_means=5this silently computes an order-6 Minkowski distance. These are independent parameters.I(X;Y|Z) = I(X,Y) - I(X,Y;Z)andI(X;Y|Z) = I(X;Y) - I(X;Y|Z).