我正在研究Bayessian analysis with python这本书,并尝试在python中实现所有代码,为此,我使用了谷歌合作实验室(google colab),但是当我运行本书中的以下代码时
import arviz
import pymc3 as pm
import numpy as np
from scipy import stats
np.random.seed(123)
n_experiments=4
theta_real =0.35
data =stats.bernoulli.rvs(p=theta_real,size=n_experiments)
with pm.Model() as our_first_model:
theta =pm.Beta('theta',alpha=1,beta=1)
y =pm.Bernoulli('y',p=theta,observed=data)
start =pm.find_MAP()
step =pm.Metropolis()
trace =pm.sample(1000,step=step,start=start)
burnin=100
chain =trace[burnin:]
pm.traceplot(chain,lines={'theta':theta_real})
它给出了这样的错误:
AttributeError: Installed version of ArviZ requires PyMC3>=3.8. Please upgrade with `pip install pymc3>=3.8` or `conda install -c conda-forge pymc3>=3.8`
在我尝试实现这些库之前
!pip install pymc3>=3.8
!pip install arviz
但仍然没有成功。如何解决此错误?
答案 0 :(得分:0)
您是否尝试过重启会话?使用public function execute(\Magento\Framework\Event\Observer $observer)
{
if($observer->getEvent()->getMethodInstance()->getCode()=="cashondelivery"){
$checkResult = $observer->getEvent()->getResult();
$checkResult->setData('is_available', true);
}else{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
$items = $cart->getItems();
$flag = 0;
$count=0;
foreach($items as $item){
$attribute1 = $item->getProduct()->getData('otherthancod');
if($attribute1){
$flag++;
$count++;
}else{
$flag--;
}
}
if($flag == $count){
$checkResult = $observer->getEvent()->getResult();
$checkResult->setData('is_available', true);
}else{
$checkResult = $observer->getEvent()->getResult();
$checkResult->setData('is_available', false);
}
}
}
升级后,您将必须重新启动会话,然后再执行function * zip(arr1, arr2, i = 0) {
while(arr1[i]) yield [ arr1[i], arr2[i++] ];
}
[ ...zip(arr1, arr2) ] // result
,否则它将仍然考虑以前安装的版本。