Metaclass
pyrenew helper classes
Model
Model(**kwargs: object)
Abstract base class for models
Source code in pyrenew/metaclass.py
81 82 83 | |
model
Alias for the sample method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
object
|
Additional keyword arguments passed through to
internal |
{}
|
Returns:
| Type | Description |
|---|---|
tuple
|
|
Source code in pyrenew/metaclass.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
posterior_predictive
posterior_predictive(
rng_key: ArrayLike | None = None,
numpyro_predictive_args: dict = {},
**kwargs: object,
) -> 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
|
object
|
Additional named arguments passed to the
|
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Source code in pyrenew/metaclass.py
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 | |
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
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
prior_predictive
prior_predictive(
rng_key: ArrayLike | None = None,
numpyro_predictive_args: dict = {},
**kwargs: object,
) -> 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
|
object
|
Additional named arguments passed to the
|
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Source code in pyrenew/metaclass.py
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 | |
run
run(
num_warmup: int,
num_samples: int,
rng_key: ArrayLike | None = None,
nuts_args: dict = None,
mcmc_args: dict = None,
**kwargs: object,
) -> 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
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 | |
sample
abstractmethod
Sample method of the model.
The method design in the class should have at least kwargs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
object
|
Additional keyword arguments passed through to internal
|
{}
|
Returns:
| Type | Description |
|---|---|
tuple
|
|
Source code in pyrenew/metaclass.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
RandomVariable
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
|
object
|
Additional keyword arguments. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in pyrenew/metaclass.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
__call__
Alias for sample.
Source code in pyrenew/metaclass.py
67 68 69 70 71 | |
sample
abstractmethod
Sample method of the process
The method design in the class should have at least kwargs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
object
|
Additional keyword arguments passed through to internal
|
{}
|
Returns:
| Type | Description |
|---|---|
tuple
|
|
Source code in pyrenew/metaclass.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |