Skip to content

explain_prediction with OneVsRestClassifier and SVC #394

@oterrier

Description

@oterrier

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions