Hi, I’m using a Windows 11 64-bit machine with Anaconda. I followed the official bap3.yml to build my environment.
The I begin to use the pymc_experimental.GenExtreme to build a model, but encountered an AttributeError: ‘function’ object has no attribute ‘register’. My code is this:
import arviz as az
import matplotlib.pyplot as plt
import numpy as np
import pymc as pm
import pymc_experimental.distributions as pmx
import pytensor.tensor as pt
from arviz.plots import plot_utils as azpu
with pm.Model() as model1:
miu = pm.Normal("miu", mu=10, sigma=5)
sigma = pm.HalfNormal("sigma", sigma=10)
ksi = pm.TruncatedNormal("ksi", mu=0, sigma=0.2, lower=-0.6, upper=0.6)
# Estimation
gev = pmx.GenExtreme("gev", mu=miu, sigma=sigma, xi=ksi, observed=new_data.max_load)
# Return level
z_p = pm.Deterministic("z_p", μ - σ / ksi * (1 - (-np.log(1 - p)) ** (-ksi)))
And the error is this:
AttributeError Traceback (most recent call last)
Cell In[3], line 5
3 import numpy as np
4 import pymc as pm
----> 5 import pymc_experimental.distributions as pmx
6 import pytensor.tensor as pt
8 from arviz.plots import plot_utils as azpu
File d:\anaconda3\envs\pymc5\Lib\site-packages\pymc_experimental\__init__.py:26
23 handler = logging.StreamHandler()
24 _log.addHandler(handler)
---> 26 from pymc_experimental import distributions, gp, utils
27 from pymc_experimental.inference.fit import fit
28 from pymc_experimental.marginal_model import MarginalModel
File d:\anaconda3\envs\pymc5\Lib\site-packages\pymc_experimental\distributions\__init__.py:24
22 from pymc_experimental.distributions.histogram_utils import histogram_approximation
23 from pymc_experimental.distributions.multivariate import R2D2M2CP
---> 24 from pymc_experimental.distributions.timeseries import DiscreteMarkovChain
26 __all__ = [
27 "DiscreteMarkovChain",
28 "GeneralizedPoisson",
(...)
31 "histogram_approximation",
32 ]
File d:\anaconda3\envs\pymc5\Lib\site-packages\pymc_experimental\distributions\timeseries.py:225
220 new_size = tuple(new_size) + tuple(old_size)
222 return DiscreteMarkovChain.rv_op(*dist.owner.inputs[:-1], size=new_size, n_lags=op.n_lags)
--> 225 @_moment.register(DiscreteMarkovChainRV)
226 def discrete_mc_moment(op, rv, P, steps, init_dist, state_rng):
227 init_dist_moment = moment(init_dist)
228 n_lags = op.n_lags
AttributeError: 'function' object has no attribute 'register'
Thanks in advance for your help.