<commit_before># -*- coding: utf-8 -*-
from singledispatch import singledispatch

import numpy as np
import scipy.sparse as sp
from sklearn.linear_model import LogisticRegression, LogisticRegressionCV
from sklearn.linear_model import SGDClassifier, Perceptron
from sklearn.linear_model import PassiveAggressiveClassifier
from sklearn.svm import LinearSVC

from eli5.sklearn.utils import (
    get_feature_names,
    get_coef,
    is_multiclass_classifier,
    is_probabilistic_classifier,
    has_intercept,
    rename_label,
)
from eli5._feature_weights import get_top_features_dict


_TOP = 20


@singledispatch
def explain_prediction(clf, doc, vec=None, top=_TOP, target_names=None,
                       feature_names=None):
    """ Return an explanation of an estimator """
    return {
        "estimator": repr(clf),
        "description": "Error: estimator %r is not supported" % clf,
    }


@explain_prediction.register(LogisticRegression)
@explain_prediction.register(LogisticRegressionCV)
@explain_prediction.register(SGDClassifier)
@explain_prediction.register(PassiveAggressiveClassifier)
@explain_prediction.register(Perceptron)
@explain_prediction.register(LinearSVC)
def explain_prediction_linear(
        clf, doc, vec=None, top=_TOP, target_names=None,
        feature_names=None, vectorized=False):<commit_msg>Get back "vectorized" argument for explain_prediction<commit_after># -*- coding: utf-8 -*-
from singledispatch import singledispatch

import numpy as np
import scipy.sparse as sp
from sklearn.linear_model import LogisticRegression, LogisticRegressionCV
from sklearn.linear_model import SGDClassifier, Perceptron
from sklearn.linear_model import PassiveAggressiveClassifier
from sklearn.svm import LinearSVC

from eli5.sklearn.utils import (
    get_feature_names,
    get_coef,
    is_multiclass_classifier,
    is_probabilistic_classifier,
    has_intercept,
    rename_label,
)
from eli5._feature_weights import get_top_features_dict


_TOP = 20


@singledispatch
def explain_prediction(clf, doc, vec=None, top=_TOP, target_names=None,
                       feature_names=None, vectorized=False):
    """ Return an explanation of an estimator """
    return {
        "estimator": repr(clf),
        "description": "Error: estimator %r is not supported" % clf,
    }


@explain_prediction.register(LogisticRegression)
@explain_prediction.register(LogisticRegressionCV)
@explain_prediction.register(SGDClassifier)
@explain_prediction.register(PassiveAggressiveClassifier)
@explain_prediction.register(Perceptron)
@explain_prediction.register(LinearSVC)
def explain_prediction_linear(
        clf, doc, vec=None, top=_TOP, target_names=None,
        feature_names=None, vectorized=False):
{'fraction_non_alphanumeric': 0.07867647058823529, 'fraction_numerical': 0.003676470588235294, 'mean_word_length': 5.226544622425629, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '953693', 'n_tokens_mistral': 885, 'n_tokens_neox': 856, 'n_words': 181}