# TypeError: weight\_predictions() got an unexpected keyword argument 'progressbar'

**URL:** <https://discourse.pymc.io/t/typeerror-weight-predictions-got-an-unexpected-keyword-argument-progressbar/13570>\
**Category:** General\
**Created:** [January 4, 2024, 3:26pm UTC](https://discourse.pymc.io/t/typeerror-weight-predictions-got-an-unexpected-keyword-argument-progressbar/13570 "2024-01-04T15:26:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oussama\_Dhaoui](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@Oussama\_Dhaoui](https://discourse.pymc.io/u/Oussama_Dhaoui)\
**Post date:** [January 4, 2024, 3:26pm UTC](https://discourse.pymc.io/t/typeerror-weight-predictions-got-an-unexpected-keyword-argument-progressbar/13570/1 "2024-01-04T15:26:15Z")

</div>

**Hi any suggestions please??? Thank you**

ppc\_w = pm.sample\_posterior\_predictive\_w(  
[trace\_0, trace\_2, trace\_1],  
[model\_0, model\_1, model\_2],  
comp.weight.sort\_index(ascending=True),  
progressbar=True,  
)  
FutureWarning: The function `sample_posterior_predictive_w` has been removed in PyMC 4.3.0. Switch to `arviz.stats.weight_predictions`

ppc\_w = az.stats.weight\_predictions(  
[trace\_0, trace\_2, trace\_1],  
[model\_0, model\_2, model\_1],  
comp.weight.sort\_index(ascending=True),  
progressbar=True  
)  
TypeError: weight\_predictions() got an unexpected keyword argument ‘progressbar’

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [January 4, 2024, 10:36pm UTC](https://discourse.pymc.io/t/typeerror-weight-predictions-got-an-unexpected-keyword-argument-progressbar/13570/2 "2024-01-04T22:36:29Z")

</div>

It looks like `arviz.stats.weight_predictions` doesn’t take a `progressbar` argument. Did you check the docstring for this function? That’s always a good place to start.

---

<div class="post-metadata">

**Author:** ![Oussama\_Dhaoui](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@Oussama\_Dhaoui](https://discourse.pymc.io/u/Oussama_Dhaoui)\
**Post date:** [January 15, 2024, 9:33am UTC](https://discourse.pymc.io/t/typeerror-weight-predictions-got-an-unexpected-keyword-argument-progressbar/13570/3 "2024-01-15T09:33:49Z")

</div>

```auto
#Posteriors    

with model_0:
   pp_model0 = pm.sample_posterior_predictive(trace_0)
   
# Save the idata to a NetCDF file
# Open it here: https://filext.com/online-file-viewer.html
# For the moment all chains and draws are empty, so I guess something is not working in the computations...
   
   idata = pm.sample(return_inferencedata=True) 
   
   print (idata)
   
   idata.to_netcdf("C:/Users/Ossama/Model_Muse/filename.nc")
   
   
   
#pp_model0= pm.sample_posterior_predictive(model_0)

print(pp_model0)

with model_1:
    pp_model1= pm.sample_posterior_predictive(trace_1)

with model_2:
    pp_model2= pm.sample_posterior_predictive(trace_2)
    
model0= az.from_dict({
    'observed_data':{'x': observed_data},
    'posterior_predictive': pp_model0
})
    
model1= az.from_dict({
    'observed_data':{'x': observed_data},
    'posterior_predictive': pp_model1
})
    
model2= az.from_dict({
    'observed_data':{'x': observed_data},
    'posterior_predictive': pp_model2
})
    
weights= [0.3, 0.7, 0.3]

ppc_w= az.stats.weight_predictions([model0, model1, model2], weights)
    
print(ppc_w)

```

I used this now but it shows me another error:

```auto
ValueError Traceback (most recent call last)
Cell In[4], line 45
     38 model2= az.from_dict({
     39 'observed_data':{'x': observed_data},
     40 'posterior_predictive': pp_model2
     41 })
     43 weights= [0.3, 0.7, 0.3]
---> 45 ppc_w= az.stats.weight_predictions([model0, model1, model2], weights)
     47 print(ppc_w)
     49 #ppc_2 = az.stats.weight_predictions(model2)
     50     
     51 #print(ppc_2)

File ~\anaconda3\Lib\site-packages\arviz\stats\stats.py:2078, in weight_predictions(idatas, weights)
   2075 raise ValueError("You should provide a list with at least two InferenceData objects")
   2077 if not all("posterior_predictive" in idata.groups() for idata in idatas):
-> 2078 raise ValueError(
   2079 "All the InferenceData objects must contain the `posterior_predictive` group"
   2080 )
   2082 if not all(idatas[0].observed_data.equals(idata.observed_data) for idata in idatas[1:]):
   2083 raise ValueError("The observed data should be the same for all InferenceData objects")

ValueError: All the InferenceData objects must contain the `posterior_predictive` group

```

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [January 15, 2024, 9:43am UTC](https://discourse.pymc.io/t/typeerror-weight-predictions-got-an-unexpected-keyword-argument-progressbar/13570/4 "2024-01-15T09:43:54Z")

</div>

I don’t think you need to do all those `az.from_dict` calls. `pm.sample_posterior_predictive` will return an InferenceData object with a `posterior_predictive` group.
