-
Notifications
You must be signed in to change notification settings - Fork 76
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
ScikitLearn declared inside a module causes segmentation error #50
Comments
The purpose for this thing is to create a wrapper to have common API between caret of RCall and scikitlearn of PyCall |
Thank you for the report. I've hit several segmentation faults myself in Julia 1.1, but this is the first occurrence with ScikitLearn. It might be interesting to reduce it as much as possible and report that to Julialang. That said, it's not surprising that |
Thanks for the reply. I resolved it by adding: |
I think the bug occurred when they decided to make precompiling as the default which was changed in this PR: JuliaLang/julia#26282 |
Yeah. It's that when precompiling, it stores the values of all global variables. |
For anyone who's still wondering here's a snippet that worked for me. using ScikitLearn
using PyCall
const mixture = PyNULL()
function __init__()
copy!(mixture, pyimport("sklearn.mixture"))
end
### Usage
gmm_config = mixture.BayesianGaussianMixture(n_components=10,
max_iter=1000,
weight_concentration_prior=1.0)
model = fit!(gmm_config, samples[:,:])
w = model.weights_[:,1,1]
μ = model.means_[:,1,1]
σ = sqrt.(model.covariances_[:,1,1])
### |
Tested in Julia 1.0.3 and Julia 1.1 and Julia 0.7
To recreate the problem:
create package A
pkg] generate A
bash> cd A
pkg] activate .
pkg] add ScikitLearn
julia> edit("src/A.jl")
-----
module A
using ScikitLearn
@sk_import linear_model: LogisticRegression
function testme()
model = LogisticRegression()
end
end
---
julia> using A
julia> A.testme() -> causes segmentation error
However, if you use:
julia> include("src/A.jl")
julia> A.testme() -> works
The text was updated successfully, but these errors were encountered: