FedProxSent140#

class fl_sim.data_processing.FedProxSent140(datadir: Path | str | None = None, seed: int = 0, **extra_config: Any)[source]#

Bases: FedNLPDataset

Federated Sentiment140 dataset used in FedProx paper.

Sentiment140 dataset [1] is built from the tweets with positive and negative sentiment. FedProx [2] preprocessed the data and saved the data into json files.

Parameters:
  • datadir (Union[Path, str], optional) – Directory to store data. If None, use default directory.

  • seed (int, default 0) – Random seed for data partitioning.

  • **extra_config (dict, optional) – Extra configurations.

References

property candidate_models: Dict[str, Module]#

A set of candidate models.

property doi: List[str]#

DOIs related to the dataset.

evaluate(probs: Tensor, truths: Tensor) Dict[str, float][source]#

Evaluation using predictions and ground truth.

Parameters:
Returns:

Evaluation results.

Return type:

Dict[str, float]

get_dataloader(train_bs: int | None = None, test_bs: int | None = None, client_idx: int | None = None) Tuple[DataLoader, DataLoader][source]#

Get local dataloader at client client_idx or get the global dataloader.

Parameters:
  • train_bs (int, optional) – Batch size for training dataloader. If None, use default batch size.

  • test_bs (int, optional) – Batch size for testing dataloader. If None, use default batch size.

  • client_idx (int, optional) – Index of the client to get dataloader. If None, get the dataloader containing all data. Usually used for centralized training.

Returns:

property url: str#

URL for downloading the dataset.

view_sample(client_idx: int, sample_idx: int) None[source]#

View a sample from the dataset.

Parameters:
  • client_idx (int) – Index of the client on which the sample is located.

  • sample_idx (int) – Index of the sample in the client.

Return type:

None