Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

explain_prediction with OneVsRestClassifier and SVC #394

Open
oterrier opened this issue Nov 26, 2020 · 1 comment
Open

explain_prediction with OneVsRestClassifier and SVC #394

oterrier opened this issue Nov 26, 2020 · 1 comment

Comments

@oterrier
Copy link

oterrier commented Nov 26, 2020

Hi
Thx for this great package
It looks like there is an error when you use OneVsRestClassifier with SVCClassifier

I have this error

    if clf.kernel != 'linear':
AttributeError: 'OneVsRestClassifier' object has no attribute 'kernel'

Here is the little code snippet to reproduce the issue:

from sklearn.datasets import make_multilabel_classification, fetch_20newsgroups
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.multiclass import OneVsRestClassifier
from sklearn.svm import SVC

data_train = fetch_20newsgroups(subset='train', shuffle=True, random_state=42)
vectorizer = TfidfVectorizer(stop_words='english')
X_train = vectorizer.fit_transform(data_train.data[0:100])
y_train = data_train.target[0:100]
classif = OneVsRestClassifier(SVC(kernel='linear'))
classif.fit(X_train, y_train)
expl = eli5.explain_prediction(classif, data_train.data[0], vec=vectorizer)

Thx a lot again

Olivier

@oterrier
Copy link
Author

Hi
If you change SVC by LinearSVC in the previous code snippet, it works ... Any reason SVC is not supported the same way?

Best regards
Olivier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant