In [ ]:
edge_index = distance_matrix[distance_matrix["edge"] == True][["start_station_id", "end_station_id"]].values
edge_index = edge_index.transpose()
distance_feature = distance_matrix[distance_matrix["edge"] == True]["distance"].values
edge_type_feature = np.zeros_like(distance_feature)
trip_duration_feature = np.zeros_like(distance_feature)
static_edge_features = np.stack([distance_feature, edge_type_feature, trip_duration_feature]).transpose()
In [ ]:
def extract_dynamic_edges(s):
trip_indices = s[["start_station_id", "end_station_id"]].values
trip_durations = s["duration"]
distance_feature = pd.DataFrame(trip_indices,
columns=["start_station_id", "end_station_id"]).merge(
distance_matrix, on=["start_station_id", "end_station_id"],
how="left")["distance"].values
edge_type_feature = np.ones_like(distance_feature)
trip_duration_feature = trip_durations
edge_features = np.stack([distance_feature, edge_type_feature, trip_duration_feature]).transpose()
return edge_features, trip_indices.transpose()