bnlearn

Python library for learning the graphical structure of Bayesian networks, parameter learning, inference and sampling methods.

OTHER License

Downloads
10.3K
Stars
447
Committers
8
bnlearn - v0.7.5

Published by erdogant about 2 years ago

  • Fix for issues #37 where query2df is fixed to output a structured dataframe with the query information.
  • Added unit test for this issue.
bnlearn - v0.7.4

Published by erdogant about 2 years ago

  • Added Gibbs sampling. See the docs for examples.
  • Improvements in verbosity messages.
  • Some code refactoring/cleaning.
bnlearn - v0.7.3

Published by erdogant over 2 years ago

  • added input parameter n_jobs where possible
bnlearn - v0.7.2

Published by erdogant over 2 years ago

  • improved speed in predict functionality
  • Add scoretype to parameter_learning
bnlearn - v0.7.1

Published by erdogant over 2 years ago

  • smooth parameter added to parameter_learning
import bnlearn as bn
DAG = bn.import_DAG('water', verbose=0)
# Sampling
df = bn.sampling(DAG, n=1000)
# Parameter learning
model = bn.parameter_learning.fit(DAG, df, smooth=None)

bnlearn - v0.7.0

Published by erdogant over 2 years ago

  • Fix for plotting due to new version of networkx. The version of networkx should be >= 2.7.1
  • Layout can now be changed more easily
  • figsize added as an input parameter which is more convenient than width/height.
import bnlearn as bn
df = bn.import_example('asia')
model = bn.structure_learning.fit(df)
# Plot
bn.plot(model)
# Plot with different layouts
bn.plot(model, params_static={'layout':'spectral_layout'})
bn.plot(model, params_static={'layout':'planar_layout'})
bn.plot(model, params_static={'layout':'kamada_kawai_layout'})
bn.plot(model, params_static={'layout':'spring_layout'})
bn.plot(model, params_static={'layout':'circular_layout', "figsize": (15, 10)})

bnlearn - v0.6.3

Published by erdogant over 2 years ago

  • added pyvis to setup file and requirements.
bnlearn - v0.6.2

Published by erdogant over 2 years ago

  • fix for bn.print_CPD()
  • name convention: bayesianmodel into bayesiannetwork
bnlearn - 0.6.1

Published by erdogant over 2 years ago

  • Name convention: BayesianModel is changed into BayesianNetwork
bnlearn - 0.6.0

Published by erdogant over 2 years ago

import bnlearn as bn
# Load large example with source-target edges
vec = bn.import_example("stormofswords")
# Convert to dataframe
df = bn.vec2df(vec['source'], vec['target'], weights=vec['weight'])
bnlearn - 0.5.2

Published by erdogant over 2 years ago

  • Added new functionality vec2df to create dataframe from source-target-weights
  • Added new example to demonstrate the usage
  • updated some docstrings

Example vec2df:

import bnlearn as bn

source=['Cloudy','Cloudy','Sprinkler','Rain']
target=['Sprinkler','Rain','Wet_Grass','Wet_Grass']
weights=[1,2,1,3]

# Convert into sparse datamatrix
df = bn.vec2df(source, target, weights=weights)

#    Cloudy   Rain  Sprinkler  Wet_Grass
# 0    True  False       True      False
# 1    True   True      False      False
# 2    True   True      False      False
# 3   False  False       True       True
# 4   False   True      False       True
# 5   False   True      False       True
# 6   False   True      False       True

bnlearn - 0.5.1

Published by erdogant almost 3 years ago

  • Improvements in independence test. It should also work now after parameter_learning.
  • Improvements in plots
  • Code refactoring
bnlearn - 0.5.0

Published by erdogant almost 3 years ago

  • implementation of bnlearn.independence_test functionality that allows to compute edge strength
  • plots improved for the edge weights
  • more pep styling
  • some code refactoring
# Example:

# Load asia DAG
df = bn.import_example(data='alarm')
# Structure learning of sampled dataset
model = bn.structure_learning.fit(df)
# Compute edge strength with the chi_square test statistic. Set prune=True to remove the none-significant edges.
model = bn.independence_test(model, df, test='chi_square', prune=False)
# Make plot
bn.plot(model)

bnlearn - 0.4.11

Published by erdogant almost 3 years ago

  • small fixes
bnlearn - 0.4.10

Published by erdogant almost 3 years ago

  • Bugfix when plotting when using edge_properties.
  • added naivebayes method for creating DAG.
  • added naivebayes method for structure learning.
  • code refactoring.
  • Updating docstrings.
  • Updated unit tests

Let me know if there are accidental new bugs introduced!

bnlearn - 0.4.9

Published by erdogant almost 3 years ago

  • edge properties can be changed for plotting purposes
    • color (per edge)
    • weight (per edge)
    • edge_alpha (overall)
    • arrowstyle (overall)
    • arrowsize (overall)
bnlearn - 0.4.8

Published by erdogant almost 3 years ago

  • added doi
bnlearn - 0.4.7

Published by erdogant almost 3 years ago

  • added missing package: tabulate
bnlearn - 0.4.6

Published by erdogant almost 3 years ago

  • output of inference variables is ordered in the same manner as defined in the input.
bnlearn - 0.4.5

Published by erdogant about 3 years ago

  • Bug fix that fixes handling multiple categorical values in the inference.