fedlib.datasets.DatasetPartitioner
- class fedlib.datasets.DatasetPartitioner(num_clients, random_seed=123, client_id_generator=None)[source]
Bases:
ABCAn abstract base class for dataset splitting strategies that considers random states from both NumPy and PyTorch.
- generate_client_datasets(train_dataset, test_dataset, **kwargs)[source]
Generates client keyconcepts from two keyconcepts that may interact with each other.
- Parameters:
train_dataset – The training dataset to be split.
test_dataset – The testing dataset to be split.
- Returns:
A list of ClientDataset instances.
- Return type:
List[ClientDataset]
- generate_client_ids()[source]
Generate a list of client IDs using the specified client ID generator.
- generate_paired_subsets(train_dataset, test_dataset)[source]
Generates paired subsets from two keyconcepts that may interact with each other.
- abstract split_dataset(dataset)[source]
Split a single dataset into multiple subsets, each keyed by a unique client_id.
- abstract split_datasets(train_dataset, test_dataset)[source]
Split two keyconcepts (e.g., training and testing keyconcepts) into multiple pairs of subsets, each keyed by a unique client_id.
- Parameters:
train_dataset (Dataset) – The training dataset to be split.
test_dataset (Dataset) – The testing dataset to be split.
- Returns:
- A dictionary where the key is a string
client_id and the value is a tuple of two Subsets (training and testing).
- Return type:
Dict[str, Tuple[Subset, Subset]]
- Return type: