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

This module defines the PartitionProposal class, which implements various operations
for proposing modifications to partitions in a structure learning context.
 
Classes:
    PartitionProposal: Implements operations such as swapping, splitting, merging,
    and moving nodes between partitions.
 
Methods:
    propose: Proposes a new state by applying one of the defined operations.
    compute_acceptance_ratio: Computes the acceptance ratio for the proposed state.
    get_nodes_to_rescore: Returns the nodes that need to be rescored.
    accept: Accepts the proposed state and updates the current state.
    compute_neighborhoods: Computes the number of neighborhoods for a given state.
    _calculate_move_probs: Calculates probabilities for different moves.
    _swap_adjacent: Swaps nodes between adjacent partitions.
    _swap_global: Swaps nodes between non-adjacent partitions.
    _split_or_merge_move: Performs either a split or merge operation.
    _split_move: Splits a partition into two.
    _join_move: Merges two adjacent partitions.
    _node_to_existing_partition: Moves a node to an existing partition.
    _node_to_new_partition: Moves a node to a new partition.
    _move_node_to_existing_or_new_partition: Moves a node to either an existing or new partition.
    _compute_neighborhoods_new_existing_partition: Computes neighborhoods for new and existing partitions.
    _calculate_join_possibilities: Calculates join possibilities for nodes.
    _calculate_partition_transitions: Calculates partition transition possibilities.
    _possible_splits_joins: Calculates possible splits and joins.
    _possible_permutations_neighbors: Calculates permutations for neighboring partitions.
    _possible_permutations: Calculates permutations for all partitions.

 
Modules
       
math
numpy
matplotlib.patches
matplotlib.pyplot
seaborn

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

 
class PartitionProposal(structure_learning.proposals.proposal.StructureLearningProposal)
    PartitionProposal(initial_state: structure_learning.data_structures.partition.OrderedPartition, whitelist: numpy.ndarray = None, blacklist: numpy.ndarray = None, seed=32)
 

 
 
Method resolution order:
PartitionProposal
structure_learning.proposals.proposal.StructureLearningProposal
abc.ABC
builtins.object

Methods defined here:
__init__(self, initial_state: structure_learning.data_structures.partition.OrderedPartition, whitelist: numpy.ndarray = None, blacklist: numpy.ndarray = None, seed=32)
Initialise StructureLearningProposal instance.
 
Parameters:
    graph (networkx.DiGraph): graph
    blacklist (numpy.ndarray): mask for edges to ignore in the proposal
    whitelist (numpy.ndarray): mask for edges to include in the proposal
accept(self)
Accepts the proposed state and updates the current state.
compute_acceptance_ratio(self, current_state_score, proposed_state_score, current_state_prior=0, proposed_state_prior=0)
Computes the acceptance ratio for the proposed state.
 
Args:
    current_state_score (float): The score of the current state.
    proposed_state_score (float): The score of the proposed state.
 
Returns:
    float: The acceptance ratio, capped at 0.
compute_neighborhoods(self, state)
Computes the number of neighborhoods of an ordered partiion by using the equation
sum_{i=1}^{m} ( sum_{c=1}^{k_i-1} ( comb( k_i, c) ) ) + m - 1
 
Args:
    state (OrderedPartition): The state for which neighborhoods are computed.
 
Returns:
    tuple: A tuple containing the total number of neighborhoods and a list of combinations.
get_nodes_to_rescore(self)
Returns the nodes that need to be rescored.
 
Returns:
    set: A set of nodes to be rescored.
propose(self)
Proposes a new state by applying one of the defined operations.
 
Returns:
    tuple: A tuple containing the proposed state and the operation applied.

Data and other attributes defined here:
MERGE_PARTITIONS = 'merge_partitions'
MOVE_NODE_TO_EXISTING_PARTITION = 'move_node_to_existing_partition'
MOVE_NODE_TO_NEW_OR_EXISTING = 'move_node_to_new_or_existing'
MOVE_NODE_TO_NEW_PARTITION = 'move_node_to_new_partition'
SPLIT_OR_MERGE = 'split_or_merge'
SPLIT_PARTITIONS = 'split_partitions'
STAY_STILL = 'stay_still'
SWAP_ADJACENT = 'swap_adjacent'
SWAP_GLOBAL = 'swap_global'
__abstractmethods__ = frozenset()
operations = ['swap_adjacent', 'swap_global', 'split_or_merge', 'move_node_to_new_or_existing', 'stay_still']

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'

 
Data
        List = typing.List