You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Display summary of results, Improve error handling, General improvements
Changes:
- Add rich table summary display for results
- Added PathStatus and LBFGSStatus for error handling, status tracking and displaying results
- Changed importance_sampling return type to ImportanceSamplingResult
- Changed multipath_pathfinder return type to MultiPathfinderResult
- Added dataclass containers for results (ImportanceSamplingResult, PathfinderResult, MultiPathfinderResult)
- Refactored LBFGS by removing PyTensor Op classes in favor of pure functions
- Added timing and configuration tracking
- Improve concurrency with better error handling
- Improved docstrings and type hints
- Simplified logp and gradient computation by combining into single function
- Added compile_kwargs parameter for pytensor compilation options
This implements the Pareto Smooth Importance Resampling (PSIR) method, as described in Algorithm 5 of Zhang et al. (2022). The PSIR follows a similar approach to Algorithm 1 PSIS diagnostic from Yao et al., (2018). However, before computing the the importance ratio r_s, the logP and logQ are adjusted to account for the number multiple estimators (or paths). The process involves resampling from the original sample with replacement, with probabilities proportional to the computed importance weights from PSIS.
46
36
47
37
Parameters
48
38
----------
49
-
samples : np.ndarray
50
-
samples from proposal distribution
51
-
logP : np.ndarray
52
-
log probability of target distribution
53
-
logQ : np.ndarray
54
-
log probability of proposal distribution
39
+
samples : NDArray
40
+
samples from proposal distribution, shape (L, M, N)
41
+
logP : NDArray
42
+
log probability values of target distribution, shape (L, M)
43
+
logQ : NDArray
44
+
log probability values of proposal distribution, shape (L, M)
55
45
num_draws : int
56
46
number of draws to return where num_draws <= samples.shape[0]
57
47
method : str, optional
@@ -60,7 +50,7 @@ def importance_sampling(
60
50
61
51
Returns
62
52
-------
63
-
np.ndarray
53
+
NDArray
64
54
importance sampled draws
65
55
66
56
Future work!
@@ -78,13 +68,14 @@ def importance_sampling(
78
68
Zhang, L., Carpenter, B., Gelman, A., & Vehtari, A. (2022). Pathfinder: Parallel quasi-Newton variational inference. Journal of Machine Learning Research, 23(306), 1-49.
79
69
"""
80
70
81
-
num_paths, num_pdraws, N=samples.shape
71
+
warning_msgs= []
72
+
num_paths, _, N=samples.shape
82
73
83
74
ifmethod=="none":
84
-
logger.warning(
85
-
"importance sampling is disabled. The samples are returned as is which may include samples from failed paths with non-finite logP or logQ values. It is recommended to use importance_sampling='psis' for better stability."
75
+
warning_msgs.append(
76
+
"Importance sampling is disabled. The samples are returned as is which may include samples from failed paths with non-finite logP or logQ values. It is recommended to use importance_sampling='psis' for better stability."
0 commit comments