SquarePartitioner#
- class SquarePartitioner(num_partitions: int)[source]#
Bases:
SizePartitioner
Partitioner creates partitions of size that are correlated with squared id.
The amount of data each client gets is correlated with the squared partition ID. For instance, if the IDs range from 1 to M, client with ID 1 gets 1 unit of data, client 2 gets 4 units, and so on, up to client M which gets M^2 units.
- Parameters:
num_partitions (int) – The total number of partitions that the data will be divided into.
Methods
Check if a dataset has been assigned to the partitioner.
load_partition
(partition_id)Load a single partition based on the partition index.
Attributes
Dataset property.
Total number of partitions.
Node id to the list of indices.
Node id to the number of samples.
- property dataset: Dataset#
Dataset property.
- is_dataset_assigned() bool #
Check if a dataset has been assigned to the partitioner.
This method returns True if a dataset is already set for the partitioner, otherwise, it returns False.
- Returns:
dataset_assigned – True if a dataset is assigned, otherwise False.
- Return type:
bool
- load_partition(partition_id: int) Dataset #
Load a single partition based on the partition index.
The number of samples is dependent on the partition partition_id.
- Parameters:
partition_id (int) – the index that corresponds to the requested partition
- Returns:
dataset_partition – single dataset partition
- Return type:
Dataset
- property num_partitions: int#
Total number of partitions.
- property partition_id_to_indices: Dict[int, List[int]]#
Node id to the list of indices.
- property partition_id_to_size: Dict[int, int]#
Node id to the number of samples.