METRLADataLoader

class stgraph.dataset.METRLADataLoader(verbose: bool = False, num_timesteps_in: int = 12, num_timesteps_out: int = 12, cutoff_time: int | None = None, redownload: bool = False)[source]

Bases: STGraphTemporalDataset

Traffic forecasting dataset based on the Los Angeles city.

A dataset for predicting traffic patterns in the Los Angeles Metropolitan area, comprising traffic data obtained from 207 loop detectors on highways in Los Angeles County. The dataset includes aggregated 5-minute interval readings spanning a four-month period from March 2012 to June 2012.

This class provides functionality for loading, processing, and accessing the METRLA dataset for use in deep learning tasks such as traffic forecasting.

gdata

num_nodes

num_edges

total_timestamps

207

1722

100

Example

from stgraph.dataset import METRLADataLoader

metrla = METRLADataLoader(verbose=True)
num_nodes = metrla.gdata["num_nodes"]
num_edges = metrla.gdata["num_edges"]
total_timestamps = metrla.gdata["total_timestamps"]

edge_list = metrla.get_edges()
edge_weights = metrla.get_edge_weights()
feats = metrla.get_all_features()
targets = metrla.get_all_targets()
Parameters:
  • verbose (bool, optional) – Flag to control whether to display verbose info (default is False)

  • num_timesteps_in (int, optional) – The number of timesteps the sequence model sees (default is 12)

  • num_timesteps_out (int, optional) – The number of timesteps the sequence model has to predict (default is 12)

  • cutoff_time (int, optional) – The cutoff timestamp for the temporal dataset (default is None)

  • redownload (bool, optional (default is False)) – Redownload the dataset online and save to cache

name

The name of the dataset.

Type:

str

gdata

Graph meta data.

Type:

dict

get_all_features() ndarray[source]

Return the features for each timestamp.

get_all_targets() ndarray[source]

Return the targets for each timestamp.

get_edge_weights() ndarray[source]

Return the edge weights.

get_edges() list[source]

Return the edge list.