FedGES#

class fedcausal.fedges.FedGES(n_rounds=10, criterion='bdeu', ess=1.0, expected_parents=1.0, penalty_discount=1.0, max_parents=None, max_t_size=None, global_fusion=None, local_fusion=None, refinement=None, convergence=None, required=None, forbidden=None, search='ges', n_jobs=None)[source]#

Learn one causal structure from data held by several sites.

Each round every site runs GES (or XGES, see search) on its own data, starting from its current model; a server fuses the sites’ structures into a global one and sends it back; each site fuses that into its own model. Only structures and scores leave the sites.

Torrijos, Gámez & Puerta, “FedGES: A Federated Learning Approach for Bayesian Network Structure Learning”, Machine Learning 115, 9 (2026).

Parameters:
n_roundsint, default=10

Most rounds to run.

criterion{“bdeu”, “bic”, “gaussian_bic”}, default=”bdeu”

Each site’s scoring criterion: BDeu or BIC over categorical data, or the BIC of a linear Gaussian model over continuous data.

essfloat, default=1.0

Equivalent sample size of the BDeu score.

expected_parentsfloat or None, default=1.0

Structure prior of each site’s score; see FamilyScore.

penalty_discountfloat, default=1.0

Multiplier of the BIC penalty.

max_parentsint or None, default=None

Most parents an Insert may give a node at a site.

max_t_sizeint or None, default=None

Largest conditioning subset tried by an Insert.

global_fusionFusionOperator, optional

How the server combines the sites’ structures. Default Consensus(50): the edges at least half the sites agree on.

local_fusionFusionOperator, optional

How a site combines the global structure with its own. Default ConsensusUnion().

refinement{“forward”, “backward”, “both”} or None, default=None

What a site does after fusing; see Site.

convergenceConvergence, optional

When to stop before n_rounds. By default, once the mean local score stops improving or every site repeats an earlier model.

required, forbiddensequence of pairs, optional

Pairs of variables, by name or column index, that must be adjacent or must not be, in every site’s model and in the global one. The direction of a required edge is still learned.

search{“ges”, “xges0”, “xges”}, default=”ges”

The search each site learns with: GES, XGES-0, or XGES; see XGES.

n_jobsint or None, default=None

Processes to spread the sites over. None or 1 runs them one after another in this process; -1, or any negative value, uses one process per site up to the number of CPUs.

Attributes:
dag_DAG

The global structure after the last round.

cpdag_PDAG

Its equivalence class.

adjacency_pandas.DataFrame

pandas.DataFrame: The global DAG as a named adjacency matrix.

site_models_list of BNModel

Each site’s own model when the rounds stopped.

n_rounds_int

Rounds run.

history_pandas.DataFrame

One row per model built: round, site (-1 for the global model), edges and score (the site’s own score; NaN for the global model).

n_features_in_int
feature_names_in_ndarray of str

Examples

>>> from fedcausal import FedGES
>>> from fedcausal.data import contiguous_split
>>> from causalbase.datasets import load_alarm
>>> sites = contiguous_split(load_alarm().data, 4)
>>> model = FedGES(n_rounds=5).fit(sites)
>>> model.dag_
DAG(num_nodes=37, num_edges=...)

Methods

fit(X[, y])

Learn the structure from the sites' data.

get_params([deep])

Return the estimator's hyperparameters by name.

set_params(**params)

Set hyperparameters by name and return the estimator.

fit(X, y=None)[source]#

Learn the structure from the sites’ data.

Parameters:
Xsequence of DiscreteDataset, ContinuousDataset, pandas.DataFrame or array-like

One table per site, all over the same variables. For the discrete criteria, levels are pooled across sites, so a level seen at one site exists at all of them.

yNone

Ignored.

Returns:
self
Raises:
TypeError

If X is a single table rather than one per site.

ValueError

If the sites hold no rows between them, disagree on their variables, or a hyperparameter is out of range.

ConvergedBeforeFusionError

If the rounds stopped before the first fusion.

property adjacency_#

pandas.DataFrame: The global DAG as a named adjacency matrix.

get_params(deep=True)#

Return the estimator’s hyperparameters by name.

set_params(**params)#

Set hyperparameters by name and return the estimator.