BeliefPropagation fails with IndexError
See original GitHub issueSubject of the issue
BeliefPropagation fails with error IndexError: only integers, slices (":"), ellipsis ("..."), numpy.newaxis ("None") and integer or boolean arrays are valid indices
.
Your environment
- pgmpy version:
0.1.15
- Python version:
Python 3.7.12
- Operating System:
Google Colab
Steps to reproduce
import os
from pgmpy.readwrite import BIFReader
def load_network(network_name):
url = f"https://www.bnlearn.com/bnrepository/{network_name}/{network_name}.bif.gz"
os.system(f"wget {url} -q")
fn = f"{network_name}.bif.gz"
os.system(f"gzip -qd -f {fn} -q")
fn = f"{network_name}.bif"
reader = BIFReader(fn)
os.system(f"rm {fn}")
model = reader.get_model()
model.states = reader.get_states()
return model
network_name = 'asia' #@param ["asia", "cancer", "earthquake", "sachs", "survey"]
model = load_network('asia')
from pgmpy.inference import BeliefPropagation
belief_propagation = BeliefPropagation(model)
belief_propagation.query(variables=['lung', 'bronc'],
evidence={'asia': 'yes',
'tub': 'no',
'xray':'yes'})
This produces IndexError: only integers, slices (":"), ellipsis ("..."), numpy.newaxis ("None") and integer or boolean arrays are valid indices
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Loopy Belief Propagation: Convergence and Effects ... - People
First, we consider the error resulting from taking the product (3) of a number of incoming approximate messages. ut).
Read more >BELIEF PROPAGATION
Here we will adopt the artificial intelligence terminology. It is straightforward to prove that belief propagation exactly computes marginals on tree factor ...
Read more >Time Series Prediction with LSTM Recurrent Neural Networks ...
In this tutorial, we will develop a number of LSTMs for a standard time series prediction problem. The problem and the chosen configuration ......
Read more >US7698239B2 - Self-evolving distributed system performance ...
As messages take more time to propagate through the network, ... At step 545, if the health index error value falls into a...
Read more >sitemap-questions-333.xml - Stack Overflow
... /questions/6566826/segment-tree-with-lazy-propagation-time-limit-problem ... .com/questions/7184796/debugging-indexerror-trivial-sum-generation-problem ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Interesting. This throws the error for me only sometimes and works fine other times. I will check why this is happening. Thanks again for reporting this.
Also, just FYI an easier way to load models from the bn repository is to use
get_example_model
: