Metaclass
pyrenew helper classes
Model
Model(**kwargs)
Abstract base class for models
Source code in pyrenew/metaclass.py
97 98 99 |
|
model
model(**kwargs) -> tuple
Alias for the sample method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Additional keyword arguments passed through to
internal |
{}
|
Returns:
Type | Description |
---|---|
tuple
|
|
Source code in pyrenew/metaclass.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
posterior_predictive
posterior_predictive(
rng_key: ArrayLike | None = None,
numpyro_predictive_args: dict = {},
**kwargs,
) -> dict
A wrapper of numpyro.infer.util.Predictive
to generate
posterior predictive samples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rng_key
|
ArrayLike | None
|
Random key for the Predictive function call. Defaults to None. |
None
|
numpyro_predictive_args
|
dict
|
Dictionary of arguments to be passed to the
|
{}
|
**kwargs
|
Additional named arguments passed to the
|
{}
|
Returns:
Type | Description |
---|---|
dict
|
|
Source code in pyrenew/metaclass.py
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 |
|
print_summary
A wrapper of numpyro.infer.mcmc.MCMC.print_summary
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prob
|
float
|
The width of the credible interval to show. Default 0.9 |
0.9
|
exclude_deterministic
|
bool
|
Whether to print deterministic sites in the summary. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in pyrenew/metaclass.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
prior_predictive
prior_predictive(
rng_key: ArrayLike | None = None,
numpyro_predictive_args: dict = {},
**kwargs,
) -> dict
A wrapper for numpyro.infer.util.Predictive
to generate prior predictive samples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rng_key
|
ArrayLike | None
|
Random key for the Predictive function call. Default None. |
None
|
numpyro_predictive_args
|
dict
|
Dictionary of arguments to be passed to
the |
{}
|
**kwargs
|
Additional named arguments passed to the
|
{}
|
Returns:
Type | Description |
---|---|
dict
|
|
Source code in pyrenew/metaclass.py
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 |
|
run
run(
num_warmup,
num_samples,
rng_key: ArrayLike | None = None,
nuts_args: dict = None,
mcmc_args: dict = None,
**kwargs,
) -> None
Runs the model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nuts_args
|
dict
|
Dictionary of arguments passed to the kernel
|
None
|
mcmc_args
|
dict
|
Dictionary of arguments passed to the MCMC runner
|
None
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in pyrenew/metaclass.py
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 |
|
sample
abstractmethod
sample(**kwargs) -> tuple
Sample method of the model.
The method design in the class should have at least kwargs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Additional keyword arguments passed through to internal
|
{}
|
Returns:
Type | Description |
---|---|
tuple
|
|
Source code in pyrenew/metaclass.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
RandomVariable
RandomVariable(**kwargs)
Abstract base class for latent and observed random variables.
Default constructor
Source code in pyrenew/metaclass.py
47 48 49 50 51 |
|
__call__
__call__(**kwargs)
Alias for sample
.
Source code in pyrenew/metaclass.py
83 84 85 86 87 |
|
sample
abstractmethod
sample(**kwargs) -> tuple
Sample method of the process
The method design in the class should have at least kwargs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Additional keyword arguments passed through to internal
|
{}
|
Returns:
Type | Description |
---|---|
tuple
|
|
Source code in pyrenew/metaclass.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
validate
abstractmethod
staticmethod
validate(**kwargs) -> None
Validation of kwargs to be implemented in subclasses.
Source code in pyrenew/metaclass.py
75 76 77 78 79 80 81 |
|