Metaclass
pyrenew helper classes
Model
Model(**kwargs)
Abstract base class for models
Source code in pyrenew/metaclass.py
118 119 120 | |
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
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
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
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 | |
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
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
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
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 | |
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
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 | |
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
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
RandomVariable
RandomVariable(name: str, **kwargs)
Abstract base class for latent and observed random variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A non-empty string identifying this random variable. |
required |
Default constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A non-empty string identifying this random variable. |
required |
**kwargs
|
Additional keyword arguments. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in pyrenew/metaclass.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
__call__
__call__(**kwargs)
Alias for sample.
Source code in pyrenew/metaclass.py
104 105 106 107 108 | |
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
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
validate
abstractmethod
staticmethod
validate(**kwargs) -> None
Validation of kwargs to be implemented in subclasses.
Source code in pyrenew/metaclass.py
96 97 98 99 100 101 102 | |