How to use the eli5.explain.explain_weights.register function in eli5

To help you get started, we’ve selected a few eli5 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TeamHG-Memex / eli5 / eli5 / sklearn_crfsuite / explain_weights.py View on Github external
@explain_weights.register(CRF)
def explain_weights_sklearn_crfsuite(crf,
                                     top=20,
                                     target_names=None,
                                     targets=None,
                                     feature_re=None,
                                     feature_filter=None):
    """ Explain sklearn_crfsuite.CRF weights.

    See :func:`eli5.explain_weights` for description of
    ``top``, ``target_names``, ``targets``,
    ``feature_re`` and ``feature_filter`` parameters.
    """
    feature_names = np.array(crf.attributes_)
    state_coef = crf_state_coef(crf).todense().A
    transition_coef = crf_transition_coef(crf)
github TeamHG-Memex / eli5 / eli5 / sklearn / explain_weights.py View on Github external
@explain_weights.register(OneVsRestClassifier)
def explain_weights_ovr(ovr, **kwargs):
    estimator = ovr.estimator
    func = explain_weights.dispatch(estimator.__class__)
    return func(ovr, **kwargs)
github TeamHG-Memex / eli5 / eli5 / sklearn / explain_weights.py View on Github external
def deco(f):
        return explain_weights.register(cls)(
            explain_weights_sklearn.register(cls)(f))
    return deco
github TeamHG-Memex / eli5 / eli5 / lightgbm.py View on Github external
@explain_weights.register(lightgbm.LGBMRegressor)
def explain_weights_lightgbm(lgb,
                             vec=None,
                             top=20,
                             target_names=None,  # ignored
                             targets=None,  # ignored
                             feature_names=None,
                             feature_re=None,
                             feature_filter=None,
                             importance_type='gain',
                             ):
    """
    Return an explanation of an LightGBM estimator (via scikit-learn wrapper
    LGBMClassifier or LGBMRegressor) as feature importances.

    See :func:`eli5.explain_weights` for description of
    ``top``, ``feature_names``,
github TeamHG-Memex / eli5 / eli5 / catboost.py View on Github external
@explain_weights.register(catboost.CatBoost)
@explain_weights.register(catboost.CatBoostClassifier)
@explain_weights.register(catboost.CatBoostRegressor)
def explain_weights_catboost(catb, 
                             vec=None,
                             top=20,
                             importance_type='PredictionValuesChange',
                             feature_names=None,
                             pool=None
                             ):
    """
    Return an explanation of an CatBoost estimator (CatBoostClassifier,
    CatBoost, CatBoostRegressor) as feature importances.

    See :func:`eli5.explain_weights` for description of
    ``top``, ``feature_names``,
    ``feature_re`` and ``feature_filter`` parameters.
github TeamHG-Memex / eli5 / eli5 / lightning.py View on Github external
@explain_weights.register(BaseEstimator)
def explain_weights_lightning_not_supported(
        estimator, vec=None, top=20, target_names=None,
        targets=None, feature_names=None,
        coef_scale=None):
    return Explanation(
        estimator=repr(estimator),
        error="Error: estimator %r is not supported" % estimator,
    )