Open SEICS opened 2 years ago
Hi,
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)?
Hello SEICS,
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.
I hope that helps!
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:
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!