Skip to main content
Ctrl+K
probinet  documentation - Home

Contents

  • API
    • probinet.evaluation
    • probinet.evaluation.community_detection
    • probinet.evaluation.covariate_prediction
    • probinet.evaluation.expectation_computation
    • probinet.evaluation.likelihood
    • probinet.evaluation.link_prediction
    • probinet.input
    • probinet.input.loader
    • probinet.input.preprocessing
    • probinet.input.stats
    • probinet.main
    • probinet.model_selection
    • probinet.model_selection.acd_cross_validation
    • probinet.model_selection.crep_cross_validation
    • probinet.model_selection.cross_validation
    • probinet.model_selection.dyncrep_cross_validation
    • probinet.model_selection.jointcrep_cross_validation
    • probinet.model_selection.main
    • probinet.model_selection.masking
    • probinet.model_selection.mtcov_cross_validation
    • probinet.model_selection.parameter_search
    • probinet.models
    • probinet.models.acd
    • probinet.models.base
    • probinet.models.classes
    • probinet.models.constants
    • probinet.models.crep
    • probinet.models.dyncrep
    • probinet.models.jointcrep
    • probinet.models.mtcov
    • probinet.synthetic
    • probinet.synthetic.anomaly
    • probinet.synthetic.base
    • probinet.synthetic.dynamic
    • probinet.synthetic.multilayer
    • probinet.synthetic.reciprocity
    • probinet.utils
    • probinet.utils.matrix_operations
    • probinet.utils.tools
    • probinet.version
    • probinet.visualization
    • probinet.visualization.plot

First Steps

  • Inputs and Outputs

Tutorials

  • A Beginner's Guide To The MTCOV Algorithm In The Probinet Package
  • Generation Of Synthetic Networks Using The CRep Algorithm
  • Analysis Of A Real-World Dataset Using The JointCRep Algorithm
  • Decoding Temporal Relationships With DynCRep
  • Cross-Validation And Anomaly Detection With The ACD Algorithm
  • Analyzing Network Data With Unknown Community Structure

Contributing

  • How To Contribute

References

  • Bibliography
  • .rst

probinet.evaluation.link_prediction

Contents

  • calculate_f1_score()
  • compute_AUC_from_ranked_predictions()
  • compute_L1loss()
  • compute_link_prediction_AUC()
  • compute_multilayer_link_prediction_AUC()
  • mask_or_flatten_array()

probinet.evaluation.link_prediction#

Functions for evaluating link prediction.

Functions

calculate_f1_score(data0, pred[, mask, ...])

Calculate the F1 score for the given predictions and data.

compute_AUC_from_ranked_predictions(...)

Calculate the AUC (Area Under the Curve) for the given ranked list of predictions.

compute_L1loss(X, Xtilde)

Calculate the L1 loss between two matrices.

compute_link_prediction_AUC(data0, pred[, mask])

Calculate the AUC (Area Under the Curve) for link prediction.

compute_multilayer_link_prediction_AUC(B, u, ...)

Calculate the AUC (Area Under the Curve) for link prediction in multilayer data.

mask_or_flatten_array(-> ~numpy.ndarray)

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_L1loss(X: ndarray, Xtilde: ndarray) → float[source]#

Calculate the L1 loss between two matrices.

Parameters:
  • X (np.ndarray) – The first matrix.

  • Xtilde (np.ndarray) – The second matrix to compare against the first matrix.

Returns:

The L1 loss between the two matrices, rounded to three decimal places.

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

previous

probinet.evaluation.likelihood

next

probinet.input

Contents
  • calculate_f1_score()
  • compute_AUC_from_ranked_predictions()
  • compute_L1loss()
  • compute_link_prediction_AUC()
  • compute_multilayer_link_prediction_AUC()
  • mask_or_flatten_array()

By Diego Baptista Theuerkauf

© Copyright 2024, Max Planck Society / Software Workshop - Max Planck Institute for Intelligent Systems.