Thiago Alexandre
Thiago Alexandre

Reputation: 297

How can I use SVM in Julia language?

I am using the Scikit-Learn of Python in Julia in my code. For example, I used to

using ScikitLearn
@sk_import decomposition: PCA
@sk_import decomposition: KernelPCA

and both work fine. I don´t have a problem.

But when I used this code

using ScikitLearn
@sk_import svm: SVC

for apply Support Vector Machine (SVM) in my code, I got an error that

LoadError: ArgumentError: invalid module

So I read some things about, for instance this https://github.com/cstjean/ScikitLearn.jl and this example https://github.com/cstjean/ScikitLearn.jl/blob/master/examples/Classifier_Comparison_Julia.ipynb but I could not identify what is the problem here.

I have tried to use the package Revise how writing in this link <stackoverflow.com/questions/44997163/sklearn-syntax-error> but this not works too.

Upvotes: 4

Views: 316

Answers (1)

Przemyslaw Szufel
Przemyslaw Szufel

Reputation: 42234

On my machine (Windows, Julia 1.6.0) I could run this import without a problem. Most likely your scikit-learn installation might be broken.

Perhaps you could try:

using Conda
Conda.runconda(`install scikit-learn --force-reinstall --yes`)

In this way you will see what is going on with your scikit-learn

Note that yet another way to test this installation is to run:

svm = pyimport("sklearn.svm")
svm.SVC  # should yield a PyObject

again it will make it possible to check whether the module is there.

Upvotes: 2

Related Questions