Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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)
@explain_weights.register(OneVsRestClassifier)
def explain_weights_ovr(ovr, **kwargs):
estimator = ovr.estimator
func = explain_weights.dispatch(estimator.__class__)
return func(ovr, **kwargs)
def deco(f):
return explain_weights.register(cls)(
explain_weights_sklearn.register(cls)(f))
return deco
@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``,
@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.
@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,
)