Skip to content

dgf.data

dgf.data.EdgeSchema

dgf.data.EdgeSetPadding

dgf.data.FeatureFormat

Bases: Enum

How a value is represented / stored.

dgf.data.FeatureSchema

Schema for a single feature.

For GNN training, users are expected to provide the format (and possibly semantic if using auto-normalization) fields. Other fields are automatically inferred when computing feature statistics + (auto) normalization.

Attributes:

Name Type Description
format FeatureFormat

The physical format of the feature values (e.g., INTEGER, FLOAT).

semantic FeatureSemantic

The semantic meaning of the feature (e.g., NUMERICAL, CATEGORICAL).

shape Shape

The shape of the feature tensor. [] or [1] for scalar features. None if the shape is unknown--but assumed to be () in some locations. Shape values None (e.g., [None]) indicates an unknown shape. Unknown shapes are not handelled by in-memory-graphs and TF-GNN Graph Samples.

num_categorical_values Optional[int]

The number of possible categories for CATEGORICAL features. None for other semantic types or if the numeber of possible categories is unknown.

is_utf8_string Optional[bool]

Whether the feature is a UTF-8 string. This is only relevant when feature_format is BYTES, to distinguish between Spanner STRING (True) and Spanner BYTES (False).

is_timeseries bool

Whether the feature represents a temporal series / sequence.

is_creation_time bool

Whether the feature represents a creation time. For non-timeseries features (is_timeseries=False), it indicates the creation time of the node or edge entity itself. For timeseries features (is_timeseries=True), it marks the sequence as the reference timestamp sequence for all features in the same group. This information is used used in temporal neighbor sampling and for masking future information in timeseries.

group Optional[str]

Name of the sequence group this feature belongs to. All sequence features sharing the same group share the same sequence length along shape[0] and share a single optional group mask and optional group timestamp sequence.

is_static_shape

Returns true if the feature has a fully static shape.

static_size

Product of all the static dimeneions.

dgf.data.FeatureSemantic

Bases: Enum

How a value should be interpreted.

Possible values

NUMERICAL: The feature represents a numerical quantity e.g. count, amount. CATEGORICAL: The feature represents a category from a finite set of values without ordering. EMBEDDING: The feature is a dense and normalized vector embedding that can be directly consumed by a neural network. TIMESTAMP: The feature represents a timestamp. TIMEDELTA: The feature represents a time delta or time duration. TIMESERIES: The feature represents a time series of values. PRIMARY_ID: The feature represents a primary ID. MASK: The feature represents a boolean sequence padding mask. It must belong to a timeseries_group, and its shape has to be broadcastable to the features in that group.

dgf.data.FeatureSetStatistics

Statistics for a set of features.

dgf.data.FeatureStatistics

Statistics for a feature.

Attributes:

Name Type Description
count int

The number of values for the feature. For multi-dim features, each observation counts as 1.

minimum float

Minimum value. For INTERGER and FLOAT only.

maximum float

Maximum value. For INTERGER and FLOAT only.

dictionary Dictionary

Dictionary of key->(index, count). For BYTES only. Notes: Non-utf8 characters are encoded using the 'surrogateescape' method.

quantiles List[float]

Quantiles over the dataset distribution.

dgf.data.GraphFeatureStatistics

Statistics about the features in a graph.

dgf.data.GraphSchema

dgf.data.GraphSchemaFilter

Filters a GraphSchema to sub-select node sets, edge sets, and features.

A GraphSchemaFilter can be used with IO methods (when reading a graph from disk; with the schema_filter argument when available), or to operate directly on a schema (with dgf.transform.filter_schema).

Attributes:

Name Type Description
nodeset_fn Callable[[str, NodeSchema], bool]

A callable (name, schema) -> bool to filter node sets. If it returns True, keep the nodeset. Otherwise, remove it.

edgeset_fn Callable[[str, EdgeSchema], bool]

A callable (name, schema) -> bool to filter edge sets. If it returns True, keep the edgeset. Otherwise, remove it.

feature_fn Callable[[str, FeatureSchema], bool]

A callable (name, schema) -> bool to filter node OR edge features. If it returns True, keep the feature. Otherwise, remove it.

node_feature_fn Callable[[str, FeatureSchema], bool]

A callable (name, schema) -> bool to filter node features. If it returns True, keep the feature. Otherwise, remove it.

edge_feature_fn Callable[[str, FeatureSchema], bool]

A callable (name, schema) -> bool to filter edge features. If it returns True, keep the feature. Otherwise, remove it.

dgf.data.GraphSchemaV2

dgf.data.InMemoryEdgeSet

An Edge Set.

Attributes:

Name Type Description
adjacency ndarray

Array of shape [2, num_edges]. Dtype: int-like. If the graph is batched, the batch dimension is added first: [batch, num_edges].

features Features

Dictionary of edge set features. Feature values are ArrayOrAnys of shape [num_edges, ].

dgf.data.InMemoryGraph

An in-memory generic graph.

Attributes:

Name Type Description
node_sets Dict[str, InMemoryNodeSet]

Dictionary of node set name and node set features.

edge_sets Dict[str, InMemoryEdgeSet]

Dictionary of edge set name and edge set features.

dgf.data.InMemoryNodeSet

A Node Set.

Attributes:

Name Type Description
num_nodes Optional[int]

Number of nodes in the nodeset. Useful to determine the number of nodes in a nodeset without features.

features Features

Dictionary of feature names to feature values. Feature values are ArrayOrAnys of shape [num_nodes, ].

dgf.data.JaxInMemoryEdgeSet

An Edge Set.

Attributes:

Name Type Description
adjacency Array

Array of shape [2, num_edges]. Dtype: int-like. If the graph is batched, the batch dimension is added first: [batch, num_edges].

features Features

Dictionary of edge set features. Feature values are ArrayOrAnys of shape [num_edges, ...]. If the graph is batched, the batch dimension is added first: [batch, num_edges, ...].

dgf.data.JaxInMemoryGraph

An in-memory generic graph.

Attributes:

Name Type Description
node_sets Dict[str, JaxInMemoryNodeSet]

Dictionary of node set name and node set features.

edge_sets Dict[str, JaxInMemoryEdgeSet]

Dictionary of edge set name and edge set features.

dgf.data.JaxInMemoryNodeSet

A Node Set.

Attributes:

Name Type Description
features Features

Dictionary of feature names to feature values. Feature values are ArrayOrAnys of shape [num_nodes, ...]. If the graph is batched, the batch dimension is added first: [batch, num_nodes, ...].

num_nodes Optional[int]

Number of nodes in the nodeset. Useful to determine the number of nodes in a nodeset without features.

dgf.data.NodeSchema

dgf.data.NodeSetPadding

dgf.data.Padding

Information to pad a graph.

dgf.data.TFInMemoryEdgeSet

Bases: ExtensionType

An Edge Set.

Attributes:

Name Type Description
adjacency Array

Array of shape [2, num_edges]. Dtype: int-like. If the graph is batched, the batch dimension is added first: [batch, num_edges].

features Features

Dictionary of edge set features. Feature values are ArrayOrAnys of shape [num_edges, ].

dgf.data.TFInMemoryGraph

Bases: ExtensionType

An in-memory generic graph.

Attributes:

Name Type Description
node_sets Mapping[str, TFInMemoryNodeSet]

Dictionary of node set name and node set features.

edge_sets Mapping[str, TFInMemoryEdgeSet]

Dictionary of edge set name and edge set features.

dgf.data.TFInMemoryNodeSet

Bases: ExtensionType

A Node Set.

Attributes:

Name Type Description
num_nodes Union[int, Array]

Number of nodes in the nodeset. Useful to determine the number of nodes in a nodeset without features.

features Features

Dictionary of feature names to feature values. Feature values are ArrayOrAnys of shape [num_nodes, ].