contiguous_split#

fedcausal.data.contiguous_split(ds, n_clients)[source]#

Split a dataset into contiguous row blocks, in original order.

Client c gets rows ceil(c * n / N) up to ceil((c + 1) * n / N), so concatenating the blocks in order rebuilds the dataset. The remainder is spread across the blocks: n=10, N=4 gives sizes [3, 2, 3, 2].

Parameters:
dsDiscreteDataset or ContinuousDataset

The dataset to split.

n_clientsint

Number of clients (blocks) to produce. Must be positive.

Returns:
list[DiscreteDataset] or list[ContinuousDataset]

n_clients datasets over the same variables as ds. If n_clients exceeds ds.n_rows, some blocks are empty.

Raises:
ValueError

If n_clients is not positive.