You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to learn a discrete Bayesian network (BN) from a dataset. During the structural learning, I encountered the compilation error "infer_number_of_instantiations assumes values in 1:N, value 0 found!" and I am not sure why it happened.
I just tested my code and it seems that this caused by the 0s in my dataset. I wonder why 0s are not considered as acceptable data values (just by curious)?
I took a look, and infer_number_of_instantiations has the following docstring:
""" infer_number_of_instantiations{I<:Int}(arr::AbstractVector{I})Infer the number of instantiations, N, for a data type, assuming that it takes on the values 1:N"""
As such, it assumes values between 1 and N for some N. Values of 0 would be out of bounds.
This assumption basically allows us to use Julia 1-based indices to index into count tables. The easiest way to convert a dataset to 1:N form is to use the categorical discretizer in Discretizers.jl.
The documentation right now does not emphasize this assumption particularly well. We do have the following for categorical CPDs:
and our discrete Bayesian networks are comprised of them.
Ah! Thank you for the explanation! I am new to Julia also, so I don't know that Julia uses 1-based indices. Really helpful advice! I will give it a try to the Discretizers.jl.
Hi,
I am trying to learn a discrete Bayesian network (BN) from a dataset. During the structural learning, I encountered the compilation error "infer_number_of_instantiations assumes values in 1:N, value 0 found!" and I am not sure why it happened.
Code producing this error:
My dataset (df) looks like this:
![Screenshot 2022-07-07 at 14 33 04](https://user-images.githubusercontent.com/52275062/177786208-5758bb1f-a129-4305-af75-846951863308.png)
and by running the following:
eltype.(eachcol(df))
the corresponding output is:
The entire error output:
Can anyone help me with this? Thank you so much!
The text was updated successfully, but these errors were encountered: