Skip to content

Commit 446d7d4

Browse files
committed
update
1 parent aa2a98c commit 446d7d4

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

README.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,23 @@
55
Learning Bayesian Belief Networks (BBNs) with LASSO. Example code is as below.
66

77
```python
8-
import pandas as pd
9-
from lassobbn.learn import do_learn
8+
from lassobbn.learn import learn_parameters, learn_structure, to_bbn, to_join_tree, posteriors_to_df
109

11-
df = pd.read_csv('./path/to/data.csv')
12-
bbn_specs = do_learn(df)
10+
# Step 1. Learn the structure
11+
df_path = './data/data-binary.csv'
12+
meta_path = './data/data-binary-complete.json'
13+
14+
parents = learn_structure(df_path, meta_path, n_way=2, ignore_neg_gt=-0.01, ignore_pos_lt=0.05)
15+
16+
# Step 2. Learn the parameters
17+
d, g, p = learn_parameters(df_path, parents)
18+
19+
# Step 3. Get the BBN
20+
bbn = to_bbn(d, g, p)
21+
22+
# Step 4. Get the Join Tree
23+
jt = to_join_tree(bbn)
1324

14-
print(bbn_specs)
1525
```
1626

1727
You can then use [Py-BBN](https://py-bbn.readthedocs.io/) to create a BBN and join tree (JT) instance and perform exact inference.

0 commit comments

Comments
 (0)