From Python¶
The command-line interface is built on a Python interface. You can use the Python interface in scripts and notebooks, or to create figures that are not included in the report.
from layerbn.analysis import Analysis
from layerbn import figures
study = Analysis.from_files("my-study/settings.yml")
study.stable_edges("all_variables") # arc stability, as a table
study.importance("all_variables") # mutual information with the targets
study.profiles() # the profiles defined in the settings
fig = figures.network_figure(study, "all_variables", highlight=["OUTCOME"])
figures.save_figure(fig, "my_network") # my_network.png and my_network.pdf
study.explore("all_variables") # the explorer, shown in a notebook
The Python interface reads the same two files as layerbn run, so both give the same
results.
Notebook¶
This adds a Jupyter notebook to the project that runs the same steps one at a time. It requires JupyterLab (see Optional packages).
For all classes and functions, see Python API.