ERGM Module
The core module containing the ERGM model class and related utilities.
ERGM
The main class for fitting Exponential Random Graph Models.
ERGM
Source code in pyERGM/ergm.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 | |
__init__
__init__(n_nodes, metrics_collection: Sequence[Metric], is_directed: bool, *, initial_thetas: dict | None = None, verbose=True, fix_collinearity=True, collinearity_fixer_sample_size=1000, is_distributed_optimization=False, mask: npt.NDArray[bool] | None = None, num_samples_per_job_collinearity_fixer: int = 5, ratio_threshold_collinearity_fixer: float = 5e-06, nonzero_threshold_collinearity_fixer: float = 0.1)
An ERGM model object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_nodes
|
int
|
Number of nodes in the network. |
required |
metrics_collection
|
Sequence[Metric]
|
A list of Metric objects for calculating statistics of a network. |
required |
is_directed
|
bool
|
Whether the graph is directed or not. |
required |
initial_thetas
|
npdarray
|
Optional. The initial values of the coefficients of the ERGM. If not provided, they are randomly initialized. |
None
|
verbose
|
bool
|
Optional. Whether to print progress information. Defaults to True |
True
|
fix_collinearity
|
bool
|
Optional. Whether to fix collinearity in the metrics. Defaults to True |
True
|
collinearity_fixer_sample_size
|
int
|
Optional. The number of networks to sample for fixing collinearity. Defaults to 1000 |
1000
|
is_distributed_optimization
|
bool
|
Optional. Whether to use distributed computing for optimization (requires LSF cluster). Defaults to False |
False
|
mask
|
NDArray[bool] | None
|
Optional. Designating which entries should be taken into account for optimization and metric calculations. The shape can be either (n, n) or (n**2 - n, 1). The latter is the flattened version with no main diagonal of square mask. |
None
|
Source code in pyERGM/ergm.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
fit
fit(observed_networks, *, lr: float = 0.1, opt_steps: int = 1000, l2_grad_thresh: float = 0.001, sliding_grad_window_k: int = 10, optimization_method: OptimizationMethod = OptimizationMethod.NEWTON_RAPHSON, convergence_criterion: ConvergenceCriterion = ConvergenceCriterion.MODEL_BOOTSTRAP, cov_matrix_estimation_method: CovMatrixEstimationMethod = CovMatrixEstimationMethod.NAIVE, cov_matrix_num_batches: int = 25, hotelling_confidence: float = 0.5, theta_init_method: ThetaInitMethod = ThetaInitMethod.MPLE, mcmc_burn_in: int | None = None, mcmc_seed_network=None, mcmc_steps_per_sample: int | None = None, mcmc_sample_size: int | None = None, edge_proposal_method: EdgeProposalMethod = EdgeProposalMethod.UNIFORM, edge_weights: np.ndarray | None = None, optimization_scheme: OptimizationScheme = OptimizationScheme.AUTO, mple_optimization_method: MPLEOptimizationMethod = MPLEOptimizationMethod.L_BFGS_B, num_edges_per_job: int = 100000, num_subsamples_data: int = 1000, data_splitting_method: DataBootstrapSplittingMethod = DataBootstrapSplittingMethod.UNIFORM, observed_cov_mat_est_method: CovMatrixEstimationMethod = CovMatrixEstimationMethod.NAIVE, bootstrap_convergence_confidence: float = 0.95, bootstrap_convergence_num_stds_away_thr: float = 1.0, num_model_sub_samples: int = 100, model_subsample_size: int = 1000, model_boot_cov_mat_est_method: CovMatrixEstimationMethod = CovMatrixEstimationMethod.NAIVE, mcmle_log_every: int = 50) -> OptimizationResult
Fit an ERGM model to a given network with one of the two fitting methods - MPLE or MCMLE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observed_networks
|
ndarray
|
The observed network connectivity matrix, with shape (n, n) or (n, n, num_networks). |
required |
lr
|
float
|
Optional. The learning rate for the optimization. Defaults to 0.1 |
0.1
|
opt_steps
|
int
|
Optional. The number of optimization steps to run. Defaults to 1000 |
1000
|
l2_grad_thresh
|
float
|
Optional. The threshold for the L2 norm of the gradient to stop the optimization. Relevant only for convergence criterion "zero_grad_norm". Defaults to 0.001 |
0.001
|
sliding_grad_window_k
|
int
|
Optional. The size of the sliding window for the gradient, for which we use to calculate the mean gradient norm. This value is then tested against l2_grad_thresh to decide whether optimization halts. Relevant only for convergence criterion "zero_grad_norm". Defaults to 10 |
10
|
optimization_method
|
OptimizationMethod or str
|
The optimization method for MCMLE. Options: "newton_raphson", "gradient_descent". Defaults to OptimizationMethod.NEWTON_RAPHSON. |
NEWTON_RAPHSON
|
convergence_criterion
|
ConvergenceCriterion or str
|
The criterion for convergence. Options: "hotelling", "zero_grad_norm", "observed_bootstrap", "model_bootstrap". Defaults to ConvergenceCriterion.MODEL_BOOTSTRAP. |
MODEL_BOOTSTRAP
|
cov_matrix_estimation_method
|
CovMatrixEstimationMethod or str
|
The method to estimate the covariance matrix. Options: "naive", "batch", "multivariate_initial_sequence". Defaults to CovMatrixEstimationMethod.NAIVE. |
NAIVE
|
cov_matrix_num_batches
|
int
|
The number of batches to use for estimating the covariance matrix.
Relevant only for |
25
|
hotelling_confidence
|
float
|
The confidence level for the Hotelling's T-squared test. Defaults to 0.99. |
0.5
|
theta_init_method
|
ThetaInitMethod or str
|
The method to initialize the theta values. Options: "uniform", "mple", "use_existing". The MPLE method can be used even for dyadic dependent models, since it serves as a good starting point for the MCMLE. Defaults to ThetaInitMethod.MPLE. |
MPLE
|
mcmc_burn_in
|
int
|
The number of burn-in steps for the MCMC sampler. Defaults to 100n^2*. |
None
|
mcmc_steps_per_sample
|
int
|
The number of steps to run the MCMC sampler for each sample. Defaults to n^2. |
None
|
mcmc_seed_network
|
ndarray
|
The seed network for the MCMC sampler. If not provided, the thetas that are currently set are used to calculate the MPLE prediction, from which the sample is drawn. Defaults to None. |
None
|
mcmc_sample_size
|
int
|
The number of networks to sample with the MCMC sampler. Defaults to 10n*.
Note - if odd, 1 is added to make even (this is necessary for some covariance matrix estimation methods,
see |
None
|
edge_proposal_method
|
EdgeProposalMethod or str
|
The method for the MCMC proposal distribution. Options: "uniform", "features_influence__sum", "features_influence__softmax". Defaults to EdgeProposalMethod.UNIFORM. |
UNIFORM
|
edge_weights
|
ndarray or None
|
Non-negative edge weights for MPLE optimization. Defaults to None. |
None
|
optimization_scheme
|
OptimizationScheme or str
|
The optimization scheme to use. Options: "AUTO", "MPLE", "MPLE_RECIPROCITY", "MCMLE". Defaults to OptimizationScheme.AUTO. |
AUTO
|
mple_optimization_method
|
MPLEOptimizationMethod or str
|
Optimization method for MPLE (scipy.optimize). Options: "L-BFGS-B", "Newton-CG". Defaults to MPLEOptimizationMethod.L_BFGS_B. |
L_BFGS_B
|
num_edges_per_job
|
int
|
Number of edges per job for distributed MPLE. Defaults to 100000. |
100000
|
num_subsamples_data
|
int
|
Number of subsamples for observed bootstrap. Defaults to 1000. |
1000
|
data_splitting_method
|
DataBootstrapSplittingMethod
|
Method for data splitting in bootstrap. Defaults to "DataBootstrapSplittingMethod.UNIFORM". |
UNIFORM
|
observed_cov_mat_est_method
|
CovMatrixEstimationMethod
|
Method for estimating the observed covariance matrix used in ConvergenceCriterion.OBSERVED_BOOTSTRAP. |
NAIVE
|
bootstrap_convergence_confidence
|
float
|
Confidence level for bootstrap convergence tests. Defaults to 0.95. |
0.95
|
bootstrap_convergence_num_stds_away_thr
|
float
|
Number of standard deviations threshold for bootstrap convergence. Defaults to 1.0. |
1.0
|
num_model_sub_samples
|
int
|
Number of model subsamples for bootstrap convergence. Defaults to 100. |
100
|
model_subsample_size
|
int
|
Size of each model subsample for bootstrap convergence. Defaults to 1000. |
1000
|
model_boot_cov_mat_est_method
|
CovMatrixEstimationMethod
|
Method for estimating the covariance matrix used in ConvergenceCriterion.MODEL_BOOTSTRAP. |
NAIVE
|
mcmle_log_every
|
int
|
The gap (int optimization steps) between logs when optimizing with MCMLE. Defaults to 50. |
50
|
Returns
OptimizationResult
Source code in pyERGM/ergm.py
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 | |
generate_networks_for_sample
generate_networks_for_sample(sample_size, seed_network=None, replace=True, burn_in=10000, mcmc_steps_per_sample=1000, sampling_method: SamplingMethod | None = None, edge_proposal_method=EdgeProposalMethod.UNIFORM)
Generate a sample of networks from the current ERGM model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_size
|
int
|
Number of networks to generate. |
required |
seed_network
|
ndarray
|
Initial network for MCMC sampling. If None, a network is generated from MPLE predictions. |
None
|
replace
|
bool
|
Whether to sample with replacement. Default is True. |
True
|
burn_in
|
int
|
Number of MCMC steps to discard before sampling. Default is 100 * (n**2). |
10000
|
mcmc_steps_per_sample
|
int
|
Number of MCMC steps between samples. Default is n**2. |
1000
|
sampling_method
|
SamplingMethod
|
Sampling method to use. Options: "metropolis_hastings", "exact". If None (default), auto-detects based on model type: MPLE/MPLE_RECIPROCITY models use "exact", MCMLE models use "metropolis_hastings". |
None
|
edge_proposal_method
|
str
|
Edge proposal distribution for MCMC. Default is "uniform". |
UNIFORM
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of sampled networks with shape (n, n, sample_size). |
Source code in pyERGM/ergm.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
get_model_parameters
get_model_parameters()
Get the fitted model parameters as a dictionary.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary mapping parameter names to their fitted values (theta coefficients). |
Source code in pyERGM/ergm.py
988 989 990 991 992 993 994 995 996 997 998 | |
get_ignored_features
get_ignored_features()
Get the names of features that were ignored due to collinearity.
Returns:
| Type | Description |
|---|---|
tuple
|
Names of features excluded from the model to avoid multicollinearity. |
Source code in pyERGM/ergm.py
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 | |
calc_model_log_likelihood
calc_model_log_likelihood(observed_network: np.ndarray, reduction: Reduction = Reduction.SUM, log_base: float = np.exp(1))
Calculate the log-likelihood of observed network(s) under the fitted model.
This method computes the log-likelihood for models fitted with MPLE or MPLE_RECIPROCITY. For dyadic independent models (MPLE), it uses the exact probability predictions. For reciprocity models, it uses the dyadic state distributions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observed_network
|
ndarray
|
The observed network adjacency matrix of shape (n, n). |
required |
reduction
|
Reduction
|
How to aggregate likelihoods. Default is Reduction.SUM. If Reduction.NONE, returns individual edge/dyad likelihoods. |
SUM
|
log_base
|
float
|
Base for logarithm. Default is e (natural log). |
exp(1)
|
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Log-likelihood value(s). If reduction='none', returns array of individual likelihoods. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If network dimensions are incorrect or network is non-binary. |
NotImplementedError
|
If model has dependencies other than reciprocity. |
Source code in pyERGM/ergm.py
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | |
calc_model_entropy
calc_model_entropy(reduction: Reduction = Reduction.SUM, eps: float = 1e-10)
Calculate the entropy of the fitted ERGM model.
Entropy measures the uncertainty in the model's probability distribution. For dyadic independent models, computes entropy from edge probabilities. For reciprocity models, computes entropy from dyadic state distributions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reduction
|
Reduction
|
How to aggregate entropy. Default is Reduction.SUM. |
SUM
|
eps
|
float
|
Small constant to avoid log(0). Default is 1e-10. |
1e-10
|
Returns:
| Type | Description |
|---|---|
float
|
The entropy value in bits. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If model has dependencies other than reciprocity. |
Source code in pyERGM/ergm.py
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | |
get_mcmc_diagnostics
get_mcmc_diagnostics(sampled_networks=None, observed_network=None)
Get MCMC diagnostics for the last chain or a sample of networks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampled_networks
|
ndarray
|
Optional. A (n, n+k, sample_size) tensor of sampled networks. If not provided, the last chain is used. |
None
|
observed_network
|
ndarray
|
Optional. The network matrix of the observed network. If provided, the traces of the features across the chain are normalized based on the observed network features. |
None
|
Source code in pyERGM/ergm.py
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 | |
get_mple_prediction
get_mple_prediction(observed_networks: np.ndarray | None = None, num_edges_per_job: int = 100000)
Get the MPLE-based edge probability predictions.
For dyadic independent models, returns the exact probability matrix. This is cached after first computation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observed_networks
|
ndarray
|
Observed network(s). Required for models with dyadic-dependent metrics (e.g., NumberOfTriangles, Reciprocity). Optional for dyadic-independent models (e.g., NumberOfEdges, InDegree, OutDegree). If provided as 3D array, uses the first network (observed_networks[..., 0]). |
None
|
num_edges_per_job
|
int
|
Number of edges per job for distributed computation. Default is 100000. |
100000
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Matrix of edge probabilities of shape (n, n). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If observed_networks is None and the model contains dyadic-dependent metrics. |
ValueError
|
If distributed optimization is enabled for a model with dyadic-dependent metrics. |
Notes
- For dyadic-independent models, observed_networks can be None as edge probabilities don't depend on network structure.
- Distributed computation (via _is_distributed_optimization) requires dyadic independence.
Source code in pyERGM/ergm.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
get_mple_reciprocity_prediction
get_mple_reciprocity_prediction()
Get the dyadic state probability distributions for reciprocity models.
Returns the probability distribution over the four possible dyadic states (no edges, i->j only, j->i only, or reciprocal) for each node pair.
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of shape (n_choose_2, 4) with probability distributions. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the model is independent or has dependencies between non-reciprocal edges. |
Source code in pyERGM/ergm.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
print_model_parameters
print_model_parameters()
Prints the parameters of the ERGM model.
Source code in pyERGM/ergm.py
143 144 145 146 147 148 149 | |
ConvergenceTester
Convergence testers for MCMLE optimization. Each criterion is implemented as a stateful subclass behind a common abstract API with a factory method.
ConvergenceTester
Bases: ABC
Abstract base class for ERGM convergence testers.
Each subclass encapsulates a specific convergence criterion, maintaining its own state and providing a uniform API for updating per-iteration data and testing for convergence.
Source code in pyERGM/convergence.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
requires_covariance_estimation
abstractmethod
property
requires_covariance_estimation: bool
Whether this tester requires a covariance matrix to be estimated each iteration.
create
staticmethod
create(criterion: ConvergenceCriterion, **kwargs) -> ConvergenceTester
Factory method that creates the appropriate ConvergenceTester subclass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
criterion
|
ConvergenceCriterion
|
The convergence criterion to use. |
required |
**kwargs
|
Keyword arguments forwarded to the relevant subclass constructor. |
{}
|
Returns:
| Type | Description |
|---|---|
ConvergenceTester
|
An instance of the appropriate subclass. |
Source code in pyERGM/convergence.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
update
abstractmethod
update(**kwargs) -> None
Receive per-iteration data from the optimization loop.
Each subclass picks out the keyword arguments it needs.
Source code in pyERGM/convergence.py
77 78 79 80 81 82 83 84 | |
test
abstractmethod
test() -> OptimizationResult
Test for convergence and return an OptimizationResult.
Always returns a result (including when not converged, with success=False).
Source code in pyERGM/convergence.py
86 87 88 89 90 91 92 93 | |