probinet.evaluation.link_prediction#
Functions for evaluating link prediction.
Functions
|
Calculate the F1 score for the given predictions and data. |
Calculate the AUC (Area Under the Curve) for the given ranked list of predictions. |
|
|
Calculate the AUC (Area Under the Curve) for link prediction. |
|
Calculate the AUC (Area Under the Curve) for link prediction in multilayer data. |
|
- probinet.evaluation.link_prediction.calculate_f1_score(data0: ndarray, pred: ndarray, mask: ndarray | None = None, threshold: float = 0.1) float [source]#
Calculate the F1 score for the given predictions and data.
- Parameters:
data0 (np.ndarray) – The original adjacency matrix.
pred (np.ndarray) – The predicted adjacency matrix.
mask (Optional[np.ndarray], optional) – The mask to apply on the data, by default None.
threshold (float, optional) – The threshold to binarize the predictions, by default 0.1.
- Returns:
The F1 score for the given predictions and data.
- Return type:
float
- probinet.evaluation.link_prediction.compute_AUC_from_ranked_predictions(ranked_predictions: list[tuple[float, int]], num_positive_samples: int, num_negative_samples: int) float [source]#
Calculate the AUC (Area Under the Curve) for the given ranked list of predictions.
- Parameters:
ranked_predictions (list[tuple[float, int]]) – The ranked list of predictions, where each tuple contains a score and the actual value.
num_positive_samples (int) – The number of positive samples.
num_negative_samples (int) – The number of negative samples.
- Returns:
The AUC value for the ranked predictions.
- Return type:
float
- probinet.evaluation.link_prediction.compute_link_prediction_AUC(data0: ndarray, pred: ndarray, mask: ndarray | None = None) float [source]#
Calculate the AUC (Area Under the Curve) for link prediction.
- Parameters:
data0 (np.ndarray) – The original adjacency matrix.
pred (np.ndarray) – The predicted adjacency matrix.
mask (Optional[np.ndarray], optional) – The mask to apply on the data, by default None.
- Returns:
The AUC value for the link prediction.
- Return type:
float
- probinet.evaluation.link_prediction.compute_multilayer_link_prediction_AUC(B: ndarray, u: ndarray, v: ndarray, w: ndarray, mask: ndarray | None = None) float [source]#
Calculate the AUC (Area Under the Curve) for link prediction in multilayer data.
- Parameters:
B (np.ndarray) – The original adjacency tensor.
u (np.ndarray) – The first factor matrix.
v (np.ndarray) – The second factor matrix.
w (np.ndarray) – The third factor matrix.
mask (Optional[np.ndarray], optional) – The mask to apply on the data, by default None.
- Returns:
The AUC value for the link prediction in multilayer data.
- Return type:
float
- probinet.evaluation.link_prediction.mask_or_flatten_array(mask: ndarray | None, expected_adjacency: ndarray) ndarray [source]#
- probinet.evaluation.link_prediction.mask_or_flatten_array(mask: None, expected_adjacency: ndarray) ndarray
- probinet.evaluation.link_prediction.mask_or_flatten_array(mask: ndarray, expected_adjacency: ndarray) ndarray