dgf.data
dgf.data.EdgeSchema
dgf.data.EdgeSetPadding
dgf.data.FeatureFormat
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.
|
num_categorical_values |
Optional[int]
|
The number of possible categories for CATEGORICAL
features. |
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 ( |
group |
Optional[str]
|
Name of the sequence group this feature belongs to. All sequence
features sharing the same |
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
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
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 |
edgeset_fn |
Callable[[str, EdgeSchema], bool]
|
A callable |
feature_fn |
Callable[[str, FeatureSchema], bool]
|
A callable |
node_feature_fn |
Callable[[str, FeatureSchema], bool]
|
A callable |
edge_feature_fn |
Callable[[str, FeatureSchema], bool]
|
A callable |
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
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, |