Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from arviz import from_pymc3
import theano
import pymc3 as pm
from bambi.priors import Prior
from .base import BackEnd
class PyMC3BackEnd(BackEnd):
"""
PyMC3 model-fitting back-end.
"""
# Available link functions
links = {
"identity": lambda x: x,
"logit": theano.tensor.nnet.sigmoid,
"inverse": theano.tensor.inv,
"inverse_squared": lambda x: theano.tensor.inv(theano.tensor.sqrt(x)),
"log": theano.tensor.exp,
}
dists = {"HalfFlat": pm.Bound(pm.Flat, lower=0)}
import re
import numpy as np
from arviz import from_pystan
from bambi.priors import Prior
from .base import BackEnd
try:
import pystan as ps
except ImportError:
ps = None
class StanBackEnd(BackEnd): # pylint: disable=too-many-instance-attributes
"""
Stan/PyStan model-fitting back-end.
"""
# distribution names and arg names should match those in priors.json,
dists = {
"Normal": {"name": "normal", "args": ["#mu", "#sd"]},
"Bernoulli": {"name": "bernoulli", "args": ["#p"]},
"Poisson": {"name": "poisson", "args": ["#mu"]},
"Cauchy": {"name": "cauchy", "args": ["#alpha", "#beta"]},
"HalfNormal": {"name": "normal", "args": ["0", "#sd"], "bounds": ""},
"HalfCauchy": {"name": "cauchy", "args": ["0", "#beta"], "bounds": ""},
# for Uniform, the bounds are the parameters. _map_dist fills these in
"Uniform": {
"name": "uniform",