6

I am getting the following error when i perform classification of new data with the following command in Python:

classifier.predict(new_data)

AttributeError: python 'SVC' object has no attribute _dual_coef_

In my laptop though, the command works fine! What's wrong?

3
  • 1
    Are you using the same version on both computers ? Commented Apr 21, 2015 at 13:29
  • yes. It is really weird cause its a basic function of the scikit learn toolkit Commented Apr 21, 2015 at 13:31
  • Can you provide input that causes the error? Commented Apr 21, 2015 at 13:40

4 Answers 4

8

I had this exact error AttributeError: python 'SVC' object has no attribute _dual_coef_ with a model trained using scikit-learn version 0.15.2, when I tried to run it in scikit-learn version 0.16.1. I did solve it by re-training the model in the latest scikit-learn 0.16.1.

Make sure you are loading the right version of the package.

Sign up to request clarification or add additional context in comments.

1 Comment

Too bad old saved models won't run on newer versions... hope there is be a more safe data format in the future.
1

Have you loaded the model based on which you try to predict? In this case it can be a version conflict, try to re-learn the model using the same sklearn version. You can see a similar problem here: Sklearn error: 'SVR' object has no attribute '_impl'

3 Comments

yes, everything is loaded. I am using the same programming pipeline in both computers
Did you tried (or do you have the possibility ) to inverse the computers roles for model construction and prediction?
unfortunately this cannot be done in the present configuration of the computers and the present datasets
1

I had the same problem,I use Sklearn version 0.23.02 but I was trying to run an archive trained with a version 0.18... and my error said: "'SVC' object has no attribute 'break_ties'", I just retrained the model with my version and fix the problem I generate other svc.pickle to run with the 0.23.02 version and replace the oldie.

1 Comment

I am facing the same issue
0
"""
X = X_train 
y =  y_train 
"""
X = X_test 
y =  y_test

# Instantiate and train the classifier
from sklearn.neighbors import KNeighborsClassifier
clf = KNeighborsClassifier(n_neighbors=1)
clf.fit(X, y) 


# Check the results using metrics
from sklearn import metrics
y_pred = clf.predict(X)

print(metrics.confusion_matrix(y_pred, y))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.