cstjean / ScikitLearn.jl

Julia implementation of the scikit-learn API https://cstjean.github.io/ScikitLearn.jl/dev/
Other
547 stars 75 forks source link

How to avoid using Conda when using @sk_import #116

Closed CBongiova closed 1 year ago

CBongiova commented 1 year ago

Hi,

I'm using HPC clusters that are incompatible with internet so I'd like to avoid using Conda when using @sk_import in ScikitLearn.jl. However, all my trials have been unsuccessful so far.

For example, when I use ScikitLearn, e.g.:

    using ScikitLearn
    @sk_import decomposition: PCA

I get:

[ Info: Running conda install -y -c conda-forge llvm-openmp in root environment Collecting package metadata (current_repodata.json): done Solving environment: done All requested packages already installed. Retrieving notices: ...working... done

Could anyone help me understanding what is going on? Thanks!

cstjean commented 1 year ago

Haven't looked at that code in a long time, but ScikitLearn being a thin layer on top of PyCall, IIRC you could simply use PyCall's plain imports. https://github.com/JuliaPy/PyCall.jl

Something like

using PyCall
decomposition = pyimport("sklearn.decomposition")
PCA = decomposition.PCA

Then all the ScikitLearn functions will work fine on PCA() objects, and you won't get the error.

You will need to make sure scikit-learn is installed in the python that's used by PyCall, though (or change which python it uses). Check the PyCall docs.

CBongiova commented 1 year ago

@cstjean Thank you! it worked :)