torch_geometric.metrics.LinkPredPrecision
- class LinkPredPrecision(k: int)[source]
Bases:
LinkPredMetric一个用于计算精确度 @ \(k\) 的链接预测指标。
- Parameters:
k (int) – The number of top-\(k\) predictions to evaluate against.
- update(pred_index_mat: Tensor, edge_label_index: Union[Tensor, Tuple[Tensor, Tensor]]) None
根据当前小批量预测更新状态变量。
update()can be repeated multiple times to accumulate the results of successive predictions, e.g., inside a mini-batch training or evaluation loop.- Parameters:
pred_index_mat (torch.Tensor) – The top-\(k\) predictions of every example in the mini-batch with shape
[batch_size, k].edge_label_index (torch.Tensor) – The ground-truth indices for every example in the mini-batch, given in COO format of shape
[2, num_ground_truth_indices].
- Return type: