BAMT icon indicating copy to clipboard operation
BAMT copied to clipboard

scratch of structure learning for discrete bn

Open Roman223 opened this issue 9 months ago • 0 comments

This pull request introduces several significant changes to the bamt package, focusing on enhancing the functionality and structure of the checker classes, graph classes, and node models. The most important changes include the creation of new checker classes, updates to the graph structure, and improvements to the node models.

Checker Classes Enhancements:

  • bamt/checkers/base.py: Introduced the Checker class, which includes methods for validating arguments and initializing node types.
  • bamt/checkers/network_checker.py: Added the NetworkChecker class, which extends Checker and includes methods for checking network restrictions, validating loads, and determining node types.
  • bamt/checkers/node_checkers.py: Created RawNodeChecker and NodeChecker classes to handle raw and evolved node types, respectively. These classes include properties for checking node types and validation methods.

Graph Structure Updates:

  • bamt/core/graph/dag.py: Modified the DirectedAcyclicGraph class to use pgmpy for directed acyclic graphs, added methods for topological sorting, and removed the old networkx graph references.
  • bamt/core/graph/graph.py: Updated the Graph class to include nodes and edges attributes and added a __repr__ method for better representation.

Node Models Improvements:

  • bamt/core/node_models/__init__.py: Corrected the import statements to use relative imports for better modularity.
  • bamt/core/node_models/distribution.py: Added an abstract __repr__ method to the Distribution class for consistent representation across different distributions.
  • bamt/core/node_models/empirical_distribution.py: Implemented the __repr__ method in the EmpiricalDistribution class and added an is_fitted method. [1] [2] [3] [4]

Node Classes Adjustments:

  • bamt/core/nodes/__init__.py: Updated import statements to use relative imports for better modularity.
  • bamt/core/nodes/child_nodes/child_node.py: Modified the ChildNode class to accept a name parameter in the constructor.
  • bamt/core/nodes/child_nodes/conditional_discrete_node.py: Added a __repr__ method and placeholder methods for get_children, get_parents, and fit in the ConditionalDiscreteNode class.
  • bamt/core/nodes/node.py: Updated the Node class to include name, disc_parents, cont_parents, and children attributes.
  • bamt/core/nodes/root_nodes/continuous_node.py: Corrected the import statement for ContinuousDistribution.
  • bamt/core/nodes/root_nodes/discrete_node.py: Modified the DiscreteNode class to accept a name parameter and updated the __repr__ method.
  • bamt/core/nodes/root_nodes/root_node.py: Updated the RootNode class to accept a name parameter and added a __repr__ method.

Additional Changes:

  • bamt/dag_optimizers/dag_optimizer.py: Updated the optimize method signature to accept data, scorer, and an optional formatter parameter.

Roman223 avatar Apr 03 '25 11:04 Roman223