rado
rado

Reputation: 399

Scikit-learn in Python (svm function)

I have this little problem with sklearn in python. It seems that I installed it correctly and indeed when I do from sklearn import svm python seems to be ok with that (no error message). However my function is not working well as I got the message AttributeError: 'module' object has no attribute 'SVC' I'm trying to use svm optimisation function. It is a little bit awkward but this would mean that SVC is not inside sklearn which is not possible. Can anyone help me please.

Upvotes: 2

Views: 26011

Answers (2)

SalazarSid
SalazarSid

Reputation: 64

According to this thread that i had refereed to a couple of days ago,perhaps you can try installing Scipy and then try to restart the python shell.

If it still gives the error try to add the respective package path's to the environment PATH variables.

In any case the link i shared should have multiple solutions to your query.

Upvotes: 0

Joe
Joe

Reputation: 2564

if you:

from sklearn import svm

You are importing the "svm" name from within the sklearn package, into your module as 'svm'. To access objects on it, keep the svm prefix:

svc = svm.SVC()

Another example, you could also do it like this:

import sklearn
svc = sklearn.svm.SVC()

And maybe, you could do this (depends how the package is setup):

from sklearn.svm import SVC
svc = SVC()

Upvotes: 12

Related Questions