Comments (2)
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.
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)
- Can't install causalnex using poetry on new Apple M1 chip HOT 1
- EMSingleLatentVariable is producing random error at random times HOT 1
- Add GitHub Actions installation jobs across environments HOT 1
- Unsuitability of Notears for causal inference HOT 3
- How do I save the fitted Bayesian model locally HOT 2
- get_target_subgraph function is not working HOT 1
- vis.show() UnicodeEncodeError HOT 9
- Find out the number of cycles HOT 1
- 01_first_tutorial.ipynb hangs on `from_pandas(...)`
- [Feature Request]: Support pandas >= 2.0
- [Bug]: Pycharm cannot use causalnex HOT 1
- [help]: I am unable to display images while using viz. show()
- [Feature Request]: batch_size for notears with GPU
- [Bug]: Inconsistent Use of CUDA Devices When Using GPU with notears
- [Bug]: Classification Model always predicting 0 HOT 1
- [Bug]: fix typo in 04_user_guide.md
- [Feature Request]: Support Python 3.11
- [Bug]: causalnex.discretiser.MDLPSupervisedDiscretiserMethod does not import MDLP
- An issue with plotting[Bug]: HOT 1
- Discontinuous time series data HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from causalnex.