def test_static_graph_temporal_signal(): dataset = StaticGraphTemporalSignal(None, None, [None, None], [None, None]) for snapshot in dataset: assert snapshot.edge_index is None assert snapshot.edge_attr is None assert snapshot.x is None assert snapshot.y is None
def test_train_test_split_dynamic_graph_static_signal(): snapshot_count = 250 n_count = 100 feature_count = 32 edge_indices, edge_weights, features = generate_signal(250, 100, 32) targets = [ np.random.uniform(0, 10, (n_count, )) for _ in range(snapshot_count) ] dataset = StaticGraphTemporalSignal(edge_indices[0], edge_weights[0], features, targets) train_dataset, test_dataset = temporal_signal_split(dataset, 0.8) for epoch in range(2): for snapshot in test_dataset: assert snapshot.edge_index.shape[0] == 2 assert snapshot.edge_index.shape[1] == snapshot.edge_attr.shape[0] assert snapshot.x.shape == (100, 32) assert snapshot.y.shape == (100, ) for epoch in range(2): for snapshot in train_dataset: assert snapshot.edge_index.shape[0] == 2 assert snapshot.edge_index.shape[1] == snapshot.edge_attr.shape[0] assert snapshot.x.shape == (100, 32) assert snapshot.y.shape == (100, )
def get_dataset( self, lags: int = 4, target_var: str = "y", feature_vars: List[str] = ["y"]) -> StaticGraphTemporalSignal: """Returning the MontevideoBus passenger inflow data iterator. Parameters ---------- lags : int, optional The number of time lags, by default 4. target_var : str, optional Target variable name, by default "y". feature_vars : List[str], optional List of feature variables, by default ["y"]. Returns ------- StaticGraphTemporalSignal The MontevideoBus dataset. """ self.lags = lags self._get_edges() self._get_edge_weights() self._get_features(feature_vars) self._get_targets(target_var) dataset = StaticGraphTemporalSignal(self._edges, self._edge_weights, self.features, self.targets) return dataset
def test_static_graph_discrete_signal_typing(): dataset = StaticGraphTemporalSignal(None, None, [np.array([1])],[np.array([2])]) for snapshot in dataset: assert snapshot.edge_index is None assert snapshot.edge_attr is None assert snapshot.x.shape == (1,) assert snapshot.y.shape == (1,)
def test_static_graph_temporal_signal_additional_attrs(): dataset = StaticGraphTemporalSignal(None, None, [None], [None], optional1=[np.array([1])], optional2=[np.array([2])]) assert dataset.additional_feature_keys == ["optional1", "optional2"] for snapshot in dataset: assert snapshot.optional1.shape == (1, ) assert snapshot.optional2.shape == (1, )
def get_dataset(self, frames: int = 16) -> StaticGraphTemporalSignal: """Returning the MTM-1 motion data iterator. Args types: * **frames** *(int)* - The number of consecutive frames T, default 16. Return types: * **dataset** *(StaticGraphTemporalSignal)* - The MTM-1 dataset. """ self.frames = frames self._get_edges() self._get_edge_weights() self._get_features() self._get_targets() dataset = StaticGraphTemporalSignal(self._edges, self._edge_weights, self.features, self.targets) return dataset