File size: 684 Bytes
ba6c090
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""The bundled real-data forecasting example."""

import csv
from importlib.resources import files

import torch
from torch import Tensor


def load_example() -> Tensor:
    """Return the example's observed history as a CPU float32 tensor ``[1, 120]``.

    Forecast rows are excluded. Each call returns a new tensor. Data attribution
    and source information accompany the CSV in ``_data/NOTICE``.
    """
    with files("continuousintelligence").joinpath("_data/bike_sharing.csv").open() as stream:
        values = [
            float(row["rentals"]) for row in csv.DictReader(stream) if row["split"] == "history"
        ]
    return torch.tensor([values], dtype=torch.float32)