probinet.evaluation.expectation_computation#
Functions for computing expectations and related metrics.
Functions
|
Compute the dense Q matrix for the given adjacency tensor and parameters. |
|
Compute the normalization constant of the Bivariate Bernoulli distribution. |
|
Calculates the conditional expectation of a given set of parameters. |
Calculate the conditional expectation for given dynamic representation. |
|
|
Compute the expectations for the marginal distribution. |
|
Calculate the expectation for the adjacency tensor with an additional covariate. |
|
Calculate the L1 loss between two matrices. |
|
Return the vectors of joint probabilities of every pair of edges. |
|
Compute the expected value of the adjacency tensor. |
Compute the expected value of the adjacency tensor for multi-covariate data. |
|
|
Function to calculate the value of the Lagrange multiplier. |
Return the marginal and conditional expected value. |
|
|
Compute the mean lambda0 for all entries. |
|
Compute the mean lambda0 for all entries for dynamic reciprocity. |
|
Compute the mean lambda0_ij for only non-zero entries. |
|
Function to update the membership matrix 'u' using the Lagrange multiplier. |
- probinet.evaluation.expectation_computation.calculate_Q_dense(A: ndarray, M: ndarray, pi: float, mu: float, mask: ndarray | None = None, EPS: float = 1e-12) ndarray [source]#
Compute the dense Q matrix for the given adjacency tensor and parameters.
- Parameters:
A (np.ndarray) – Adjacency tensor.
M (np.ndarray) – Mean adjacency tensor.
pi (float) – Poisson parameter.
mu (float) – Mixing parameter.
mask (Optional[np.ndarray]) – Mask for selecting a subset of the adjacency tensor.
EPS (float) – Small constant to avoid division by zero.
- Returns:
Dense Q matrix.
- Return type:
np.ndarray
- probinet.evaluation.expectation_computation.calculate_Z(lambda0_aij: ndarray, eta: float) ndarray [source]#
Compute the normalization constant of the Bivariate Bernoulli distribution.
- probinet.evaluation.expectation_computation.calculate_conditional_expectation(B: ndarray, u: ndarray, v: ndarray, w: ndarray, eta: float, mean: ndarray | None = None) ndarray [source]#
Calculates the conditional expectation of a given set of parameters.
This function computes the conditional expectation of a multivariate random process based on the provided inputs. It incorporates a scaling parameter (eta) and optionally a mean tensor to compute the result. If the mean tensor is not provided, it defaults to computing a mean based on the input parameters u, v, and w.
- Parameters:
B – A 3-dimensional tensor used in the computation of the weighted mean. The tensor represents the relationship between variables in the multivariate process.
u – A 1-dimensional array representing the first set of variables contributing to the computation of the mean. Typically corresponds to a principal factor in the model.
v – A 1-dimensional array representing the second set of variables contributing to the computation of the mean. It complements the u array in forming the joint distribution.
w – A 1-dimensional array representing the third set of variables interacting with u and v to establish a comprehensive measure of centrality in the model.
eta – A scaling parameter applied to the tensor factors to adjust their weighted contribution to the overall mean measure of expectations.
mean – A precomputed 3-dimensional tensor mean to override the default computed mean. If None, the mean will be computed using u, v, and w.
- Returns:
A 3-dimensional tensor that represents the computed conditional expectation given the provided parameters. The tensor provides a context-sensitive measure of expectation, calculated as either a default weighted mean or incorporating a provided precomputed mean.
- Return type:
np.ndarray
- probinet.evaluation.expectation_computation.calculate_conditional_expectation_dyncrep(B_to_T: COO | ndarray, u: ndarray, v: ndarray, w: ndarray, eta: float = 0.0, beta: float = 1.0) ndarray [source]#
Calculate the conditional expectation for given dynamic representation.
This function computes the conditional expectation based on the dynamic representation of the input data, including arrays and graph-based data. It utilizes transformation and normalization techniques such as matrix transposition and scaling.
- Parameters:
B_to_T (GraphDataType) – Graph-based data structure representing relationships or transitions between nodes or states.
u (np.ndarray) – Input array representing data points or state variables.
v (np.ndarray) – Input array representing another set of data points or state variables related to u.
w (np.ndarray) – Auxiliary input array used for reference in the calculation.
eta (float, optional) – Scaling factor applied to the graph transformation. Default is 0.0.
beta (float, optional) – Scaling factor applied in the normalization computation. Default is 1.0.
- Returns:
Array representing the computed conditional expectation after applying the dynamic representation transformations.
- Return type:
np.ndarray
- probinet.evaluation.expectation_computation.calculate_expectation(u: ndarray, v: ndarray, w: ndarray, eta: float) ndarray [source]#
Compute the expectations for the marginal distribution.
- probinet.evaluation.expectation_computation.calculate_expectation_acd(U: ndarray, V: ndarray, W: ndarray, Q: ndarray, pi: float = 1) ndarray [source]#
Calculate the expectation for the adjacency tensor with an additional covariate.
- probinet.evaluation.expectation_computation.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.expectation_computation.compute_M_joint(U: ndarray, V: ndarray, W: ndarray, eta: float) list [source]#
Return the vectors of joint probabilities of every pair of edges.
- probinet.evaluation.expectation_computation.compute_expected_adjacency_tensor(U: ndarray, V: ndarray, W: ndarray) ndarray [source]#
Compute the expected value of the adjacency tensor.
- probinet.evaluation.expectation_computation.compute_expected_adjacency_tensor_multilayer(u: ndarray, v: ndarray, w: ndarray) ndarray [source]#
Compute the expected value of the adjacency tensor for multi-covariate data.
- probinet.evaluation.expectation_computation.compute_lagrange_multiplier(lambda_i: float, num: float, den: float) float [source]#
Function to calculate the value of the Lagrange multiplier.
- probinet.evaluation.expectation_computation.compute_marginal_and_conditional_expectation(B: ndarray, U: ndarray, V: ndarray, W: ndarray, eta: float) tuple [source]#
Return the marginal and conditional expected value.
- probinet.evaluation.expectation_computation.compute_mean_lambda0(u: ndarray, v: ndarray, w: ndarray) ndarray [source]#
Compute the mean lambda0 for all entries.
- probinet.evaluation.expectation_computation.compute_mean_lambda0_dyncrep(u: ndarray, v: ndarray, w: ndarray) ndarray [source]#
Compute the mean lambda0 for all entries for dynamic reciprocity.