Generator

Used this package to create realistic Bayesian belief networks.

pybbn.generator.bbngenerator.convert_for_drawing(bbn)

Converts a BBN to a networkx graph for drawing.

Parameters:

bbn – BBN.

Returns:

Directed acyclic graph.

pybbn.generator.bbngenerator.convert_for_exact_inference(g, p)

Converts the graph and parameters to a BBN.

Parameters:
  • g – Directed acyclic graph (DAG in the form of networkx).

  • p – Parameters.

Returns:

BBN.

pybbn.generator.bbngenerator.generate_bbn_to_file(n, file_path, bbn_type='singly', max_iter=10, max_values=2, max_alpha=10)

Generates a BBN and saves it to a file.

Parameters:
  • n – Number of nodes.

  • file_path – File path. JSON and CSV supported. Export will be determined by path extension.

  • bbn_type – Type: singly or multi.

  • max_iter – Maximum iterations.

  • max_values – Maximum values.

  • max_alpha – Maximum alpha.

Returns:

None.

pybbn.generator.bbngenerator.generate_multi_bbn(n, max_iter=10, max_values=2, max_alpha=10)

Generates structure and parameters for a multi-connected BBN.

Parameters:
  • n – Number of nodes.

  • max_iter – Maximum iterations.

  • max_values – Maximum values per node.

  • max_alpha – Maximum alpha per value (hyperparameters).

Returns:

A tuple of structure and parameters.

pybbn.generator.bbngenerator.generate_singly_bbn(n, max_iter=10, max_values=2, max_alpha=10)

Generates structure and parameters for a singly-connected BBN.

Parameters:
  • n – Number of nodes.

  • max_iter – Maximum iterations.

  • max_values – Maximum values per node.

  • max_alpha – Maximum alpha per value (hyperparameters).

Returns:

A tuple of structure and parameters.

pybbn.generator.bbngenerator.to_json(g, params, pretty=False)

Serializes the graph to JSON.

Parameters:
  • g – Graph.

  • params – Parameters.

  • pretty – Pretty-print serialization flag.

Returns:

None.