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
  • order_search

order_search#

causalbase.order.order_search(score, initial_order=None, *, polish='ges', n_restarts=2, n_pair_candidates=0, n_swaps=None, max_iter=None, time_limit=None, random_state=None, cache_mb=2048)[source]#

Learn a network by iterated local search over orders, each local search polished by GES.

A local search climbs over orders by insertion moves, scoring each order by the best network consistent with it (OrderScorer, a greedy climb per node), and ends with GES (or XGES) started from that network, so that arcs the order forbids can still be added. Each iteration kicks the best network found so far (a random topological order of it, half the time with n_swaps random transpositions), runs a local search from there, and keeps the result if it scores at least as well.

Parameters:
scoreFamilyScore

The score: BDeu with either prior, BIC, Gaussian BIC or BGe. Orders and networks are scored with it (with its compiled engine for BDeu); GES and XGES search it as ges() does.

initial_ordersequence of int, optional

Order the first local search starts from. By default a topological order of the network GES learns on the same score, learned before the time limit starts.

polish{“ges”, “xges”}, default=”ges”

Search over equivalence classes that ends each local search.

n_restartsint, default=2

Extra greedy climbs per node in the order evaluator, each without the first parent the previous climb chose (see OrderScorer).

n_pair_candidatesint, default=0

When positive, each local search also tries adding pairs of parents drawn from this many best single candidates (pair_polish()), and polishes again if that added any.

n_swapsint or None, default=None

Transpositions of a kick; ceil(ln p) for p variables when None.

max_iterint or None, default=None

Kicks, each followed by a local search, after the first local search.

time_limitfloat or None, default=None

Seconds of search, checked inside the local searches too. At least one of max_iter and time_limit must be set.

random_stateint or None, default=None

Seeds every random choice; None draws a fresh seed. With an integer and max_iter (and no time limit) the result is reproducible.

cache_mbfloat or None, default=2048

Memory budget of the order evaluator’s caches, in MiB (see OrderScorer); None leaves them unbounded. The search does not change, a tight budget only slows it down.

Returns:
SearchResult

n_iter counts the kicks; info["accepted"] those whose local search scored at least as well as the best, which then moved there.

Raises:
ValueError

If neither limit is set, or an option is out of range.

Examples

>>> from causalbase.datasets import load_asia
>>> from causalbase.order import order_search
>>> from causalbase.scores import BDeuScore
>>> result = order_search(BDeuScore(load_asia().data), max_iter=3, random_state=0)
>>> result.n_iter
3
On this page
  • order_search()
Show Source

© Copyright 2026, causalbase developers.

Built with the PyData Sphinx Theme 0.24.0.