gfn.gym.helpers.bayesian_structure.scores

Classes

BGeScore

BGe score.

BaseScore

Base class for the scorer.

Functions

logdet(matrix)

Module Contents

class gfn.gym.helpers.bayesian_structure.scores.BGeScore(data, prior, mean_obs=None, alpha_mu=1.0, alpha_w=None)

Bases: BaseScore

BGe score.

Parameters:
  • data (pandas.DataFrame) – A DataFrame containing the (continuous) dataset D. Each column corresponds to one variable.

  • prior (gfn.gym.helpers.bayesian_structure.priors.BasePrior) – A callable that returns the log prior contribution given num_parents.

  • mean_obs (Optional[torch.Tensor]) – Mean parameter of the Normal prior over the mean μ. This array must have size (N,), where N is the number of variables.

  • alpha_mu (float) – Precision parameter for the Normal prior over the mean μ.

  • alpha_w (Optional[float]) – Degrees of freedom for the Wishart prior over the precision matrix W. Must satisfy alpha_w > N - 1.

R
_calculate_bge_score(adj_matrix)

Calculate the BGe score for a single graph represented by its adjacency matrix. The score is computed as the sum of local scores over all nodes.

Parameters:

adj_matrix (torch.Tensor)

Return type:

float

alpha_mu = 1.0
alpha_w = None
local_score(target, parents)

Calculate the local BGe score.

Parameters:
  • target (int) – The target node index.

  • parents (list[int]) – The indices of the parents of the target node.

Return type:

float

log_gamma_term
mean_obs = None
num_nodes
num_samples
state_evaluator(states)

Evaluate the BGe score for the given states. Expecting state.tensor.to_data_list() to return a list of graph objects, each of which has attributes ‘edge_index’ and a method to convert the sparse representation to an adjacency matrix.

Parameters:

states (gfn.states.GraphStates)

Return type:

torch.Tensor

t
class gfn.gym.helpers.bayesian_structure.scores.BaseScore(data, prior)

Bases: abc.ABC

Base class for the scorer.

Parameters:
column_names
data
num_nodes
prior
abstract state_evaluator(state)
Parameters:

state (gfn.states.GraphStates)

Return type:

torch.Tensor

gfn.gym.helpers.bayesian_structure.scores.logdet(matrix)
Parameters:

matrix (torch.Tensor)

Return type:

torch.Tensor