pyhs3.Model¶
- class pyhs3.Model(*, parameterset, distributions, domain, functions, progress=True, mode='FAST_RUN')[source]¶
Probabilistic model with compiled tensor operations.
A model represents a specific instantiation of a workspace with concrete parameter values and domain constraints. It builds symbolic computation graphs for distributions and functions, with optional compilation for performance optimization.
The model handles dependency resolution between parameters, functions, and distributions, ensuring proper evaluation order through topological sorting of the computation graph.
- Parameters:
parameterset (
ParameterSet
)distributions (
Distributions
)domain (
Domain
)functions (
Functions
)progress (
bool
)mode (
str
)
- __init__(*, parameterset, distributions, domain, functions, progress=True, mode='FAST_RUN')[source]¶
Represents a probabilistic model composed of parameters, domains, distributions, and functions.
- Parameters:
parameterset (ParameterSet) – The parameter set used in the model.
distributions (Distributions) – Set of distributions to include.
domain (Domain) – Domain constraints for parameters.
functions (Functions) – Set of functions that compute parameter values.
progress (bool) – Whether to show progress bar during dependency graph construction.
mode (str) – PyTensor compilation mode. Defaults to “FAST_RUN”. Options: “FAST_RUN” (apply all rewrites, use C implementations), “FAST_COMPILE” (few rewrites, Python implementations), “NUMBA” (compile using Numba), “JAX” (compile using JAX), “PYTORCH” (compile using PyTorch), “DebugMode” (debugging), “NanGuardMode” (NaN detection).
- parameterset¶
The original parameter set with parameter values.
- Type:
- distributions¶
Symbolic distribution expressions.
Methods
__init__
(*, parameterset, distributions, ...)Represents a probabilistic model composed of parameters, domains, distributions, and functions.
graph_summary
(name)Get a summary of the computation graph structure.
logpdf
(name, **parametervalues)Evaluates the natural logarithm of the PDF.
pdf
(name, **parametervalues)Evaluates the probability density function of the specified distribution.
visualize_graph
(name[, fmt, outfile, path])Visualize the computation graph for a distribution.