Score#

class causalbase.scores.Score(*args, **kwargs)[source]#

A decomposable score: a DAG scores the sum of its families’ local scores.

This is what causalbase.search.ges() and causalbase.search.xges() need from a score, and the extension point for new ones. Any object with an n_vars attribute (the number of variables, which sets the size of the graph a search learns) and these two methods works with them; the other searches also call local_scores_add(node, parents, candidates). The easiest way to write a score is to subclass FamilyScore and implement its compute_family, which adds caching, batching, the structure prior and local_scores_add, so the score works with every search.

Higher is better, and both methods must give the same value for the same family: the search compares their results directly.

local_score(node, parents)[source]#

Return the local score of node given parents.

local_scores_with(node, parents, extra)[source]#

Return the local score of node given parents | {x}, for each x in extra.

The families an Insert compares, all at once; a loop over local_score() is a correct implementation.