Skip to content

Benchmark Datasets

Pre-configured DataLoader factories for identibench benchmark datasets.

create_dls_downl

create_dls_downl(u: list[str], y: list[str], dataset: Path | str | None = None, download_function=None, **kwargs) -> DataLoaders

Create DataLoaders, downloading the dataset first if needed.

Parameters:

Name Type Description Default
u list[str]

list of input signal names

required
y list[str]

list of output signal names

required
dataset Path | str | None

path to the dataset directory

None
download_function

callable that downloads the dataset to a given path

None
Source code in tsfast/tsdata/benchmark.py
def create_dls_downl(
    u: list[str],
    y: list[str],
    dataset: Path | str | None = None,
    download_function=None,
    **kwargs,
) -> DataLoaders:
    """Create DataLoaders, downloading the dataset first if needed.

    Args:
        u: list of input signal names
        y: list of output signal names
        dataset: path to the dataset directory
        download_function: callable that downloads the dataset to a given path
    """
    if dataset is None and download_function is not None:
        dataset = _get_dataset_path() / download_function.__name__
    elif dataset is not None:
        dataset = Path(dataset)
    else:
        raise ValueError("Must provide either dataset path or download_function")

    if not is_dataset_directory(dataset):
        if download_function is not None:
            print(f'Dataset not found. Downloading it to "{dataset}"')
            download_function(dataset)
        else:
            raise ValueError(f"{dataset} does not contain a dataset. Check the path or activate the download flag.")

    return create_dls(u=u, y=y, dataset=dataset, **kwargs)

create_dls_from_spec

create_dls_from_spec(spec: BenchmarkSpecBase, **kwargs) -> DataLoaders

Create DataLoaders from an identibench benchmark specification.

Parameters:

Name Type Description Default
spec BenchmarkSpecBase

benchmark specification from identibench

required
Source code in tsfast/tsdata/benchmark.py
def create_dls_from_spec(
    spec: idb.benchmark.BenchmarkSpecBase,
    **kwargs,
) -> DataLoaders:
    """Create DataLoaders from an identibench benchmark specification.

    Args:
        spec: benchmark specification from identibench
    """
    spec_kwargs = {
        "u": spec.u_cols,
        "y": spec.y_cols,
        "download_function": spec.download_func,
        "dataset": spec.dataset_path,
    }

    # Prediction specs: in Phase 1 we only handle the window sizing, not the
    # actual prediction input concatenation (deferred to Phase 3).
    if isinstance(spec, idb.benchmark.BenchmarkSpecPrediction):
        spec_kwargs.update(
            {
                "win_sz": spec.pred_horizon + spec.init_window,
                "valid_stp_sz": spec.pred_step,
            }
        )

    if spec.name in BENCHMARK_DL_KWARGS:
        spec_kwargs.update(BENCHMARK_DL_KWARGS[spec.name])

    dl_kwargs = {**spec_kwargs, **kwargs}
    return create_dls_downl(**dl_kwargs)