Pomegranate: BUG: BayesianNetwork exact structure learning error

Created on 23 Aug 2017  路  14Comments  路  Source: jmschrei/pomegranate

I'm getting an exception when running the exact (A*) bayesian network structure learning algorithm. The snippet below is based on the Tutorial 4b notebook

```.python
from sklearn.datasets import load_digits
import numpy as np
from pomegranate import BayesianNetwork

num_cols = 7
X, y = load_digits(10, True)
X = X > np.mean(X)
X = X[:,:num_cols]
net = BayesianNetwork.from_samples(X, algorithm='exact')



TypeError Traceback (most recent call last)
in ()
7 X = X > np.mean(X)
8 X = X[:,:num_cols]
----> 9 net = BayesianNetwork.from_samples(X, algorithm='exact')

~/anaconda/envs/python3_general/lib/python3.6/site-packages/pomegranate/BayesianNetwork.pyx in pomegranate.BayesianNetwork.BayesianNetwork.from_samples (pomegranate/BayesianNetwork.c:19201)()

~/anaconda/envs/python3_general/lib/python3.6/site-packages/pomegranate/BayesianNetwork.pyx in pomegranate.BayesianNetwork.discrete_exact_a_star (pomegranate/BayesianNetwork.c:27099)()

~/anaconda/envs/python3_general/lib/python3.6/site-packages/pomegranate/utils.pyx in pomegranate.utils.PriorityQueue.pop (pomegranate/utils.c:2459)()

TypeError: '<' not supported between instances of 'NoneType' and 'tuple'
```

Interestingly, when num_cols is 6 or less everything works fine.

Details:

  • Pomegranate 0.7.7 installed from pip
  • OS X
  • Python 3.6

Please let me know if there's anything else you need. Thanks!

Most helpful comment

That's interesting! Can you try running with exact-dp and let me know if that works?

All 14 comments

That's interesting! Can you try running with exact-dp and let me know if that works?

Yeah, exact-dp works fine

Anyone else able to reproduce this issue?

Sorry for the delay. I'm in a state of constant overload (aka grad school). I will look into this soon and get back to you. Can you use exact-dp until I can evaluate the issue?

No apology necessary. This issue isn't holding me up, I was just curious about the reproducibility. Thanks for all of your work on this project!

late on the response, but YES - I have the same issue;)

Hi @jmschrei .

Same issue here.

pomegranate version 0.9.0

But in my case the issue is in "from_structure"

That's weird. Can you post the error you get? from_structure shouldn't be calling from_samples, it should be calling fit

The code bellow:

image

The code works in the version 0.7.0.

Can you help me @jmschrei ?

I just pushed a fix for the issue that @jonmmease pointed out. @jonmmease can you pull the latest version and try with the fix? @willsilvano can you check and see if it fixed your issue as well?

Hi @jmschrei ,

erro

Hello @jmschrei !
I've found the cause of error I've posted.
Analysing the from_samples method from ConditionalProbabilityTable class in the numpy.unique, I discover I have NAN values in one of my variables.
Fixing the values of my variable the error doesn't occurred anymore.

@willsilvano You might consider closing this then.

Was this page helpful?
0 / 5 - 0 ratings