LinkPredMetricCollection
¶
A collection of link prediction metrics updated together.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
Union[List[_LinkPredMetric], Dict[str, _LinkPredMetric]]
|
A list of metrics (named |
required |
Example:
from mlx_graphs.metrics import (
LinkPredMAP,
LinkPredMetricCollection,
LinkPredPrecision,
LinkPredRecall,
)
metrics = LinkPredMetricCollection(
[
LinkPredMAP(k=10),
LinkPredPrecision(k=100),
LinkPredRecall(k=50),
]
)
metrics.update(pred_index_mat, edge_label_index)
out = metrics.compute() # {"LinkPredMAP@10": ..., ...}
metrics.reset()
Methods:
| Name | Description |
|---|---|
update |
Updates all metrics with a mini-batch of predictions (see |
compute |
Returns the value of every metric. |
reset |
Resets all metrics. |
Attributes:
| Name | Type | Description |
|---|---|---|
max_k |
int
|
The largest \(k\) of the metrics. |
weighted |
bool
|
Whether the collection has a weighted metric. |
Source code in mlx_graphs/metrics/link_pred.py
update
¶
update(
pred_index_mat: ArrayLike,
edge_label_index: EdgeLabelIndex,
edge_label_weight: Optional[ArrayLike] = None,
)
Updates all metrics with a mini-batch of predictions (see
LinkPredMetric.update()). Ground-truth pairs with non-positive
weights are dropped for all metrics, as in PyG.
Source code in mlx_graphs/metrics/link_pred.py
compute
¶
from mlx_graphs.metrics import LinkPredMetricCollection · mlx_graphs/metrics/link_pred.py