How to use the eli5.transform.transform_feature_names.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 / transform.py View on Github external
@transform_feature_names.register(SelectorMixin)
def _select_names(est, in_names=None):
    mask = est.get_support(indices=False)
    in_names = _get_feature_names(est, feature_names=in_names,
                                  num_features=len(mask))
    return [in_names[i] for i in np.flatnonzero(mask)]
github TeamHG-Memex / eli5 / eli5 / sklearn / transform.py View on Github external
@transform_feature_names.register(MaxAbsScaler)
@transform_feature_names.register(RobustScaler)
def _transform_scaling(est, in_names=None):
    if in_names is None:
        in_names = _get_feature_names(est, feature_names=in_names,
                                      num_features=est.scale_.shape[0])
    return [name for name in in_names]
github TeamHG-Memex / eli5 / eli5 / sklearn / transform.py View on Github external
# Feature selection:

@transform_feature_names.register(SelectorMixin)
def _select_names(est, in_names=None):
    mask = est.get_support(indices=False)
    in_names = _get_feature_names(est, feature_names=in_names,
                                  num_features=len(mask))
    return [in_names[i] for i in np.flatnonzero(mask)]

try:
    from sklearn.linear_model import (
        RandomizedLogisticRegression,
        RandomizedLasso,
    )
    _select_names = transform_feature_names.register(RandomizedLasso)(_select_names)
    _select_names = transform_feature_names.register(RandomizedLogisticRegression)(_select_names)
except ImportError:     # Removed in scikit-learn 0.21
    pass


# Scaling

@transform_feature_names.register(MinMaxScaler)
@transform_feature_names.register(StandardScaler)
@transform_feature_names.register(MaxAbsScaler)
@transform_feature_names.register(RobustScaler)
def _transform_scaling(est, in_names=None):
    if in_names is None:
        in_names = _get_feature_names(est, feature_names=in_names,
                                      num_features=est.scale_.shape[0])
    return [name for name in in_names]
github TeamHG-Memex / eli5 / eli5 / sklearn / transform.py View on Github external
@transform_feature_names.register(FeatureUnion)
def _union_names(est, in_names=None):
    return ['{}:{}'.format(trans_name, feat_name)
            for trans_name, trans, _ in est._iter()
            for feat_name in transform_feature_names(trans, in_names)]
github TeamHG-Memex / eli5 / eli5 / sklearn / transform.py View on Github external
@transform_feature_names.register(Pipeline)
def _pipeline_names(est, in_names=None):
    names = in_names
    for name, trans in est.steps:
        if trans is not None:
            names = transform_feature_names(trans, names)
    return names
github TeamHG-Memex / eli5 / eli5 / sklearn / transform.py View on Github external
@transform_feature_names.register(StandardScaler)
@transform_feature_names.register(MaxAbsScaler)
@transform_feature_names.register(RobustScaler)
def _transform_scaling(est, in_names=None):
    if in_names is None:
        in_names = _get_feature_names(est, feature_names=in_names,
                                      num_features=est.scale_.shape[0])
    return [name for name in in_names]
github TeamHG-Memex / eli5 / eli5 / sklearn / transform.py View on Github external
# Feature selection:

@transform_feature_names.register(SelectorMixin)
def _select_names(est, in_names=None):
    mask = est.get_support(indices=False)
    in_names = _get_feature_names(est, feature_names=in_names,
                                  num_features=len(mask))
    return [in_names[i] for i in np.flatnonzero(mask)]

try:
    from sklearn.linear_model import (
        RandomizedLogisticRegression,
        RandomizedLasso,
    )
    _select_names = transform_feature_names.register(RandomizedLasso)(_select_names)
    _select_names = transform_feature_names.register(RandomizedLogisticRegression)(_select_names)
except ImportError:     # Removed in scikit-learn 0.21
    pass


# Scaling

@transform_feature_names.register(MinMaxScaler)
@transform_feature_names.register(StandardScaler)
@transform_feature_names.register(MaxAbsScaler)
@transform_feature_names.register(RobustScaler)
def _transform_scaling(est, in_names=None):
    if in_names is None:
        in_names = _get_feature_names(est, feature_names=in_names,
                                      num_features=est.scale_.shape[0])
    return [name for name in in_names]
github TeamHG-Memex / eli5 / eli5 / sklearn / transform.py View on Github external
@transform_feature_names.register(RobustScaler)
def _transform_scaling(est, in_names=None):
    if in_names is None:
        in_names = _get_feature_names(est, feature_names=in_names,
                                      num_features=est.scale_.shape[0])
    return [name for name in in_names]