Classes, Solvers and Utilities
Undirected Graph
- class DyGyS.Undirected_class.UndirectedGraph(adjacency=None)[source]
Undirected Graph instance must be initialised with adjacency weighted matrix On initialization it computes also the core network statistics and the binary adjacency matrix.
- Parameters
adjacency (np.ndarray, list) – Weighted adjacency matrix
- classification_measures(n_ensemble=1000, percentiles=(2.5, 97.5), stats=[])[source]
Computes Measures for the quality of classification, listed in self.implemented_classifier_statistics. To be used after .solve() :param n_ensemble: Wanted number of ensemble graphs, default is 1000. :type n_ensemble: int
- Parameters
percentiles (tuple) – Explicit the percentiles used for the construction of the confidence interval, default is (2.5,97.5) for a 95 CI.
stats (list of strings) – numpy array or list of classifier statistics in string format.
- gen_ensemble(n_ensemble=1000)[source]
Generate an ensemble of -n_ensemble- networks according to the selected model
- Parameters
n_ensemble (int) – Number of wanted Graph realizations
- Returns
N_obs X n_ensemble numpy matrix that collects all the ensemble adjacency matrices
- Return type
np.ndarray
- netstats_measures(percentiles=(2.5, 97.5), stats=[])[source]
Computes available network statistics, To be used after .solve() and .gen_ensemble().
- Parameters
percentiles (Tuple) – Explicit the percentiles used for the construction of the confidence interval, default is (2.5,97.5) for a 95 CI.
stats (list) – numpy array or list of available network statistics. The wanted stats must be in the list -.implemented_network_statistics-
- reproduction_accuracy_s(percentiles=(2.5, 97.5), stats=[])[source]
Computes RA_s, the percentage of nodes for which the network statistics are compatible with the graph ensemble according to a percentile confidence interval. To be used after .solve() and .gen_ensemble().
- Parameters
percentiles (tuple) – Explicit the percentiles used for the construction of the confidence interval, default is (2.5,97.5) for a 95 CI.
stats (list of strings) – numpy array or list of network statistics for which it is possible to recover RA_s. The wanted stats must be in the list -.implemented_network_statistics-
- Returns
L-list where L is the number of statistics, the order follows the input stats array
- Return type
list of float
- reproduction_accuracy_w(percentiles=(2.5, 97.5))[source]
Computes RA_w, the percentage of couples for which the weights are compatible with the graph ensemble according to a percentile confidence interval. To be used after .solve() and .gen_ensemble().
- Parameters
percentiles (Tuple) – Explicit the percentiles used for the construction of the confidence interval, default is (2.5,97.5) for a 95 CI.
- Returns
A number (0,1) that explicits RA_w
- Return type
np.ndarray
- solver(model, exogenous_variables=numpy.array, selection_variables=numpy.array, fixed_selection_params=numpy.array, verbose=False, print_steps=numpy.inf, imported_params=numpy.array, use_guess=numpy.array, maxiter=10, tol=1e-05)[source]
Optimize chosen model for Undirected Graphs and compute model selection measures such as AIC and BIC.
- Parameters
model (string) – Chosen model
exogenous_variables (np.ndarray) – Exogenous Variables used for the weighted step, in numpy 2-D format of the type N X k where N are the observations and k are the params,
selection_variables (np.ndarray) – Exogenous Variables used for the topological step, in numpy 2-D format of the type N X k where N are the observations and k are the params,
fixed_selection_params (np.ndarray) – Optional Constant Parameters for the topological step. When initialized different from null vector, it fixes the last “n” topological parameters, when selection_variables are used and n is the size of fixed_selection_params
verbose (boolean) – True if you want to see every n*print_steps iterations, default is False
print_steps (int) – If verbose is True, you print on screen every n*print_steps iterations. default is 1
imported_params (np.ndarray) – If used, uses wanted params as solution.
use_guess (np.ndarray) – If used, uses wanted params as starters in the optimization.
maxiter (int) – Maximum Iterations of solver function.
tol (float) – tolerance for infinite norm in the optimization process
Directed Graph
- class DyGyS.Directed_class.DirectedGraph(adjacency=None)[source]
“Directed Graph instance must be initialised with adjacency weighted matrix. An exploratory analysis is conducted during initialization. See .implemented_models, .implemented_network_statistics and .implemented_classifier_statistics for available methods and statistics.
- Params adjacency (np.ndarray,list)
Weighted adjacency matrix in numpy 1D, numpy 2D or list format.
- classification_measures(n_ensemble=1000, percentiles=(2.5, 97.5), stats=[])[source]
Computes Measures for the quality of classification, listed in self.implemented_classifier_statistics. To be used after .solve() :param n_ensemble: Wanted number of ensemble graphs, default is 1000. :type n_ensemble: int
- Parameters
percentiles (tuple) – Explicit the percentiles used for the construction of the confidence interval, default is (2.5,97.5) for a 95 CI.
stats (list of strings) – numpy array or list of classifier statistics in string format.
- Returns
Average value, standard deviation, percentiles and ensemble distribution of * classifier statistic in the graph ensemble.
- Return type
float, float, tuple, np.ndarray
- gen_ensemble(n_ensemble=1000)[source]
Generate an ensemble of -n_ensemble- networks according to the selected model
- Parameters
n_ensemble (int) – Number of wanted Graph realizations
- Returns
N_obs X n_ensemble numpy matrix that collects all the ensemble adjacency matrices
- Return type
np.ndarray
- netstats_measures(percentiles=(2.5, 97.5), stats=[])[source]
Computes available network statistics, To be used after .solve() and .gen_ensemble(). Available attributes are .avg_*, .std_*, .percentiles_* and .array_* where * stands for the wanted statistics, avg_* is namely the ensemble average, std_* is the ensemble standard deviation, percentiles_* is a Tuple made by (percentile[0],percentile[1]) of the ensemble distribution, array_* is the whole ensemble distribution.
- Parameters
percentiles (Tuple) – Explicit the percentiles used for the construction of the confidence interval, default is (2.5,97.5) for a 95 CI.
stats (list) – numpy array or list of available network statistics. The wanted stats must be in the list -.implemented_network_statistics-
- reproduction_accuracy_s(percentiles=(2.5, 97.5), stats=[])[source]
Computes RA_s, the percentage of nodes for which the network statistics are compatible with the graph ensemble according to a percentile confidence interval. To be used after .solve() and .gen_ensemble().
- Parameters
percentiles (tuple) – Explicit the percentiles used for the construction of the confidence interval, default is (2.5,97.5) for a 95 CI.
stats (list of strings) – numpy array or list of network statistics for which it is possible to recover RA_s. The wanted stats must be in the list -.implemented_network_statistics-
- Returns
L-list where L is the number of statistics, the order follows the input stats array
- Return type
list of float
- reproduction_accuracy_w(percentiles=(2.5, 97.5))[source]
Computes RA_w, the percentage of couples for which the weights are compatible with the graph ensemble according to a percentile confidence interval. To be used after .solve() and .gen_ensemble().
- Parameters
percentiles (Tuple) – Explicit the percentiles used for the construction of the confidence interval, default is (2.5,97.5) for a 95 CI.
- Returns
A number (0,1) that explicits RA_w
- Return type
np.ndarray
- solver(model, exogenous_variables=numpy.array, selection_variables=numpy.array, fixed_selection_params=numpy.array, verbose=False, print_steps=1, imported_params=numpy.array, use_guess=numpy.array, maxiter=10, tol=1e-05)[source]
Optimize chosen model for Directed Graphs and compute model selection measures such as AIC and BIC.
- Parameters
model (string) – Chosen model
exogenous_variables (np.ndarray) – Exogenous Variables used for the weighted step, in numpy 2-D format of the type N X k where N are the observations and k are the params,
selection_variables (np.ndarray) – Exogenous Variables used for the topological step, in numpy 2-D format of the type N X k where N are the observations and k are the params,
fixed_selection_params (np.ndarray) – Optional Constant Parameters for the topological step. When initialized different from null vector, it fixes the last “n” topological parameters, when selection_variables are used and n is the size of fixed_selection_params
verbose (boolean) – True if you want to see every n*print_steps iterations, default is False
print_steps (int) – If verbose is True, you print on screen every n*print_steps iterations. default is 1
print_steps – number of steps for which you can investigate iterations, if Verbose is True
imported_params (np.ndarray) – If used, uses wanted params as solution.
use_guess (np.ndarray) – If used, uses wanted params as starters in the optimization.
maxiter (int) – Maximum Iterations of solver function.
tol (float) – tolerance for infinite norm in the optimization process
Ensemble Functions
- DyGyS.ensemble_Functions.IT_sampling_Exponential(random_array, zij, beta_0, n_ensemble)
Inverse Transform Sampling routine for the Exponential models.
- DyGyS.ensemble_Functions.IT_sampling_Gamma(random_array, zij, beta_0, phi, n_ensemble)
Inverse Transform Sampling routine for the Gamma models.
- DyGyS.ensemble_Functions.IT_sampling_Lognormal(random_array, lnzij, gamma_0, n_ensemble)
Inverse Transform Sampling routine for the Lognormal models.
- DyGyS.ensemble_Functions.IT_sampling_Pareto(random_array, shape, scale, n_ensemble)
Inverse Transform Sampling routine for the Pareto models.
- DyGyS.ensemble_Functions.discrete_ensemble_matrix_directed(params, Wij, model, exogenous_variables, selection_variables=numpy.array, fixed_selection_params=numpy.array, n_ensemble=1000)[source]
Generate ensemble of graphs for directed networks with discrete-valued weights
- Parameters
params (np.ndarray) – params after optimization
Wij (np.ndarray) – weighted adjacency matrix
model (str) – requested model for discrete-valued weights
exogenous_variables (np.ndarray) – regressor matrix for the weighted gravity specification
selection_variables (np.ndarray, optional) – topological regressor matrix for zero-inflated and L-C models. Defaults to np.array([]).
fixed_selection_params (np.ndarray, optional) – fixed parameters for the topological stage for zero-inflated and L-C models. Defaults to np.array([]).
n_ensemble (int, optional) – Number of graphs in the ensemble. Defaults to 1000.
- Raises
TypeError – If model is not a discrete count data model or is not implemented.
- Returns
Weighted adjacency matrices in the ensemble. Each column refers to each graph.
- Return type
np.ndarray
- DyGyS.ensemble_Functions.discrete_ensemble_matrix_undirected(params, Wij, model, exogenous_variables, selection_variables=numpy.array, fixed_selection_params=numpy.array, n_ensemble=1000)[source]
Generate ensemble of graphs for undirected networks with discrete-valued weights
- Parameters
params (np.ndarray) – params after optimization
Wij (np.ndarray) – weighted adjacency matrix
model (str) – requested model for discrete-valued weights
exogenous_variables (np.ndarray) – regressor matrix for the weighted gravity specification
selection_variables (np.ndarray, optional) – topological regressor matrix for zero-inflated and L-C models. Defaults to np.array([]).
fixed_selection_params (np.ndarray, optional) – fixed parameters for the topological stage for zero-inflated and L-C models. Defaults to np.array([]).
n_ensemble (int, optional) – Number of graphs in the ensemble. Defaults to 1000.
- Raises
TypeError – If model is not a discrete count data model or is not implemented.
- Returns
Weighted adjacency matrices in the ensemble. Each column refers to each graph.
- Return type
np.ndarray
- DyGyS.ensemble_Functions.faster_ensemble_matrix_directed(params, Wij, model, exogenous_variables, selection_variables=numpy.array, fixed_selection_params=numpy.array, n_ensemble=1000)
Generate ensemble of graphs for directed networks with continuous-valued weights
- Parameters
params (np.ndarray) – params after optimization
Wij (np.ndarray) – weighted adjacency matrix
model (str) – requested model for discrete-valued weights
exogenous_variables (np.ndarray) – regressor matrix for the weighted gravity specification
selection_variables (np.ndarray, optional) – topological regressor matrix for zero-inflated and L-C models. Defaults to np.array([]).
fixed_selection_params (np.ndarray, optional) – fixed parameters for the topological stage for zero-inflated and L-C models. Defaults to np.array([]).
n_ensemble (int, optional) – Number of graphs in the ensemble. Defaults to 1000.
- Raises
TypeError – If model is not a discrete count data model or is not implemented.
- Returns
Weighted adjacency matrices in the ensemble. Each column refers to each graph.
- Return type
np.ndarray
- DyGyS.ensemble_Functions.faster_ensemble_matrix_undirected(params, Wij, model, exogenous_variables, selection_variables=numpy.array, fixed_selection_params=numpy.array, n_ensemble=1000)
Generate ensemble of graphs for undirected networks with continuous-valued weights
- Parameters
params (np.ndarray) – params after optimization
Wij (np.ndarray) – weighted adjacency matrix
model (str) – requested model for discrete-valued weights
exogenous_variables (np.ndarray) – regressor matrix for the weighted gravity specification
selection_variables (np.ndarray, optional) – topological regressor matrix for zero-inflated and L-C models. Defaults to np.array([]).
fixed_selection_params (np.ndarray, optional) – fixed parameters for the topological stage for zero-inflated and L-C models. Defaults to np.array([]).
n_ensemble (int, optional) – Number of graphs in the ensemble. Defaults to 1000.
- Raises
TypeError – If model is not a discrete count data model or is not implemented.
- Returns
Weighted adjacency matrices in the ensemble. Each column refers to each graph.
- Return type
np.ndarray
Network Statistics Functions
- DyGyS.netstats_Functions.ACC(adj_emp, adj_ens)
Computes Accuracy given empirical and expected binary adjacency matrices.
- DyGyS.netstats_Functions.ACC_ensemble(pij_mat, aij_emp, n_ensemble=1000, percentiles=(2.5, 97.5))
Computes various statistics for Accuracy in the Graph Ensemble.
It returns the ensemble average, standard deviation, percentiles and array for ACC.
- Parameters
pij_mat (np.ndarray) – expected binary adjacency matrix
aij_emp (np.ndarray) – empirical binary adjacency matrix
n_ensemble (int, optional) – Number of graphs in the ensemble. Defaults to 1000.
percentiles (tuple, optional) – Percentiles to compute. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.AIC(ll, nparams)
Computes Akaike Measure given log-likelihood value and number of free parameters
- DyGyS.netstats_Functions.BACC(adj_emp, adj_ens)
Computes Balanced Accuracy given empirical and expected binary adjacency matrices.
- DyGyS.netstats_Functions.BACC_ensemble(pij_mat, aij_emp, n_ensemble=1000, percentiles=(2.5, 97.5))
Computes various statistics for Balanced Accuracy in the Graph Ensemble.
It returns the ensemble average, standard deviation, percentiles and array for BACC.
- Parameters
pij_mat (np.ndarray) – expected binary adjacency matrix
aij_emp (np.ndarray) – empirical binary adjacency matrix
n_ensemble (int, optional) – Number of graphs in the ensemble. Defaults to 1000.
percentiles (tuple, optional) – Percentiles to compute. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.BIC(ll, nparams, nobs)
Computes BIC Measure given log-likelihood value, number of free parameters and number of observations.
- DyGyS.netstats_Functions.F1_score(adj_emp, adj_ens)
Computes F1 Score given empirical and expected binary adjacency matrices.
- DyGyS.netstats_Functions.F1_score_ensemble(pij_mat, aij_emp, n_ensemble=1000, percentiles=(2.5, 97.5))
Computes various statistics for F1 Score in the Graph Ensemble.
It returns the ensemble average, standard deviation, percentiles and array for F1score.
- Parameters
pij_mat (np.ndarray) – expected binary adjacency matrix
aij_emp (np.ndarray) – empirical binary adjacency matrix
n_ensemble (int, optional) – Number of graphs in the ensemble. Defaults to 1000.
percentiles (tuple, optional) – Percentiles to compute. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.PPV(adj_emp, adj_ens)
Computes Precision given empirical and expected binary adjacency matrices.
- DyGyS.netstats_Functions.PPV_ensemble(pij_mat, aij_emp, n_ensemble=1000, percentiles=(2.5, 97.5))
Computes various statistics for Precision in the Graph Ensemble.
It returns the ensemble average, standard deviation, percentiles and array for PPV.
- param pij_mat
expected binary adjacency matrix
- type pij_mat
np.ndarray
- param aij_emp
empirical binary adjacency matrix
- type aij_emp
np.ndarray
- param n_ensemble
Number of graphs in the ensemble. Defaults to 1000.
- type n_ensemble
int, optional
- param percentiles
Percentiles to compute. Defaults to (2.5,97.5).
- type percentiles
tuple, optional
- DyGyS.netstats_Functions.SPC(adj_emp, adj_ens)
Computes Specificity given empirical and expected binary adjacency matrices.
- DyGyS.netstats_Functions.SPC_ensemble(pij_mat, aij_emp, n_ensemble=1000, percentiles=(2.5, 97.5))
Computes various statistics for Specificity in the Graph Ensemble.
It returns the ensemble average, standard deviation, percentiles and array for SPC.
- Parameters
pij_mat (np.ndarray) – expected binary adjacency matrix
aij_emp (np.ndarray) – empirical binary adjacency matrix
n_ensemble (int, optional) – Number of graphs in the ensemble. Defaults to 1000.
percentiles (tuple, optional) – Percentiles to compute. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.TPR(adj_emp, adj_ens)
Computes True Positive Rate given empirical and expected binary adjacency matrices.
- DyGyS.netstats_Functions.TPR_ensemble(pij_mat, aij_emp, n_ensemble=1000, percentiles=(2.5, 97.5))
Computes various statistics for True Positive Rate in the Graph Ensemble. It returns the ensemble average, standard deviation, percentiles and array for TPR.
- Parameters
pij_mat (np.ndarray) – expected binary adjacency matrix
aij_emp (np.ndarray) – empirical binary adjacency matrix
n_ensemble (int, optional) – Number of graphs in the ensemble. Defaults to 1000.
percentiles (tuple, optional) – Percentiles to compute. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.annd_ensemble(w_mat_ensemble, percentiles=(2.5, 97.5))
Computes various statistics for average neighbor degree centrality in the Graph Ensemble, consisting of ensemble average, standard deviation, percentiles and ensemble distribution.
- Params w_mat_ensemble
weighted adjacency matrices for the Graph Ensemble
- Params percentiles
percentages for percentile CI extracted from the ensemble. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.anns_ensemble(w_mat_ensemble, percentiles=(2.5, 97.5))
Computes various statistics for average neighbor strength centrality in the Graph Ensemble, consisting of ensemble average, standard deviation, percentiles and ensemble distribution.
- Params w_mat_ensemble
weighted adjacency matrices for the Graph Ensemble
- Params percentiles
percentages for percentile CI extracted from the ensemble. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.binarize(input)
Return binary adjacency matrix from weighted adjacency matrix.
- DyGyS.netstats_Functions.clust_ensemble(w_mat_ensemble, percentiles=(2.5, 97.5))
Computes various statistics for binary clustering coefficient centrality in the Graph Ensemble, consisting of ensemble average, standard deviation, percentiles and ensemble distribution.
- Params w_mat_ensemble
weighted adjacency matrices for the Graph Ensemble
- Params percentiles
percentages for percentile CI extracted from the ensemble. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.clust_single_fast(adj)
Computes binary clustering coefficient(cycle-type).
- DyGyS.netstats_Functions.clust_w_single_fast(w_adj, adj)
Computes linear weighted clustering coefficient (cycle type).
- DyGyS.netstats_Functions.cw_ensemble(w_mat_ensemble, percentiles=(2.5, 97.5))
Computes various statistics for (linear) weighted clustering coefficient centrality in the Graph Ensemble, consisting of ensemble average, standard deviation, percentiles and ensemble distribution.
- Params w_mat_ensemble
weighted adjacency matrices for the Graph Ensemble
- Params percentiles
percentages for percentile CI extracted from the ensemble. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.deg(adj)
Compute (out-)degree centrality for (Directed)Undirected Networks.
- DyGyS.netstats_Functions.deg_in(adj)
Compute in-degree centrality for Directed Networks.
- DyGyS.netstats_Functions.degree_ensemble(w_mat_ensemble, percentiles=(2.5, 97.5))
Computes various statistics for (out-)degree centrality in the Graph Ensemble, consisting of ensemble average, standard deviation, percentiles and ensemble distribution.
- Params w_mat_ensemble
weighted adjacency matrices for the Graph Ensemble
- Params percentiles
percentages for percentile CI extracted from the ensemble. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.degree_in_ensemble(w_mat_ensemble, percentiles=(2.5, 97.5))
Computes various statistics for in-degree centrality in the Graph Ensemble, consisting of ensemble average, standard deviation, percentiles and ensemble distribution.
- Params w_mat_ensemble
weighted adjacency matrices for the Graph Ensemble
- Params percentiles
percentages for percentile CI extracted from the ensemble. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.ensemble_coverage(w_mat_ensemble, wij_emp, percentiles=(2.5, 97.5), stats=['degree', 'annd', 'clust', 'strength', 'anns', 'cw'])
Computes Statistic Reproduction Accuracy for the network statistics in the stats-list
- Parameters
w_mat_ensemble (np.ndarray) – weighted adjacency matrices in the graph ensemble
wij_emp (np.ndarray) – empirical weighted adjacency matrix
percentiles (tuple, optional) – percentages for ensemble percentiles. Defaults to (2.5,97.5).
stats (list, optional) – list of statistics to compute. Defaults to [“degree”,”annd”,”clust”,”strength”,”anns”,”cw”].
- Returns
list of reproduction accuracies for the network statistics in input list stats.
- Return type
list
- DyGyS.netstats_Functions.flatten(input)
Flatten numpy 2-D matrix to numpy 1-D array.
- DyGyS.netstats_Functions.is_symmetric(input)
Check if weighted adjacency matrix is symmetric.
- DyGyS.netstats_Functions.knn_single(adj)
Compute (out/out)average neighbor degree.
- DyGyS.netstats_Functions.matrixate(input)
Turns 1-D numpy array into a numpy 2-D matrix.
- DyGyS.netstats_Functions.pij_matrix_directed(params, method, Wij, selection_variables=numpy.array, exogenous_variables=numpy.array, fixed_selection_params=numpy.array)[source]
Computes expected binary adjacency matrix according to model of choice for Directed networks.
- Parameters
params (np.ndarray) – params after optimization
Wij (np.ndarray) – weighted adjacency matrix
model (str) – requested model for discrete-valued weights
exogenous_variables (np.ndarray) – regressor matrix for the weighted gravity specification
selection_variables (np.ndarray, optional) – topological regressor matrix for zero-inflated and L-C models. Defaults to np.array([]).
fixed_selection_params (np.ndarray, optional) – fixed parameters for the topological stage for zero-inflated and L-C models. Defaults to np.array([]).
n_ensemble (int, optional) – Number of graphs in the ensemble. Defaults to 1000.
- Returns
topological expected matrix in 1-D form
- Return type
np.ndarray
- DyGyS.netstats_Functions.pij_matrix_undirected(params, method, Wij, selection_variables=numpy.array, exogenous_variables=numpy.array, fixed_selection_params=numpy.array)[source]
Computes expected binary adjacency matrix according to model of choice for Undirected networks.
- Parameters
params (np.ndarray) – params after optimization
Wij (np.ndarray) – weighted adjacency matrix
model (str) – requested model for discrete-valued weights
exogenous_variables (np.ndarray) – regressor matrix for the weighted gravity specification
selection_variables (np.ndarray, optional) – topological regressor matrix for zero-inflated and L-C models. Defaults to np.array([]).
fixed_selection_params (np.ndarray, optional) – fixed parameters for the topological stage for zero-inflated and L-C models. Defaults to np.array([]).
n_ensemble (int, optional) – Number of graphs in the ensemble. Defaults to 1000.
- Returns
topological expected matrix in 1-D form
- Return type
np.ndarray
- DyGyS.netstats_Functions.st_ensemble(w_mat_ensemble, percentiles=(2.5, 97.5))
Computes various statistics for (out-)strength centrality in the Graph Ensemble, consisting of ensemble average, standard deviation, percentiles and ensemble distribution.
- Params w_mat_ensemble
weighted adjacency matrices for the Graph Ensemble
- Params percentiles
percentages for percentile CI extracted from the ensemble. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.st_in_ensemble(w_mat_ensemble, percentiles=(2.5, 97.5))
Computes various statistics for in-strength centrality in the Graph Ensemble, consisting of ensemble average, standard deviation, percentiles and ensemble distribution.
- Params w_mat_ensemble
weighted adjacency matrices for the Graph Ensemble
- Params percentiles
percentages for percentile CI extracted from the ensemble. Defaults to (2.5,97.5).
- DyGyS.netstats_Functions.stnn_single(w_adj, adj)
Computes (out/out) average neighbor strength.
- DyGyS.netstats_Functions.strength(w_adj)
Computes (out-)strength sequence for (Directed)Undirected networks
- DyGyS.netstats_Functions.strength_in(w_adj)
Computes in-strength sequence
- DyGyS.netstats_Functions.symmetrize(input)
Symmetrize weighted adjacency matrix using the average between $$w_{ij}$$ and $$w_{ji}$$.
- DyGyS.netstats_Functions.weighted_coverage(w_mat_ensemble, wij_emp, percentiles=(2.5, 97.5))
Computes Reproduction Accuracy for the weights
- Parameters
w_mat_ensemble (np.ndarray) – weighted adjacency matrices in the graph ensemble
wij_emp (np.ndarray) – empirical weighted adjacency matrix
percentiles (tuple, optional) – percentages for ensemble percentiles. Defaults to (2.5,97.5).
- Returns
list of reproduction accuracies for the weights.
- Return type
list
Solver Functions
- DyGyS.solver_Functions.binarize(input)
Computes binary adjacency matrix from weighted adjacency matrix.
- DyGyS.solver_Functions.solver(model, Wij, selection_variables, exogenous_variables, fixed_selection_params=numpy.array, tol=1e-05, use_guess=numpy.array, verbose=False, print_steps=1, maxiter=20)[source]
Solves chosen model using scipy.optimize and scipy.least_squares routines.
- Parameters
model (str) – chosen model
Wij (np,ndarray) – weighted adjacency matrix
selection_variables (np.ndarray) – regressor matrix for the topological optimization of Zero-Inflated and L-constrained Conditional Models.
exogenous_variables (np.ndarray) – regressor matrix for the weighted optimization
fixed_selection_variables (np.ndarray) – fixed parameters for the topological optimization of Zero-Inflated and L-constrained Conditional Models. Defaults to np.array([1.00000,1.0000,0.0000]).
tol (float, optional) – tolerance for optimization. Defaults to 1e-5.
use_guess (np.ndarray, optional) – optional starter guess for the optimization process. Defaults to np.array([]).
verbose (bool, optional) – True if you want to print iteration values of infinite norm. Defaults to False.
print_steps (int, optional) – If verbose is True, you decide after how many steps you print on the screen. Defaults to 1.
maxiter (int, optional) – Maxiter for optimization process. Defaults to 10.
- Raises
TypeError – If chosen model is not correctly written or not implemented. See self.implemented_models to see available models.
- Returns
estimated model solution
- Return type
np.ndarray
Criterion Functions for Conditional MaxEnt Models
- DyGyS.ll_Functions_conditional.alpha_estimate_CLognormal(params_exog, Wij, exogenous_variables)
Computes an approximate estimate for the last parameter of the Lognormal model given the others.
- DyGyS.ll_Functions_conditional.binarize(input)
Computes binary adjacency matrix from weighted matrix.
- DyGyS.ll_Functions_conditional.hess_BCM(params, Wij)
Computes opposite of the hessian for Undirected Binary Configuration Model
- DyGyS.ll_Functions_conditional.hess_CExp(params, Wij, exogenous_variables)
Computes the opposite of the hessian for the weighted part of the Conditional Exponential model
- DyGyS.ll_Functions_conditional.hess_CGeom(params, Wij, exogenous_variables)
Computes the opposite of the hessian for the weighted part of the Conditional Geometric model
- DyGyS.ll_Functions_conditional.hess_DBCM(params, Wij)
Computes opposite of the hessian for Directed Binary Configuration Model
- DyGyS.ll_Functions_conditional.jac_BCM(params, Wij)
Computes opposite of the jacobian for Undirected Binary Configuration Model
- DyGyS.ll_Functions_conditional.jac_CExp(params, Wij, exogenous_variables)
Computes the opposite of the jacobian for the weighted part of the Conditional Exponential model
- DyGyS.ll_Functions_conditional.jac_CGamma(params, Wij, exogenous_variables)
Computes the opposite of the jacobian for the weighted part of the Conditional Gamma model
- DyGyS.ll_Functions_conditional.jac_CGeom(params, Wij, exogenous_variables)
Computes the opposite of the jacobian for the weighted part of the Conditional Geometric model
- DyGyS.ll_Functions_conditional.jac_CLognormal(params, Wij, exogenous_variables)
Computes the opposite of the jacobian for the weighted part of the Conditional Lognormal model
- DyGyS.ll_Functions_conditional.jac_CPareto(params_exog, Wij, exogenous_variables)
Computes the opposite of the jacobian for the weighted part of the Conditional Pareto model
- DyGyS.ll_Functions_conditional.jac_DBCM(params, Wij)
Computes opposite of the jacobian for Directed Binary Configuration Model
- DyGyS.ll_Functions_conditional.jac_logit(params, Wij, selection_variables, fixed_selection_params=numpy.array)
Computes opposite of the jacobian for Logit model
- DyGyS.ll_Functions_conditional.ll_BCM(params, Wij)
Computes opposite of the log-likelihood for Undirected Binary Configuration Model
- DyGyS.ll_Functions_conditional.ll_CExp(params, Wij, exogenous_variables)
Computes the opposite of the log-likelihood for the weighted part of the Conditional Exponential model
- DyGyS.ll_Functions_conditional.ll_CGamma(params, Wij, exogenous_variables)
Computes the opposite of the log-likelihood for the weighted part of the Conditional Gamma model
- DyGyS.ll_Functions_conditional.ll_CGeom(params, Wij, exogenous_variables)
Computes the opposite of the log-likelihood for the weighted part of the Conditional Geometric model
- DyGyS.ll_Functions_conditional.ll_CLognormal(params, Wij, exogenous_variables)
Computes the opposite of the log-likelihood for the weighted part of the Conditional Lognormal model
- DyGyS.ll_Functions_conditional.ll_CPareto(params_exog, Wij, exogenous_variables)
Computes the opposite of the log-likelihood for the weighted part of the Conditional Pareto model
- DyGyS.ll_Functions_conditional.ll_DBCM(params, Wij)
Computes opposite of the log-likelihood for Directed Binary Configuration Model
- DyGyS.ll_Functions_conditional.ll_logit(params, Wij, selection_variables, fixed_selection_params=numpy.array)
Computes opposite of the log-likelihood for Logit model
Criterion Functions for Integrated MaxEnt Models
- DyGyS.ll_Functions_integrated.binarize(input)
Computes binary adjacency matrix from weighted matrix.
- DyGyS.ll_Functions_integrated.hess_LIExp(params, Wij, exogenous_variables)
Computes the opposite of the hessian for the L-constrained Integrated Exponential model
- DyGyS.ll_Functions_integrated.hess_LIGeom(params, Wij, exogenous_variables)
Computes the opposite of the hessian for the L-constrained Integrated Geometric model
- DyGyS.ll_Functions_integrated.hess_kIExp_topological_undirected(theta_0, Wij, exogenous_variables, params_exog, b0)
Computes the opposite of the topological hessian for the k-constrained Integrated Exponential model for Undirected networks
- DyGyS.ll_Functions_integrated.hess_kIExp_undirected(params, Wij, exogenous_variables)
Computes the opposite of the hessian for the k-constrained Integrated Exponential model for Undirected networks
- DyGyS.ll_Functions_integrated.hess_kIGeom_topological_undirected(theta, Wij, exogenous_variables, params_exog, z_0)
Computes the opposite of the topological hessian for the k-constrained Integrated Geometric model for Undirected networks. Used in the solver
- DyGyS.ll_Functions_integrated.hess_kIGeom_undirected(params, Wij, exogenous_variables)
Computes the opposite of the hessian for the k-constrained Integrated Geometric model for Undirected networks
- DyGyS.ll_Functions_integrated.jac_LIExp(params, Wij, exogenous_variables)
Computes the opposite of the jacobian for the L-constrained Integrated Exponential model
- DyGyS.ll_Functions_integrated.jac_LIGeom(params, Wij, exogenous_variables)
Computes the opposite of the jacobian for the L-constrained Integrated Geometric model
- DyGyS.ll_Functions_integrated.jac_kIExp_directed(params, Wij, exogenous_variables)
Computes the opposite of the jacobian for the k-constrained Integrated Exponential model for Directed networks
- DyGyS.ll_Functions_integrated.jac_kIExp_topological_directed(theta, Wij, exogenous_variables, params_exog, beta_0)
Computes the opposite of the topological jacobian for the k-constrained Integrated Exponential model for Directed networks
- DyGyS.ll_Functions_integrated.jac_kIExp_topological_undirected(theta, Wij, exogenous_variables, params_exog, beta_0)
Computes the opposite of the topological jacobian for the k-constrained Integrated Exponential model for Undirected networks
- DyGyS.ll_Functions_integrated.jac_kIExp_undirected(params, Wij, exogenous_variables)
Computes the opposite of the jacobian for the k-constrained Integrated Exponential model for Undirected networks
- DyGyS.ll_Functions_integrated.jac_kIGeom_directed(params, Wij, exogenous_variables)
Computes the opposite of the jacobian for the k-constrained Integrated Geometric model for Directed networks
- DyGyS.ll_Functions_integrated.jac_kIGeom_topological_directed(theta, Wij, exogenous_variables, params_exog, z_0)
Computes the opposite of the topological jacobian for the k-constrained Integrated Geometric model for Directed networks
- DyGyS.ll_Functions_integrated.jac_kIGeom_topological_undirected(theta_i, Wij, exogenous_variables, params_exog, z_0)
Computes the opposite of the topological jacobian for the k-constrained Integrated Geometric model for Undirected networks. Used in the solver.
- DyGyS.ll_Functions_integrated.jac_kIGeom_undirected(params, Wij, exogenous_variables)
Computes the opposite of the jacobian for the k-constrained Integrated Geometric model for Undirected networks
- DyGyS.ll_Functions_integrated.ll_LIExp(params, Wij, exogenous_variables)
Computes the opposite of the log-likelihood for the L-constrained Integrated Exponential model
- DyGyS.ll_Functions_integrated.ll_LIExp_binary(params, Wij, exogenous_variables)
Computes the opposite of the binary log-likelihood for the L-constrained Integrated Exponential model
- DyGyS.ll_Functions_integrated.ll_LIGeom(params, Wij, exogenous_variables)
Computes the opposite of the log-likelihood for the L-constrained Integrated Geometric model
- DyGyS.ll_Functions_integrated.ll_LIGeom_binary(params, Wij, exogenous_variables)
Computes the opposite of the binary log-likelihood for the L-constrained Integrated Geometric model
- DyGyS.ll_Functions_integrated.ll_kIExp_binary_directed(params, Wij, exogenous_variables)
Computes the opposite of the binary log-likelihood for the k-constrained Integrated Exponential model for Directed networks
- DyGyS.ll_Functions_integrated.ll_kIExp_binary_undirected(params, Wij, exogenous_variables)
Computes the opposite of the binary log-likelihood for the k-constrained Integrated Exponential model for Undirected networks
- DyGyS.ll_Functions_integrated.ll_kIExp_directed(params, Wij, exogenous_variables)
Computes the opposite of the log-likelihood for the k-constrained Integrated Exponential model for Directed networks
- DyGyS.ll_Functions_integrated.ll_kIExp_undirected(params, Wij, exogenous_variables)
Computes the opposite of the log-likelihood for the k-constrained Integrated Exponential model for Undirected networks
- DyGyS.ll_Functions_integrated.ll_kIGeom_binary_directed(params, Wij, exogenous_variables)
Computes the opposite of the binary log-likelihood for the k-constrained Integrated Geometric model for Directed networks
- DyGyS.ll_Functions_integrated.ll_kIGeom_binary_undirected(params, Wij, exogenous_variables)
Computes the opposite of the binary log-likelihood for the k-constrained Integrated Geometric model for Undirected networks
- DyGyS.ll_Functions_integrated.ll_kIGeom_directed(params, Wij, exogenous_variables)
Computes the opposite of the log-likelihood for the k-constrained Integrated Geometric model for Directed networks
- DyGyS.ll_Functions_integrated.ll_kIGeom_undirected(params, Wij, exogenous_variables)
Computes the opposite of the log-likelihood for the k-constrained Integrated Geometric model for Undirected networks
Criterion Functions for Econometric Models
- DyGyS.ll_Functions_econometrics.binarize(input)
Computes binary adjacency matrix from weighted matrix.
- DyGyS.ll_Functions_econometrics.guess_constant_parameter(Wij, exogenous_variables)
Estimate approximate first parameter for the solver of Poisson model
- DyGyS.ll_Functions_econometrics.jac_NB2(params, Wij, exogenous_variables)
Computes opposite of the jacobian for Negative Binomial model
- DyGyS.ll_Functions_econometrics.jac_POIS(params, Wij, exogenous_variables)
Computes opposite of the jacobian for Poisson model
- DyGyS.ll_Functions_econometrics.jac_ZINB(params, Wij, selection_variables, exogenous_variables, fixed_selection_params=numpy.array)
Compute the opposite of the jacobian for Zero-Inflated Negative Binomial model
- DyGyS.ll_Functions_econometrics.jac_ZIP(params, Wij, selection_variables, exogenous_variables, fixed_selection_params=numpy.array)
Compute the opposite of the jacobian for Zero-Inflated Poisson model
- DyGyS.ll_Functions_econometrics.ll_NB2(params, Wij, exogenous_variables)
Computes opposite of the log-likelihood for Negative Binomial model
- DyGyS.ll_Functions_econometrics.ll_NB2_binary(params, Wij, exogenous_variables)
Computes opposite of the binary log-likelihood for Negative Binomial model
- DyGyS.ll_Functions_econometrics.ll_POIS(params, Wij, exogenous_variables)
Computes opposite of the log-likelihood for Poisson model
- DyGyS.ll_Functions_econometrics.ll_POIS_binary(params, Wij, exogenous_variables)
Computes opposite of the binary log-likelihood for Poisson model
- DyGyS.ll_Functions_econometrics.ll_ZINB(params, Wij, selection_variables, exogenous_variables, fixed_selection_params=numpy.array)
Compute the opposite of the log-likelihood for Zero-Inflated Negative Binomial model
- DyGyS.ll_Functions_econometrics.ll_ZINB_binary(params, Wij, selection_variables, exogenous_variables, fixed_selection_params=numpy.array)
Compute the opposite of the binary log-likelihood for Zero-Inflated Negative Binomial model
- DyGyS.ll_Functions_econometrics.ll_ZIP(params, Wij, selection_variables, exogenous_variables, fixed_selection_params=numpy.array)
Compute the opposite of the log-likelihood for Zero-Inflated Poisson model
- DyGyS.ll_Functions_econometrics.ll_ZIP_binary(params, Wij, selection_variables, exogenous_variables, fixed_selection_params=numpy.array)
Compute the opposite of the binary log-likelihood for Zero-Inflated Poisson model