Hello,

This is my first post here (I just started with Julia for two weeks and I'm 
very happy)
The problem I'm facing now is calling the sklearn python library via PyCall
This is an example of code

X = reshape(rand(20000),(10000,2))
radius = 0.05

using PyCall
@pyimport sklearn.neighbors as nb
@time balltree = nb.BallTree(X,leaf_size=30)
@time result_test = 
pycall(balltree["query_radius"],PyVector{Array{Int64,1}},X,radius);
@time resultJulia_test = copy(result_test);

elapsed time: 0.005133544 seconds (2204 bytes allocated)
elapsed time: 0.097277762 seconds (680 bytes allocated)
elapsed time: 8.034163516 seconds (20968224 bytes allocated, 4.13% gc time)


The conversion  to julia array takes around 100 times compared to the actual 
calculation

Another thing I tried is to iterate the PyVector 'result_test'. 


function iterate_Pyvector(vec)

    cont = 0
    for v in vec
        cont += 1
    end
end     


@time iterate_Pyvector(result_test)


elapsed time: 7.865199943 seconds (20736288 bytes allocated)


Iteration of 'result_test' takes roughly the same time and the same memory 
allocation as conversion. 

This fact suggests me that conversion is actually happening.


Is there any suggestion to improve performance in both conversion and iteration 
of the vector result_test?


Thanks,

Alberto

Reply via email to