Closed zzzrbx closed 9 months ago
After debugging, I noticed that the issue seems to originate from the _get_prob() function. The line allcomb = np.array(list(itertools.product([0, 1], repeat=len(query.variables))))
generates a list consisting only of 0s and 1s.
For instance, in your code, if you assign a value from 0 to 1 for the "random" variable, there is no issue. However, if you change it to a range from 0 to 100, the problem consistently occurs.
I have recently encountered a similar issue and I am attempting to make modifications. If I succeed, I will either post it here or attempt a pull request (PR).You can also give it a try and attempt to make modifications.
Alright, it looks like a small modification can solve this issue. I haven't encountered any problems on my end, so hopefully, this change will work in all scenarios. The modification is straightforward. You just need to replace the problematic line with the following:
possible_values = query.state_names.values()
allcomb = np.array(list(itertools.product(*possible_values)))
Since this change is minor and I haven't rigorously checked the variable order, I'll just post it here and hope this helps.
Great contribution @ankh1999 Do you want to create a pull request? You will be tagged as a contributor and likely get a batch on your github page ;)
Thanks for your recognition. In that case, I will check the correctness of the variable order and create a pull request accordingly in the coming days. Lastly, I'm grateful for your work in developing the library!
Thank you for your contribution @ankh1999 ! I released a new version!
install the latest version with pip install -U bnlearn
https://github.com/erdogant/bnlearn/releases/tag/0.8.3
I'm getting an error when using the .predict method with this code: