Python 试着按照PyMC3的教程进行操作,结果是:“';型号';对象没有属性TransformedVar“;
我一直在努力学习PYMC3的教程,但是当我看到下面的代码部分时,我遇到了错误Python 试着按照PyMC3的教程进行操作,结果是:“';型号';对象没有属性TransformedVar“;,python,jupyter-notebook,pymc3,Python,Jupyter Notebook,Pymc3,我一直在努力学习PYMC3的教程,但是当我看到下面的代码部分时,我遇到了错误 from pymc3 import Exponential, T, logtransform, exp, Deterministic from pymc3.distributions.timeseries import GaussianRandomWalk with Model() as sp500_model: nu = Exponential('nu', 1./10, testval=.1)
from pymc3 import Exponential, T, logtransform, exp, Deterministic
from pymc3.distributions.timeseries import GaussianRandomWalk
with Model() as sp500_model:
nu = Exponential('nu', 1./10, testval=.1)
sigma, log_sigma = sp500_model.TransformedVar('sigma', Exponential.dist(1./.02, testval=.1),
logtransform)
s = GaussianRandomWalk('s', sigma**-2, shape=n)
volatility_process = Deterministic('volatility_process', exp(-2*s))
r = T('r', nu, lam=volatility_process, observed=returns)
第一个错误是“无法导入名称logtransform
”。
第二个错误(如果我没有尝试加载logtransform
)是“'Model'对象没有属性TransformedVar
”
我在Windows 7上的IPython笔记本中运行此功能,我尝试卸载并重新安装PyMC3,但没有成功。PyMC3的当前版本与不同步 2015年6月3日 2015年6月15日 新的做法是: 被替换为
sigma = Exponential('sigma', 1. / .02, testval=.1)
pymc3的安装应包含pymc3/examples/randomic\u volatility.py
。
与在线教程不同,此代码应与您的pymc3版本一致
代码可以用这种方式简化的原因是指数型是正连续型
的一个子类,而这个类
为了记录在案,这里是Randomic_volatility.py()的当前版本:
然后查看影响transforms.py的提交:
gitk pymc3/distributions/transforms.py
gitk pymc3/distributions/continuous.py
gitk pymc3/examples/stochastic_volatility.py
一旦找到提交哈希(例如c3120bce05bf8f1389272e1c38ddf83cb46c8d84),则
github上相应的提交可位于:
https://github.com/pymc-devs/pymc3/commit/c3120bce05bf8f1389272e1c38ddf83cb46c8d84
我无法在相关时间段(2015-06-xx)内找到讨论/解释此变化的信息
git clone https://github.com/pymc-devs/pymc3
gitk pymc3/distributions/transforms.py
gitk pymc3/distributions/continuous.py
gitk pymc3/examples/stochastic_volatility.py
https://github.com/pymc-devs/pymc3/commit/c3120bce05bf8f1389272e1c38ddf83cb46c8d84