Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to visualize the FCM based approaches #146

Open
priamai opened this issue Oct 30, 2023 · 3 comments
Open

how to visualize the FCM based approaches #146

priamai opened this issue Oct 30, 2023 · 3 comments

Comments

@priamai
Copy link

priamai commented Oct 30, 2023

Hi there,
I noticed that the FCM methods don't produce a Graph object.

from causallearn.search.FCMBased import lingam
model = lingam.DirectLiNGAM(random_state=None, prior_knowledge=None, apply_prior_knowledge_softly=False, measure='pwling')
model.fit(dataset)

print(model.causal_order_)
print(model.adjacency_matrix_)

Why they are not following the other approach like in Constrained based and in Score Based?
Cheers.

@kunwuz
Copy link
Collaborator

kunwuz commented Nov 3, 2023

Yea you are right, at least for these LiNGAM-based methods we could definitely visualize them in a similar way as follows:

from causallearn.search.FCMBased import lingam
model = lingam.ICALiNGAM()
model.fit(data)

from causallearn.search.FCMBased.lingam.utils import make_dot
make_dot(model.adjacency_matrix_, labels=labels)

We will include these usages into the doc, and preferably make the visualization way consistent with other methods. For ANM or PNL, the multivariate version could be a little bit more tricky, see e.g. https://proceedings.mlr.press/v177/uemura22a/uemura22a.pdf.

@priamai
Copy link
Author

priamai commented Nov 16, 2023

Hello,
that worked:
https://colab.research.google.com/drive/1BZ2idQWgr7Ed6d09fk9bYi4a5RoOiu3g?usp=sharing
is there a way to save it into a file?

@priamai
Copy link
Author

priamai commented Nov 16, 2023

Quick solution

from causallearn.search.FCMBased.lingam.utils import make_dot
my_dot = make_dot(model.adjacency_matrix_,labels=df.columns.to_list())
my_dot.filename="test"
my_dot.name="test"
my_dot.render(format='png')
my_dot.save(filename="test.dot")

maybe add to the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants