probinet.models.acd#
Class definition of ACD, the algorithm to perform inference in networks with anomaly. The latent variables are related to community memberships and anomaly parameters [SDB22] .
Classes
|
Class definition of AnomalyDetection, the algorithm to perform inference and anomaly detection on networks with reciprocity. |
- class probinet.models.acd.AnomalyDetection(convergence_tol: float = 0.1, decision: int = 2, err: float = 0.01, err_max: float = 1e-08, num_realizations: int = 1, max_iter: int = 500, **kwargs)[source]#
Class definition of AnomalyDetection, the algorithm to perform inference and anomaly detection on networks with reciprocity.
- compute_likelihood()[source]#
Compute the log-likelihood of the data.
This is an abstract method that must be implemented in each derived class.
- fit(gdata: GraphData, ag: float = 1.5, bg: float = 10.0, pibr0: float | None = None, mupr0: float | None = None, flag_anomaly: bool = True, fix_pibr: bool = False, fix_mupr: bool = False, K: int = 3, undirected: bool = False, initialization: int = 0, assortative: bool = True, constrained: bool = False, fix_w: bool = False, fix_communities: bool = False, mask: ndarray | None = None, out_inference: bool = True, out_folder: Path = PosixPath('outputs'), end_file: str | None = None, files: PathLike | None = None, rng: Generator | None = None, **_AnomalyDetection__kwargs: Any) Tuple[ndarray, ndarray, ndarray, float, float, float] [source]#
Fit the AnomalyDetection models to the provided data.
- Parameters:
gdata – Graph adjacency tensor.
ag – Shape of gamma prior, by default 1.5.
bg – Rate of gamma prior, by default 10.0.
pibr0 – Initial value for the anomaly parameter pi, by default None.
mupr0 – Initial value for the prior mu parameter, by default None.
flag_anomaly – If True, the anomaly detection is enabled, by default True.
fix_pibr – If True, the anomaly parameter pi is fixed, by default False.
fix_mupr – If True, the prior mu parameter is fixed, by default False.
K – Number of communities, by default 3.
undirected – If True, the graph is considered undirected, by default False.
initialization – Indicator for choosing how to initialize u, v, and w, by default 0.
assortative – If True, the network is considered assortative, by default True.
constrained – If True, constraints are applied on the updates, by default False.
fix_w – If True, the affinity tensor w is fixed, by default False.
fix_communities – If True, the community memberships are fixed, by default False.
mask – Mask for selecting the held-out set in the adjacency tensor in case of cross-validation, by default None.
out_inference – If True, evaluation inference results, by default True.
out_folder – Output folder for inference results, by default “outputs/”.
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.
**kwargs – Additional parameters for the model.
- Returns:
u_f – Final out-going membership matrix.
v_f – Final in-coming membership matrix.
w_f – Final affinity tensor.
pibr_f – Final anomaly parameter pi.
mupr_f – Final prior mu parameter.
maxL – Maximum log-likelihood.