ges#

causalbase.search.ges(score, initial_graph=None, *, candidates=None, max_t_size=None, knowledge=None, max_parents=None, forward=True, backward=True, one_edge_faithfulness=False)[source]#

Run GES with score and return the learned equivalence class.

Parameters:
scoreScore

Decomposable score; the graph has score.n_vars nodes. For BDeuScore(prior="tetrad") the search runs on the Bernoulli BDeu with the same differences between families (see BDeuScore), so it learns Tetrad’s structures.

initial_graphDAG or PDAG, optional

Where the search starts: the equivalence class of a DAG, or of a consistent extension of a PDAG. The empty graph by default.

candidatesfrozenset of (int, int), optional

Restrict both phases to these ordered pairs (x, y).

max_t_sizeint or None, default=None

Largest conditioning subset tried by an Insert. None tries every one that can be valid, as Chickering defines the operator; only the subsets that keep a clique are visited, so this costs little more than a cap unless the neighbours of a node form a large clique.

knowledgeKnowledge, optional

Adjacencies the result must have or must not have. The search starts from initial_graph with them imposed.

max_parentsint or None, optional

No Insert gives its child more parents than this. None is no limit.

forward, backwardbool, default=True

Which phases to run.

one_edge_faithfulnessbool, default=False

Insert an edge only between variables that the score finds dependent on their own, as fGES does (Ramsey et al., 2017). Much faster on many variables; it misses an edge whose paths cancel exactly.

Returns:
SearchResult

cpdag is the learned equivalence class and dag one DAG of it, score the score of dag under score (Tetrad’s value with its prior). n_iter counts the Inserts and Deletes applied, the trace has an entry at the start and after each phase that changed the graph, and info holds "forward_steps" and "backward_steps".

Raises:
ValueError

If initial_graph has another number of nodes, or a limit is out of range.

Examples

>>> from causalbase.datasets import load_asia
>>> from causalbase.scores import BDeuScore
>>> from causalbase.search import ges
>>> ges(BDeuScore(load_asia().data)).cpdag
PDAG(num_nodes=8, directed=..., undirected=...)