xges#

causalbase.search.xges(score, initial_graph=None, *, extended=True, max_t_size=None, knowledge=None, max_parents=None, one_edge_faithfulness=False)[source]#

Run XGES with score and return the learned equivalence class.

XGES-0 applies, at every step, the best Delete that improves the score; if there is none, the best Reverse; if there is none, the best Insert. It stops where none of the three improves. With extended, XGES then forces out each edge in turn, bars the search from putting it back the same way, runs XGES-0 again and keeps the result if it scores higher, until no forced deletion pays. As in the authors’ code, an accepted bar stays for the rest of the search; unlike it, the search ends with XGES-0 free of bars, and starts over if that improves, so the result is a local optimum of the whole neighbourhood.

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 empty graph by default.

extendedbool, default=True

Run the forced deletions after XGES-0; False is XGES-0 alone.

max_t_size, knowledge, max_parents, one_edge_faithfulness

As in ges(). The screen of one_edge_faithfulness limits Inserts only.

Returns:
SearchResult

As ges() returns it, but n_iter counts every operator XGES-0 applied, those of the forced deletions it then rejected included; the trace has an entry at the start, after XGES-0 and after each round of forced deletions that improved the score, and info holds "rounds", the rounds of forced deletions.

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 xges
>>> xges(BDeuScore(load_asia().data)).cpdag
PDAG(num_nodes=8, directed=..., undirected=...)