py-why / causal-learn

Causal Discovery in Python. It also includes (conditional) independence tests and score functions.
https://causal-learn.readthedocs.io/en/latest/
MIT License
1.13k stars 186 forks source link

Background knowledge not used correctly? #171

Open patfl84 opened 7 months ago

patfl84 commented 7 months ago

Hi, I'm trying to provide a background graph to reduce the number of edges that I have to check when running PC. I'm doing this by setting forbidden edges in my BackgroundKnowledge object.

However, based on the code here: https://github.com/py-why/causal-learn/blob/main/causallearn/utils/PCUtils/SkeletonDiscovery.py#L100

it looks like the conditional independence test is being tested even when the pair of nodes is marked as 'forbidden'. Is this correct? Shouldn't this be completely skipped?

Because of this I see that my runtime for the naive (no background) is the same as the runtime for when I give a background graph, even when I use the FastBackgroundKnowledge object that was previously discussed (https://github.com/py-why/causal-learn/issues/142).

Thanks!

kunwuz commented 6 months ago

Hi, thanks for your interest and question! The current implementation for incorporating background knowledge mainly focuses on fine-tuning the result instead of speeding up the search procedure, since achieving the latter while preserving the correctness of the result might not be straightforward (e.g., forcing a model to choose a specific edge might influence other edges). However, I do think that background should be helpful in some cases. We will work on it, and, at the same time, please feel free to propose any changes :)