Saving and Loading

All models can be saved and loading using the bnlearn.bnlearn.save() and bnlearn.bnlearn.load() functionality.

Example of saving and loading models

# Load data
df = bn.import_example(data='asia')

# Learn structure
model = bn.structure_learning.fit(df, methodtype='tan', class_node='lung')

# Save model
bn.save(model, filepath='bnlearn_model', overwrite=True)

# Load model
model = bn.load(filepath='bnlearn_model')