How to use the eli5.explain.explain_prediction.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 / lightning.py View on Github external
_REGRESSORS = [
    regression.AdaGradRegressor,
    regression.CDRegressor,
    regression.FistaRegressor,
    regression.LinearSVR,
    regression.SAGARegressor,
    regression.SAGRegressor,
    regression.SDCARegressor,
    regression.SGDRegressor,
    # regression.SVRGRegressor
]

for clf in _CLASSIFIERS:
    explain_weights.register(clf, explain_linear_classifier_weights)
    explain_weights_lightning.register(clf, explain_linear_classifier_weights)
    explain_prediction.register(clf, explain_prediction_linear_classifier)
    explain_prediction_lightning.register(clf, explain_prediction_linear_classifier)


for reg in _REGRESSORS:
    explain_weights.register(reg, explain_linear_regressor_weights)
    explain_weights_lightning.register(reg, explain_linear_regressor_weights)
    explain_prediction.register(reg, explain_prediction_linear_regressor)
    explain_prediction_lightning.register(reg, explain_prediction_linear_regressor)
github TeamHG-Memex / eli5 / eli5 / keras / explain_prediction.py View on Github external
@explain_prediction.register(Model)
def explain_prediction_keras(model, # type: Model
                             doc, # type: np.ndarray
                             targets=None, # type: Optional[list]
                             layer=None, # type: Optional[Union[int, str, Layer]]
                             image=None,
                             ):
    # type: (...) -> Explanation
    """
    Explain the prediction of a Keras classifier with the Grad-CAM technique.

    We explicitly assume that the model's task is classification, i.e. final output is class scores.

    :param keras.models.Model model:
        Instance of a Keras neural network model,
        whose predictions are to be explained.
github TeamHG-Memex / eli5 / eli5 / lightgbm.py View on Github external
@explain_prediction.register(lightgbm.LGBMClassifier)
@explain_prediction.register(lightgbm.LGBMRegressor)
def explain_prediction_lightgbm(
        lgb, doc,
        vec=None,
        top=None,
        top_targets=None,
        target_names=None,
        targets=None,
        feature_names=None,
        feature_re=None,
        feature_filter=None,
        vectorized=False,
        ):
    """ Return an explanation of LightGBM prediction (via scikit-learn wrapper
    LGBMClassifier or LGBMRegressor) as feature weights.
github TeamHG-Memex / eli5 / eli5 / lightning.py View on Github external
@explain_prediction.register(BaseEstimator)
def explain_prediction_lightning_not_supported(
        estimator, doc, vec=None, top=None,
        target_names=None, targets=None,
        feature_names=None, vectorized=False,
        coef_scale=None):
    return Explanation(
        estimator=repr(estimator),
        error="Error: estimator %r is not supported" % estimator,
    )
github TeamHG-Memex / eli5 / eli5 / sklearn / explain_prediction.py View on Github external
def deco(f):
        return explain_prediction.register(cls)(
            explain_prediction_sklearn.register(cls)(f))
    return deco
github TeamHG-Memex / eli5 / eli5 / sklearn / explain_prediction.py View on Github external
@explain_prediction.register(OneVsRestClassifier)
def explain_prediction_ovr(clf, doc, **kwargs):
    estimator = clf.estimator
    func = explain_prediction.dispatch(estimator.__class__)
    return func(clf, doc, **kwargs)
github TeamHG-Memex / eli5 / eli5 / xgboost.py View on Github external
@explain_prediction.register(XGBClassifier)
@explain_prediction.register(XGBRegressor)
@explain_prediction.register(Booster)
def explain_prediction_xgboost(
        xgb, doc,
        vec=None,
        top=None,
        top_targets=None,
        target_names=None,
        targets=None,
        feature_names=None,
        feature_re=None,  # type: Pattern[str]
        feature_filter=None,
        vectorized=False,  # type: bool
        is_regression=None,  # type: bool
        missing=None,  # type: bool
        ):