Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in fit examples of the documentation #90

Closed
phcournede opened this issue Jun 25, 2020 · 3 comments
Closed

Error in fit examples of the documentation #90

phcournede opened this issue Jun 25, 2020 · 3 comments
Assignees

Comments

@phcournede
Copy link

Hi,
I'm discovering this great package. And running the examples given in the notebook of the documentation I face an unexpected error:

the three lines of the notebook (In[17], In[18], In[19]) when running
fit(BayesNet, data, (:a=>:b), [StaticCPD{Normal}, LinearGaussianCPD])
or
fit(BayesNet, data, (:a=>:b), LinearGaussianCPD)
or

data = DataFrame(c=[1,1,1,1,2,2,2,2,3,3,3,3], 
                 b=[1,1,1,2,2,2,2,1,1,2,1,1],
                 a=[1,1,1,2,1,1,2,1,1,2,1,1])

fit(DiscreteBayesNet, data, (:a=>:b, :a=>:c, :b=>:c))

give the same error:

MethodError: Cannot convert an object of type Nothing to an object of type Int64
Closest candidates are:
convert(::Type{T}, !Matched::T) where T<:Number at number.jl:6
convert(::Type{T}, !Matched::Number) where T<:Number at number.jl:7
convert(::Type{T}, !Matched::Ptr) where T<:Integer at pointer.jl:23
...
LightGraphs.SimpleGraphs.SimpleEdge{Int64}(::Nothing, ::Nothing) at simpleedge.jl:7
add_edge!(::LightGraphs.SimpleGraphs.SimpleDiGraph{Int64}, ::Nothing, ::Nothing) at SimpleGraphs.jl:90
_get_dag(::DataFrame, ::Tuple{Pair{Symbol,Symbol}}) at learning.jl:34
fit(::Type{BayesNet}, ::DataFrame, ::Pair{Symbol,Symbol}, ::Array{DataType,1}) at learning.jl:59
top-level scope at BayesNets.jl:44

I am with Windows, Atom, Julia 1.4.2.

Is it only happening for me?
Thanks if you can help.

@phcournede
Copy link
Author

OK. I think that I found the problem.
When data is a DataFrame, names(data) returns a list of strings, while for the different functions in learning.jl, we need lists of symbols. Therefore: names(data) should become propertynames(data).
It worked for me with this modification.
I'm however surprised that nobody has encountered the problem before.

If somebody is in charge of the package, maybe it could be worth integrating this little modification.

@mykelk mykelk self-assigned this Jun 25, 2020
@mykelk mykelk closed this as completed in c2ef898 Jun 25, 2020
@mykelk
Copy link
Member

mykelk commented Jun 25, 2020

Thanks so much! I think this is due to a recent change in DataFrames.jl.

@phcournede
Copy link
Author

Thanks to all of you for this great package !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants