probinet.models.crep#
Class definition of CRep, the algorithm to perform inference in networks with reciprocity. The latent variables are related to community memberships and reciprocity value [SCDB21].
Classes
|
Class to perform inference in networks with reciprocity. |
- class probinet.models.crep.CRep(max_iter: int = 1000, num_realizations: int = 5, **kwargs: Any)[source]#
Class to perform inference in networks with reciprocity.
- check_params_to_load_data(**kwargs)[source]#
Check that the parameters to load the data are correct.
- compute_likelihood() float [source]#
Compute the pseudo log-likelihood of the data.
- Returns:
loglik – Pseudo log-likelihood value.
- Return type:
float
- fit(gdata: GraphData, K: int = 3, mask: ndarray | None = None, initialization: int = 0, eta0: float | None = None, undirected: bool = False, assortative: bool = True, constrained: bool = True, out_inference: bool = True, fix_eta: bool = False, fix_w: bool = False, out_folder: Path = PosixPath('outputs'), end_file: str | None = None, files: PathLike | None = None, rng: Generator | None = None, **_kwargs: Any) tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]], float, float] [source]#
Model directed networks by using a probabilistic generative model based on a Poisson distribution and a pseudo-likelihood approximation. It assumes communities and reciprocity as main mechanisms for tie formation. The inference is performed via the EM algorithm.
- Parameters:
gdata – Graph adjacency tensor.
K – Number of communities, by default 3.
mask – Mask for selecting the held-out set in the adjacency tensor in case of cross-validation, by default None.
initialization – Initialization method for the models parameters, by default 0.
eta0 – Initial value of the reciprocity coefficient, by default None.
undirected – Flag to call the undirected network, by default False.
assortative – Flag to call the assortative network, by default True.
constrained – Flag to specify if the model is constrained, by default True.
out_inference – Flag to evaluate inference results, by default True.
fix_eta – Flag to fix the eta parameter, by default False.
fix_w – Flag to fix the affinity tensor, by default False.
out_folder – Output folder for inference results, by default OUTPUT_FOLDER.
end_file – Suffix for the evaluation file, by default None.
files – Path to the file for initialization, by default None.
rng – Random number generator, by default None.
- Returns:
u_f – Out-going membership matrix.
v_f – In-coming membership matrix.
w_f – Affinity tensor.
eta_f – Reciprocity coefficient.
maxL – Maximum pseudo log-likelihood.