Metrics
Link prediction and ranking metrics (mlx_graphs.metrics, as
torch_geometric.metrics). They are computed on the host with NumPy from
MLX or NumPy arrays, accumulate over mini-batches with update and return a
scalar mx.array from compute.
Functions
Function
Description
roc_auc_score()
Area under the ROC curve of binary labels ranked by scores.
average_precision_score()
Average precision of binary labels ranked by scores.
tgb_mrr_hits()
MRR and Hits@k of positive scores ranked against their negative scores, as TGB.
tgb_ndcg()
NDCG@k of the predicted scores of each node over the classes, averaged over the nodes, as TGB (sklearn.metrics.ndcg_score(y_true, y_pred, k=k)).
Link prediction metrics
Class
Description
LinkPredMetric
Base class of the link prediction metrics averaged over the examples with at least one ground-truth label.
LinkPredMetricCollection
A collection of link prediction metrics updated together.
LinkPredMetricData
The predictions and ground truth of a mini-batch, with the quantities shared by the link prediction metrics.
LinkPredPrecision
Precision @ \(k\) : the proportion of the top-\(k\) recommendations that are relevant.
LinkPredRecall
Recall @ \(k\) : the proportion of the relevant items that appear in the top-\(k\) recommendations.
LinkPredF1
F1 @ \(k\) , the harmonic mean of precision and recall @ \(k\) .
LinkPredMAP
MAP @ \(k\) (Mean Average Precision), which accounts for the order of the relevant items in the top-\(k\) .
LinkPredNDCG
NDCG @ \(k\) (Normalized Discounted Cumulative Gain), which gives more weight to relevant items ranked higher.
LinkPredMRR
MRR @ \(k\) (Mean Reciprocal Rank): the reciprocal rank of the first relevant item of the top-\(k\) , or zero.
LinkPredHitRatio
Hit ratio @ \(k\) : the proportion of examples with at least one relevant item in the top-\(k\) .
LinkPredCoverage
Coverage @ \(k\) : the proportion of the destination nodes that appear in at least one top-\(k\) recommendation.
LinkPredDiversity
Diversity @ \(k\) of the recommendations according to item categories,
LinkPredPersonalization
Personalization @ \(k\) : the dissimilarity of the recommendations of different examples (the average of 1 - overlap / k over all pairs of examples).
LinkPredAveragePopularity
Average Recommendation Popularity @ \(k\) : the average popularity of the recommended items.
TGBEvaluator
The evaluator of a Temporal Graph Benchmark dataset, with the same interface and results as py-tgb's Evaluator classes.