Code Monkey home page Code Monkey logo

Comments (2)

SteveLerQB avatar SteveLerQB commented on May 25, 2024 3

Hi @ogencoglu,

Just updated the tutorial and documentation. To output the plot, you have to do the following:

from IPython.display import Image
from causalnex.plots import plot_structure, NODE_STYLE, EDGE_STYLE

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

Hope this helps! 🙂

from causalnex.

ogencoglu avatar ogencoglu commented on May 25, 2024

And gives error for the other tutorial example (directly copied from tutorial):

data = pd.read_csv('../data/student-por.csv', delimiter=';')
drop_col = ['school','sex','age','Mjob', 'Fjob','reason','guardian']
data = data.drop(columns=drop_col)
struct_data = data.copy()

non_numeric_columns = list(struct_data.select_dtypes(exclude=[np.number]).columns)
print(non_numeric_columns)

le = LabelEncoder()
for col in non_numeric_columns:
    struct_data[col] = le.fit_transform(struct_data[col])
    
sm = from_pandas(struct_data)
_, _, _ = plot_structure(sm)
/usr/local/lib/python3.7/site-packages/pygraphviz/agraph.py:1367: RuntimeWarning: Warning: node 'address', graph '%3' size too small for label
Warning: node 'famsize', graph '%3' size too small for label
Warning: node 'Pstatus', graph '%3' size too small for label
Warning: node 'Medu', graph '%3' size too small for label
Warning: node 'Fedu', graph '%3' size too small for label
Warning: node 'traveltime', graph '%3' size too small for label
Warning: node 'studytime', graph '%3' size too small for label
Warning: node 'failures', graph '%3' size too small for label
Warning: node 'schoolsup', graph '%3' size too small for label
Warning: node 'famsup', graph '%3' size too small for label
Warning: node 'paid', graph '%3' size too small for label
Warning: node 'activities', graph '%3' size too small for label
Warning: node 'nursery', graph '%3' size too small for label
Warning: node 'higher', graph '%3' size too small for label
Warning: node 'internet', graph '%3' size too small for label
Warning: node 'romantic', graph '%3' size too small for label
Warning: node 'famrel', graph '%3' size too small for label
Warning: node 'freetime', graph '%3' size too small for label
Warning: node 'goout', graph '%3' size too small for label
Warning: node 'Dalc', graph '%3' size too small for label
Warning: node 'Walc', graph '%3' size too small for label
Warning: node 'health', graph '%3' size too small for label
Warning: node 'absences', graph '%3' size too small for label
Warning: node 'G1', graph '%3' size too small for label
Warning: node 'G2', graph '%3' size too small for label
Warning: node 'G3', graph '%3' size too small for label

  warnings.warn(b"".join(errors).decode(self.encoding), RuntimeWarning)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-7-d2da9edb9d84> in <module>
---->  _, _, _ = plot_structure(sm)

ValueError: too many values to unpack (expected 3)

from causalnex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.