RelationalSampler#

class sdm.relational.RelationalSampler(data: RelationalData, time_columns: Mapping[str, str] | None = None)#

Bases: object

Subgraph sampler over relational data.

Parameters:
  • data (RelationalData) – The collection of named tables and their relationships.

  • time_columns (Mapping[str, str] | None) – Mapping from table name to the datetime column used for temporal sampling. A row in a time-aware table can only be sampled if its timestamp does not exceed the query timestamp.

sample(task_table: TableTensor, task_link: TaskLink | Mapping[str, str | Sequence[str]], num_neighbors: Sequence[int], task_time_column: str | None = None, temporal_strategy: Literal['last', 'uniform'] = 'last') → RelationalSamplerOutput#

Sample RelatedTables for task rows.

Parameters:
  • task_table (TableTensor) – Task table whose rows define the sampling queries.

  • task_link (TaskLink | Mapping[str, str | Sequence[str]]) – Link from task_table rows to a table in the relational data.

  • num_neighbors (Sequence[int]) – Number of neighbors to sample per hop.

  • task_time_column (str | None) – Datetime column in task_table used as the query timestamp for temporal sampling.

  • temporal_strategy (Literal['last', 'uniform']) – How temporal neighbors are selected. "last" selects the most recent neighbors before each seed timestamp. "uniform" samples uniformly from neighbors before each seed timestamp. CUDA sampling currently falls back from "last" to "uniform" with a warning.

Return type:

RelationalSamplerOutput