Skip to content

Commit

Permalink
udpate examples
Browse files Browse the repository at this point in the history
  • Loading branch information
erdogant committed Apr 13, 2024
1 parent 103ade2 commit f5febaf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bnlearn/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@
model = bn.structure_learning.fit(df, verbose=0, scoretype='k2', methodtype='hc')

# Plot the DAG
DAG = bn.plot(model, verbose=0, interactive=False)
bn.plot(model, verbose=0, interactive=True, node_color='#000000')

# Test for independence
model = bn.independence_test(model, df, prune=False)

# Plot the DAG
bn.plot(model, verbose=0, interactive=False, pos=DAG['pos'])
bn.plot(model, verbose=0, interactive=True, node_color='#000000')

# Print the CPDs
bn.print_CPD(model)
# Comparison
Expand Down Expand Up @@ -104,11 +107,17 @@
df = df.dropna()
DAG = bn.structure_learning.fit(df, methodtype='tan', class_node='threat_type')

# Plot
G = bn.plot(DAG)
G = bn.plot(DAG, interactive=True)

# Structure learning
DAG = bn.independence_test(DAG, df, prune=True)

# Plot
G = bn.plot(DAG)
G = bn.plot(DAG, interactive=True)

# Parameter learning
model = bn.parameter_learning.fit(DAG, df)
# Make inference
Expand Down

0 comments on commit f5febaf

Please sign in to comment.