huawei-noah / trustworthyAI

Trustworthy AI related projects
Apache License 2.0
979 stars 216 forks source link

Allow more algorithm to use prior knowledge #79

Open xwbxxx opened 2 years ago

xwbxxx commented 2 years ago

Just like the example of PC algorithm,PC demo.py I hope you can provide interfaces to allow more algorithms to adopt a priori knowledge. image

shaido987 commented 2 years ago

Hello,

Prior knowledge is something we plan to include in all algorithms in the future (as also mentioned in #72). However, there is no timeline for this as of yet.

AlxndrMlk commented 2 years ago

@shaido987, is there a way to help with this task as a contributor?

shaido987 commented 2 years ago

@AlxndrMlk Any contributions in this direction are very welcome! Prior knowledge can be a bit more difficult to integrate into some of the algorithms as compared with PC. If you want to help you can add it to one or multiple algorithms directly for now, and then we can see if the logic can be abstracted into the base class. Or if you have some suggestions in that direction we can look over them.

AlxndrMlk commented 1 year ago

@shaido987

It seems that there were some attempts to introduce the possibility for adding causal knowledge to DirectLiNGAM (https://github.com/huawei-noah/trustworthyAI/blob/master/gcastle/castle/algorithms/lingam/direct_lingam.py), but it seems it does not work in the current version (1.0.3).

I am referring to these (lines 76-77):

@check_args_value(DIRECT_LINGAM_VALID_PARAMS)
def __init__(self, prior_knowledge=None, measure='pwling', thresh=0.3):
   ...

I tried adding a priori knowledge to Direct LiNGAM and it did not work for me (the model was not adding the edges passed to prior_knowlede)

I think that actually it is possible to add the prior knowledge functionality for Direct LiNGAM (it was described in the paper if I'm not mistaken).

Perhaps that would be a good first step for enhancing the palette of models that accept prior knowledge.

What are your thoughts on this?

shaido987 commented 1 year ago

Yes, I agree that making sure that it works for DirectLiNGAM would be a good first step forward.

For the a prior knowledge added to the PC implementation (added in #73) we added a PrioriKnowledge class that can be used here. I believe it should have the same characteristics as the input matrix in DirectLiNGAM.