bambinos/kulprit

UserWarning: Incompatible model and inference data.

lucabol opened this issue · 4 comments

Hi,
Beginner here. I tried to reduce my model to as few variables as possible, and follow the Quickstart, but still getting this error. Not sure how to debug.

ppi = kpt.ProjectionPredictive(model, idata)

Repro is here: https://github.com/lucabol/divs/blob/master/Analysis.ipynb

Full error below

UserWarning                               Traceback (most recent call last)
Cell In[6], [line 3](vscode-notebook-cell:?execution_count=6&line=3)
      [1](vscode-notebook-cell:?execution_count=6&line=1) #idata.to_netcdf("kptidata1.nc")
      [2](vscode-notebook-cell:?execution_count=6&line=2) #idata = az.from_netcdf("kptidata1.nc")
----> [3](vscode-notebook-cell:?execution_count=6&line=3) ppi = kpt.ProjectionPredictive(model, idata)
      [4](vscode-notebook-cell:?execution_count=6&line=4) ppi.search()

File ~/miniconda3/envs/bap3/lib/python3.11/site-packages/kulprit/reference.py:62, in ProjectionPredictive.__init__(self, model, idata)
     [60](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/lucabol/dev/divs/~/miniconda3/envs/bap3/lib/python3.11/site-packages/kulprit/reference.py:60) # test compatibility between model and idata
     [61](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/lucabol/dev/divs/~/miniconda3/envs/bap3/lib/python3.11/site-packages/kulprit/reference.py:61) if not check_model_idata_compatability(model=model, idata=idata):
---> [62](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/lucabol/dev/divs/~/miniconda3/envs/bap3/lib/python3.11/site-packages/kulprit/reference.py:62)     raise UserWarning("Incompatible model and inference data.")
     [64](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/lucabol/dev/divs/~/miniconda3/envs/bap3/lib/python3.11/site-packages/kulprit/reference.py:64) # log reference model and inference data
     [65](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/lucabol/dev/divs/~/miniconda3/envs/bap3/lib/python3.11/site-packages/kulprit/reference.py:65) self.model = model

UserWarning: Incompatible model and inference data.

Hi @lucabol, thanks for reporting the issue and providing an example. I am on vacations and away from my laptop. I will be able to check this next week, when I come back.

No problem. Take your time. I think it is likely something crazy I did as I am new to all of this.

Having a look at your notebook cell count it looks like you ran ppi = kpt.ProjectionPredictive(model, idata) before running idata = model.fit(idata_kwargs={'log_likelihood': True}). What happens if you restart the notebook and run from top to bottom?

I am not sure why github puts those numbers beside the blocks. In VsCode the code blocks are numbered in increasing order (as you see it in the files).

In any case, I had rerun it block by block making sure I run model.fit first, and still see the same problem.

I also run it in JupyterLab. It shows the correct cell count and gives the same error.