Skip to content

request.load

Request copies of relational datasets.

load(name, version=None, *, fold=1)

Get train/test instances of a dataset

Parameters:

Name Type Description Default
name str

Dataset name (e.g. toy_cancer)

required
version Optional[str]

Dataset version (e.g. v0.0.3)

None
fold int

In datasets with multiple folds, return this fold. This value is ignored if the data is not split into multiple folds.

1

Returns:

Type Description
Tuple[RelationalDataset, RelationalDataset]

Returns the training and test.

Raises:

Type Description
urllib.error.URLError

If the data is not in the cache and cannot be downloaded, a failed request will raise this exception.

Examples:

Load version v0.0.3 of the toy_cancer dataset:

>>> from relational_datasets import load
>>> train, test = load("toy_cancer", "v0.0.3")
>>> train.pos
['cancer(alice).', 'cancer(bob).', 'cancer(chuck).', 'cancer(fred).']
Source code in relational_datasets/request.py
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
def load(
    name: str, version: Optional[str] = None, *, fold: int = 1
) -> Tuple[RelationalDataset, RelationalDataset]:
    """Get train/test instances of a dataset

    Arguments:
        name: Dataset name (e.g. `toy_cancer`)
        version: Dataset version (e.g. `v0.0.3`)
        fold: In datasets with multiple folds, return this fold. This value is
            ignored if the data is not split into multiple folds.

    Returns:
        Returns the training and test.

    Raises:
        urllib.error.URLError: If the data is not in the cache and cannot be
            downloaded, a failed request will raise this exception.

    Examples:

    Load version ``v0.0.3`` of the ``toy_cancer`` dataset:

    ```python
    >>> from relational_datasets import load
    >>> train, test = load("toy_cancer", "v0.0.3")
    >>> train.pos
    ['cancer(alice).', 'cancer(bob).', 'cancer(chuck).', 'cancer(fred).']
    ```
    """
    data_location = fetch(name, version)
    return deserialize_zipfile(data_location, name=name, fold=fold)

Last update: June 20, 2022