Skip to main content
Ctrl+K

causalbase 0.2.0

  • Install
  • Quickstart
  • Bring your own data
  • Benchmark networks
  • Algorithms and options
    • Examples
    • API reference
    • Benchmarks
    • Validation
    • Citing
    • Changelog
    • Contributing
  • GitHub
  • Install
  • Quickstart
  • Bring your own data
  • Benchmark networks
  • Algorithms and options
  • Examples
  • API reference
  • Benchmarks
  • Validation
  • Citing
  • Changelog
  • Contributing
  • GitHub

Section Navigation

  • GES
  • XGES
  • OrderSearch
  • FLOP
  • HillClimbing
  • ExactSearch
  • RCD
  • ges
  • xges
  • order_search
  • flop
  • hill_climbing
  • exact_search
  • SearchResult
  • Knowledge
  • OrderScorer
  • OrderResult
  • InsertionSearch
  • IteratedLocalSearch
  • ILSResult
  • pair_polish
  • moment_sums
  • cumulants_from_sums
  • rcd
  • rcd_exact
  • exact_order
  • tau_matrix_3rd
  • tau_matrix_4th
  • estimate_b_from_cov
  • estimate_b_lasso_from_cov
  • RCDResult
  • Score
  • FamilyScore
  • BDeuScore
  • BICScore
  • GaussianBICScore
  • BGeScore
  • make_score
  • log_likelihood
  • DiscreteDataset
  • ContinuousDataset
  • as_discrete
  • as_discrete_sites
  • as_continuous
  • as_continuous_sites
  • load_network
  • list_networks
  • fetch_network
  • list_remote_networks
  • get_data_home
  • load_cancer
  • load_asia
  • load_child
  • load_insurance
  • load_alarm
  • NetworkBundle
  • DAG
  • PDAG
  • dag_to_cpdag
  • moralize
  • mcs_order
  • fill_in
  • maximal_cliques
  • treewidth
  • shd
  • shd_skeleton
  • smhd
  • smhd_graphs
  • edge_scores
  • graph_record
  • EdgeScores
  • load_bif
  • parse_bif
  • load_xbif
  • forward_sample
  • DiscreteBN
  • CausalBaseError
  • ConfigurationError
  • CycleError
  • NotFittedError
  • API reference
  • exact_search

exact_search#

causalbase.exact.exact_search(score, initial_order=None, *, max_parents=None, time_limit=None, prune=True, verbose=False)[source]#

Find the network of highest score, or the best one under a parent limit.

Without a limit, dynamic programming over variable subsets (Silander and Myllymaki, 2006) finds the global optimum; memory grows as p 2^p, so about 27 variables fit in 32 GB. With max_parents, an integer program solved with SCIP (which needs pip install "causalbase[exact]") finds the optimum among the DAGs whose parent sets have at most max_parents variables; see causalbase.exact.ilp.

Parameters:
scoreFamilyScore

The score. BDeu, the discrete BIC, the Gaussian BIC and BGe are scored by compiled kernels on as many threads as the score’s n_jobs (the counting kernels of BDeu and the BIC on fewer than 32768 rows and at most 255 levels per variable; larger discrete data goes through the score’s own batches, more slowly). Any other score is scored family by family in Python.

initial_ordersequence of int, optional

Integer program only: a variable order whose best consistent network seeds SCIP with a first solution.

max_parentsint or None, default=None

Most parents of a node. None runs the dynamic programming.

time_limitfloat or None, default=None

Integer program only: SCIP’s time limit in seconds. The result is then the best network found, and info["status"] says whether it is proved optimal.

prunebool, default=True

Dynamic programming only: skip the parent sets that the superset bound of the score proves useless (the result is the same). BGe has no bound, so it scores every set either way.

verbosebool, default=False

Print progress per variable, and SCIP’s log.

Returns:
SearchResult

n_iter is 0 and trace holds a single entry. info holds "parents" (sorted parents per node), "n_candidates" and "n_scored" (parent sets kept and scored, per node), "max_candidate_size" (largest candidate per node), "time_scores" and "time_dp" (seconds scoring the parent sets and searching, by dynamic programming or the integer program), and, with max_parents, SCIP’s "status" (“optimal” when proved), "gap", "dual_bound" and "n_clusters" (cluster constraints added).

Raises:
ValueError

If max_parents is out of range, or, with max_parents, there are more than 64 variables.

Examples

>>> from causalbase.datasets import load_asia
>>> from causalbase.exact import exact_search
>>> from causalbase.scores import BDeuScore
>>> result = exact_search(BDeuScore(load_asia().data))
>>> result.dag.num_nodes
8
On this page
  • exact_search()
Show Source

© Copyright 2026, causalbase developers.

Built with the PyData Sphinx Theme 0.24.0.