mckinsey / causalnex

A Python library that helps data scientists to infer causation rather than observing correlation.
http://causalnex.readthedocs.io/
Other
2.21k stars 256 forks source link

Question: plot_structure does not work by OSError #105

Closed 8-u8 closed 3 years ago

8-u8 commented 3 years ago

I'm trying the tutorial of causalnex, but I got OSError when I use StructureModel.plot_structure.

My trial environment is:
OS: Ubuntu 20.04
Memory: 24GiB
CPU: Intel Core i7(8th gen) GPU: none
python: 3.8.5
I'm running causalnex on virtual environment: pipenv

When I try "Learning the Structure" section on tutorial:

viz = plot_structure(
    sm,
    graph_attributes={"scale": "0.5"},
    all_node_attributes=NODE_STYLE.WEAK,
    all_edge_attributes=EDGE_STYLE.WEAK)
Image(viz.draw(format='png'))

then, I got OSError and many warnings below:

OSError: Warning: node 'address', graph '' size too small for label
Warning: node 'famsize', graph '' size too small for label
Warning: node 'Pstatus', graph '' size too small for label
Warning: node 'Medu', graph '' size too small for label
Warning: node 'Fedu', graph '' size too small for label
Warning: node 'traveltime', graph '' size too small for label
Warning: node 'studytime', graph '' size too small for label
Warning: node 'failures', graph '' size too small for label
Warning: node 'schoolsup', graph '' size too small for label
Warning: node 'famsup', graph '' size too small for label
Warning: node 'paid', graph '' size too small for label
Warning: node 'activities', graph '' size too small for label
Warning: node 'nursery', graph '' size too small for label
Warning: node 'higher', graph '' size too small for label
Warning: node 'internet', graph '' size too small for label
Warning: node 'romantic', graph '' size too small for label
Warning: node 'famrel', graph '' size too small for label
Warning: node 'freetime', graph '' size too small for label
Warning: node 'goout', graph '' size too small for label
Warning: node 'Dalc', graph '' size too small for label
Warning: node 'Walc', graph '' size too small for label
Warning: node 'health', graph '' size too small for label
Warning: node 'absences', graph '' size too small for label
Warning: node 'G1', graph '' size too small for label
Warning: node 'G2', graph '' size too small for label
Warning: node 'G3', graph '' size too small for label

I know this error in previous issue,
I tried the solution from this issue, but it did not work, too. I want to understand why this error occurred. (PC spec is too low to plot graph? some problem on graphviz or pipenv?)

Now I've checked next content(plot graph with threshold=0.8) work well.

Thank you for your help.

pjbqb commented 3 years ago

Hi - just to check, the plot is still showing?

These are warnings, not errors - and I believe are just because the text is too large to fit inside the node (circle) on the plot and can be ignored. (I get them too, but the graph still displays...).

It comes from GraphViz and may be possible to suppress, but is not a PC spec issue :)

jay-sarkar commented 2 years ago

Hi - just to check, the plot is still showing?

These are warnings, not errors - and I believe are just because the text is too large to fit inside the node (circle) on the plot and can be ignored. (I get them too, but the graph still displays...).

It comes from GraphViz and may be possible to suppress, but is not a PC spec issue :)

Just to be communicative - this problem still exists on Linux. It may not be happening in OS X, per my memory from the past, but its certainly present in Linux. The Text may be too large, but the text sits outside the node circle - but as you see above, the OSError prevents this problem from being ignored by Python/sklearn. It may very well be a Graphviz problem and not Causalnexs' but the fact that it shows up with the Causalnex tutorial exercise - makes it problematic. Is there a software engineer who is an expert in Graphviz suggest a solution ? I'm using Causalnex 0.11 on RHEL 7.8 with all the installation requirements of Causalnex - with Sklearn 1.0.2 and Python 3.8