gossipy.data module#
Submodules#
Module contents#
This module contains functions and classes to manage datasets loading and dispatching.
- class gossipy.data.DataHandler#
Bases:
abc.ABC
Abstract class for data handlers.
A
DataHandler
class provides attributes and methods to manage a dataset. A subclass ofDataHandler
must implement the following methods:__getitem__()
- abstract at(idx, eval_set=False)#
Get a sample (or samples) from the training/test set.
- abstract eval_size()#
Get the number of examples of the evaluation set.
- Returns
The size of the evaluation set of the dataset.
- Return type
- abstract get_eval_set()#
Get the evaluation set of the dataset.
- Returns
The evaluation set of the dataset.
- Return type
tuple[Any, Any]
- gossipy.data.get_CIFAR10(path='./data', as_tensor=True)#
Returns the CIFAR10 dataset.
The method downloads the dataset if it is not already present in path.
- gossipy.data.get_FashionMNIST(path='./data', as_tensor=True)#
Returns the FashionMNIST dataset.
The method downloads the dataset if it is not already present in path.
- gossipy.data.load_classification_dataset(name_or_path, normalize=True, as_tensor=True)#
Loads a classification dataset.
A dataset can be loaded from svmlight file or can be one of the following: iris, breast, digits, wine, reuters, spambase, sonar, ionosphere, abalone, banknote.
- Parameters
- Returns
A tuple containing the data and the labels with the specified type.
- Return type
tuple[torch.Tensor, torch.Tensor] or tuple[np.ndarray, np.ndarray]
- gossipy.data.load_recsys_dataset(name, path='.')#
Load a recsys dataset.
Currently, only the following datasets are supported: ml-100k, ml-1m, ml-10m and ml-20m.
- Parameters
- Returns
A tuple contining the ratings, the number of users and the number of items. Ratings are represented as a dictionary mapping user ids to a list of tuples (item id, rating).
- Return type