Graph Metrics API¶
Graph-specific metrics.
Contains: - compute_validation_metrics: Triplet-based validation metrics for hyperbolic embeddings - GraphEmbeddingDataset: Container for hyperbolic graph embeddings
GraphEmbeddingDataset
dataclass
¶
Container for a set of hyperbolic graph embeddings.
from_dataframe(frame, *, embedding_prefix=STAGE4_EMBEDDING_PREFIX, code_column='code', level_column='level')
classmethod
¶
Build a dataset from a parquet dataframe.
compute_validation_metrics(emb, anchors, positives, negatives, c=1.0, top_k=1, *, as_tensors=False)
¶
Compute validation metrics for hyperbolic embeddings.
Distances are computed in float64 on the CPU (see _anchor_distances). Like every distance
formula here, sqrt(c) * acosh(-
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emb
|
Tensor
|
Embeddings tensor of shape |
required |
anchors
|
Tensor
|
Anchor indices, shape |
required |
positives
|
Tensor
|
Positive indices, shape |
required |
negatives
|
Tensor
|
Negative indices, shape |
required |
c
|
float
|
Curvature parameter (default: 1.0). |
1.0
|
top_k
|
int
|
Number of top negatives to consider for auxiliary accuracy. |
1
|
as_tensors
|
bool
|
Return torch scalars instead of Python floats (for Lightning logging). |
False
|
Returns:
| Type | Description |
|---|---|
Union[Dict[str, float], Dict[str, Tensor]]
|
Mapping of metric names to values: float32 tensors on |