Skip to content

The kNN estimator returns the complete graph #14

Description

@kslote1

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions