Module Index : Topics : Keywords
 
 
structure_learning.proposals.graph.graph_proposal
index
/Users/165421/Documents/code/structure_learning/src/structure_learning/proposals/graph/graph_proposal.py

This module implements the GraphProposal class, which generates proposals for graph structures by performing edge operations such as addition, deletion, and reversal.
 
The GraphProposal class is used in structure learning algorithms to explore the space of possible graph structures. It supports constraints through blacklist and whitelist matrices and calculates acceptance ratios for proposed changes.
 
Classes:
    GraphProposal: Generates graph proposals and computes acceptance ratios for structure learning.

 
Modules
       
numpy
networkx

 
Classes
       
structure_learning.proposals.proposal.StructureLearningProposal(abc.ABC)
GraphProposal

 
class GraphProposal(structure_learning.proposals.proposal.StructureLearningProposal)
    GraphProposal(initial_state: Union[numpy.ndarray, networkx.classes.digraph.DiGraph, structure_learning.data_structures.dag.DAG], blacklist=None, whitelist=None, seed: int = 32)
 
Graph Proposal by adding, deleting, reversing edges.
 
 
Method resolution order:
GraphProposal
structure_learning.proposals.proposal.StructureLearningProposal
abc.ABC
builtins.object

Methods defined here:
__init__(self, initial_state: Union[numpy.ndarray, networkx.classes.digraph.DiGraph, structure_learning.data_structures.dag.DAG], blacklist=None, whitelist=None, seed: int = 32)
Initialise GraphProposal instance.
 
Parameters:
    initial_state (networkx.DiGraph | numpy.ndarray): graph
    blacklist (numpy.ndarray): mask for edges to ignore in the proposal
    whitelist (numpy.ndarray): mask for edges to include in the proposal
compute_acceptance_ratio(self, current_state_score, proposed_state_score, current_state_prior=0, proposed_state_prior=0)
Calculate log acceptance ratio.
 
Returns:
    (float)
get_nodes_to_rescore(self) -> List[str]
propose(self)
Propose a DAG.
 
Returns:
    (numpy.ndarray): adjacency matrix of proposed graph
    (str): operation that generated the proposed graph

Data and other attributes defined here:
ADD_EDGE = 'add_edge'
DELETE_EDGE = 'delete_edge'
REVERSE_EDGE = 'reverse_edge'
__abstractmethods__ = frozenset()
operations = ['add_edge', 'delete_edge', 'reverse_edge', 'stay_still']

Methods inherited from structure_learning.proposals.proposal.StructureLearningProposal:
accept(self)

Data descriptors inherited from structure_learning.proposals.proposal.StructureLearningProposal:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

Data and other attributes inherited from structure_learning.proposals.proposal.StructureLearningProposal:
INITIAL = 'initial'
STAY_STILL = 'stay_still'

 
Data
        List = typing.List
Union = typing.Union