TGBEvaluator
¶
The evaluator of a Temporal Graph Benchmark dataset, with the same
interface and results as py-tgb's Evaluator classes.
- Link property prediction (
tgbl-*,thgl-*,tkgl-*): each positive edge is ranked against its negative edges (one-vs-many) and the metrics are the mean reciprocal rank"mrr"and"hits@k"(seetgb_mrr_hits()). Inputs:"y_pred_pos"of shape[num_pos]and"y_pred_neg"of shape[num_pos, num_neg]. - Node property prediction (
tgbn-*):"ndcg"is the NDCG@10 of the predicted class scores (seetgb_ndcg()),"mse"also returns"rmse". Inputs:"y_true"and"y_pred"of shape[num_nodes, num_classes].
Inputs can be MLX or NumPy arrays (or torch tensors).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the TGB dataset, e.g. |
required |
k_value
|
int
|
The |
10
|
Example:
from mlx_graphs.metrics import TGBEvaluator
evaluator = TGBEvaluator("tgbl-wiki")
evaluator.eval(
{"y_pred_pos": pos_scores, "y_pred_neg": neg_scores,
"eval_metric": ["mrr"]}
)
>>> {"hits@10": 0.83, "mrr": 0.61}
References
Methods:
| Name | Description |
|---|---|
eval |
Computes the metrics. |
Source code in mlx_graphs/metrics/tgb.py
eval
¶
Computes the metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dict
|
dict
|
The predictions (see the class description) and
|
required |
verbose
|
bool
|
Whether to print the metrics |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary of metric values (floats). |
Source code in mlx_graphs/metrics/tgb.py
from mlx_graphs.metrics import TGBEvaluator · mlx_graphs/metrics/tgb.py