MMSBM Functions
- functions.MMSBM_functions.omega_comp_arrays(Na, Nb, p_kl, theta, eta, K, L, links_array, links_ratings)[source]
Computes the omega matrix for a bipartite network.
- Parameters:
Na (int) – Number of nodes in layer a
Nb (int) – Number of nodes in layer b
p_kl (np.array) – Probability matrix between groups k and l
theta (np.array) – Membership matrix for layer a
eta (np.array) – Membership matrix for layer b
K (int) – Number of groups in layer a
L (int) – Number of groups in layer b
links_array (np.array) – Array containing the links between nodes
links_ratings (np.array) – Array containing the ratings/labels for each link
- Returns:
The computed omega matrix of shape (Na, Nb, K, L)
- Return type:
np.array
- functions.MMSBM_functions.omega_comp_arrays_exclusive(q_ka, N_att, theta, N_nodes, K, metas_links_arrays_nodes)[source]
Computes the omega matrix for exclusive metadata.
- Parameters:
q_ka (np.array) – Probability matrix between groups k and attributes a
N_att (int) – Number of attributes
theta (np.array) – Membership matrix for nodes
N_nodes (int) – Number of nodes
K (int) – Number of groups
metas_links_arrays_nodes (np.array) – Array containing the links between nodes and metadata
- Returns:
The computed omega matrix of shape (N_nodes, N_att, K)
- Return type:
np.array
- functions.MMSBM_functions.theta_comp_arrays_multilayer(BiNet, layer='a')[source]
Computes the membership matrix for a layer in a bipartite network.
- Parameters:
BiNet (BiNet) – The bipartite network object
layer (str, default="a") – The layer to compute the membership matrix for (“a” or “b”)
- Returns:
The computed membership matrix for the specified layer
- Return type:
np.array
- Raises:
TypeError – If layer is not “a” or “b”
- functions.MMSBM_functions.theta_comp_array(N_nodes, K, omega, denominators, links, masks_list)[source]
Computes the membership matrix of a nodes layer with no metadata.
- Parameters:
N_nodes (int) – Number of nodes
K (int) – Number of groups
omega (np.array) – The omega matrix
denominators (np.array) – Array of denominators for normalization
links (np.array) – Array containing the links
masks_list (list) – List of masks for each attribute
- Returns:
The computed membership matrix of shape (N_nodes, K)
- Return type:
np.array
- functions.MMSBM_functions.q_ka_comp_arrays(K, N_att, omega, links, masks_att_list)[source]
Computes the probability matrix between nodes in group k and attribute a.
- Parameters:
K (int) – Number of groups
N_att (int) – Number of attributes
omega (np.array) – The omega matrix of the BiNet
links (np.array) – The links of the BiNet
masks_att_list (list) – A list of masks for each attribute
- Returns:
The probability matrix of shape (K, N_att) between nodes in group k and attribute a
- Return type:
np.array
- functions.MMSBM_functions.p_kl_comp_arrays(Ka, Kb, N_labels, links, omega, mask_list)[source]
Computes the probability matrix between groups in nodes_a layer and group nodes_b layer in a BiNet network.
- Parameters:
Ka (int) – Number of groups in layer a
Kb (int) – Number of groups in layer b
N_labels (int) – Number of possible labels
links (np.array) – Array containing the links
omega (np.array) – The omega matrix
mask_list (list) – List of masks for each label
- Returns:
The probability matrix of shape (Ka, Kb, N_labels) between nodes_a and nodes_b
- Return type:
np.array
- functions.MMSBM_functions.theta_meta(theta, meta)[source]
Computes the membership matrix for metadata.
- Parameters:
theta (np.array) – The membership matrix
meta (metadata_layer) – The metadata layer object
- Returns:
The computed membership matrix for the metadata
- Return type:
np.array
- functions.MMSBM_functions.log_like_comp(theta, eta, pkl, links, labels)[source]
Computes the log_likelihood given the membership matrices of two nodes layer and its matrix probabilities.
- Parameters:
theta (np.array) – Membership matrix for layer a
eta (np.array) – Membership matrix for layer b
pkl (np.array) – Probability matrix between groups
links (np.array) – Array containing the indexes of the links
labels (np.array) – Array containing the indexes of the labels for each link
- Returns:
The computed log likelihood
- Return type:
float
- functions.MMSBM_functions.total_p_comp_test(theta, eta, pkl, links)[source]
Computes the probabilities that two nodes are connected with each link label.
- Parameters:
theta (np.array) – Membership matrix for layer a
eta (np.array) – Membership matrix for layer b
pkl (np.array) – Probability matrix between groups
links (np.array) – Array containing the links
- Returns:
Array of probabilities for each link label
- Return type:
np.array
- functions.MMSBM_functions.log_like_comp_exclusive(theta, qka, links)[source]
Computes the log_likelihood of a bipartite network of exclusive metadata.
- Parameters:
theta (np.array) – Membership matrix for nodes
qka (np.array) – Probability matrix between groups and attributes
links (np.array) – Array containing the indexes of the links
- Returns:
The computed log likelihood for exclusive metadata
- Return type:
float