mlxtend version: 0.23.1

ColumnSelector

ColumnSelector(cols=None, drop_axis=False)

用于从数据集中选择特定列的对象.

Parameters

Examples

有关使用示例,请参见 https://rasbt.github.io/mlxtend/user_guide/feature_selection/ColumnSelector/

Methods


fit(X, y=None)

Mock方法.什么也不做.

Parameters

Returns

self


fit_transform(X, y=None)

返回输入数组的切片.

Parameters

Returns


get_metadata_routing()

Get metadata routing of this object.

Please check :ref:`User Guide <metadata_routing>` on how the routing
mechanism works.

Returns


get_params(deep=True)

Get parameters for this estimator.

Parameters

Returns


set_params(params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects
(such as :class:`~sklearn.pipeline.Pipeline`). The latter have
parameters of the form ``<component>__<parameter>`` so that it's
possible to update each component of a nested object.

Parameters

Returns


transform(X, y=None)

返回输入数组的切片.

Parameters

Returns

ExhaustiveFeatureSelector

ExhaustiveFeatureSelector(estimator, min_features=1, max_features=1, print_progress=True, scoring='accuracy', cv=5, n_jobs=1, pre_dispatch='2n_jobs', clone_estimator=True, fixed_features=None, feature_groups=None)*

Exhaustive Feature Selection for Classification and Regression. (new in v0.4.3)

Parameters

Attributes

Notes

(1) 如果参数feature_groups不为None,特征数量等于特征组的数量,即len(feature_groups).例如,如果feature_groups = [[0], [1], [2, 3], [4]],那么max_features的值不能超过4.

(2) 尽管两个或多个单独的特征可能在整个特征选择过程中被视为一个组,但这并不意味着该组的单个特征对结果有相同的影响.例如,在线性回归中,特征2和3的系数可能不同,即使它们在feature_groups中被视为一个组.

(3) 如果同时指定了fixed_features和feature_groups,请确保每个特征组包含fixed_features选择.例如,对于一个3特征集,fixed_features=[0, 1]和feature_groups=[[0, 1], [2]]是有效的;fixed_features=[0, 1]和feature_groups=[[0], [1, 2]]是无效的.

(4) 在KeyboardInterrupt的情况下,字典subsets可能未完成.如果用户仍然对获取最佳分数感兴趣,他们可以使用方法`finalize_fit`.

Examples

有关使用示例,请参见 https://rasbt.github.io/mlxtend/user_guide/feature_selection/ExhaustiveFeatureSelector/

Methods


finalize_fit()

None


fit(X, y, groups=None, fit_params)

执行特征选择并从训练数据中学习模型.

Parameters

Returns


fit_transform(X, y, groups=None, fit_params)

拟合训练数据并返回从X中选出的最佳特征.

Parameters

Returns

X的特征子集, shape={n_samples, k_features}


get_metadata_routing()

Get metadata routing of this object.

Please check :ref:`User Guide <metadata_routing>` on how the routing
mechanism works.

Returns


get_metric_dict(confidence_interval=0.95)

返回指标字典

Parameters

Returns

字典,其中每个字典值都是一个列表,列表长度为迭代次数(特征子集数量). 这些列表对应的字典键如下: 'feature_idx': 特征子集的索引元组 'cv_scores': 各个交叉验证分数的列表 'avg_score': 交叉验证平均分数 'std_dev': 交叉验证分数平均值的标准差 'std_err': 交叉验证分数平均值的标准误差 'ci_bound': 交叉验证分数平均值的置信区间边界


get_params(deep=True)

Get parameters for this estimator.

Parameters

Returns


set_fit_request(self: mlxtend.feature_selection.exhaustive_feature_selector.ExhaustiveFeatureSelector, , groups: Union[bool, NoneType, str] = '$UNCHANGED$') -> mlxtend.feature_selection.exhaustive_feature_selector.ExhaustiveFeatureSelector*

Request metadata passed to the fit method.

Note that this method is only relevant if
``enable_metadata_routing=True`` (see :func:`sklearn.set_config`).
Please see :ref:`User Guide <metadata_routing>` on how the routing
mechanism works.

The options for each parameter are:

- ``True``: metadata is requested, and passed to ``fit`` if provided. The request is ignored if metadata is not provided.

- ``False``: metadata is not requested and the meta-estimator will not pass it to ``fit``.

- ``None``: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

- ``str``: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (``sklearn.utils.metadata_routing.UNCHANGED``) retains the
existing request. This allows you to change the request for some
parameters and not others.

.. versionadded:: 1.3

.. note::
This method is only relevant if this estimator is used as a
sub-estimator of a meta-estimator, e.g. used inside a
:class:`~sklearn.pipeline.Pipeline`. Otherwise it has no effect.

Parameters

Returns


set_params(params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects
(such as :class:`~sklearn.pipeline.Pipeline`). The latter have
parameters of the form ``<component>__<parameter>`` so that it's
possible to update each component of a nested object.

Parameters

Returns


transform(X)

返回从X中选出的最佳特征.

Parameters

Returns

X的特征子集,shape={n_samples, k_features}

SequentialFeatureSelector

SequentialFeatureSelector(estimator, k_features=1, forward=True, floating=False, verbose=0, scoring=None, cv=5, n_jobs=1, pre_dispatch='2n_jobs', clone_estimator=True, fixed_features=None, feature_groups=None)*

顺序特征选择用于分类和回归.

Parameters

Attributes

Notes

(1) 如果参数 feature_groups 不为 None,特征数量等于特征组的数量,即 len(feature_groups). 例如,如果 feature_groups = [[0], [1], [2, 3], [4]],则 max_features 值不能超过 4.

(2) 尽管两个或多个单独的特征可能在整个特征选择过程中被视为一组,但这并不意味着这些特征对结果的影响相同.
例如,在线性回归中,特征 2 和 3 的系数可能不同,即使它们在 feature_groups 中被视为一组.

(3) 如果同时指定了 fixed_features 和 feature_groups,请确保每个特征组包含 fixed_features 选择.
例如,对于一个 3 特征集,fixed_features=[0, 1] 和 feature_groups=[[0, 1], [2]] 是有效的;
fixed_features=[0, 1] 和 feature_groups=[[0], [1, 2]] 是无效的.

(4) 在 KeyboardInterrupt 的情况下,字典 subsets 可能未完成.如果用户仍对获取最佳分数感兴趣,他们可以使用方法 `finalize_fit`.

Examples

有关使用示例,请参见 https://rasbt.github.io/mlxtend/user_guide/feature_selection/SequentialFeatureSelector/

Methods


finalize_fit()

None


fit(X, y, groups=None, fit_params)

执行特征选择并从训练数据中学习模型.

Parameters

Returns


fit_transform(X, y, groups=None, fit_params)

拟合训练数据后,将X缩减为其最重要的特征.

Parameters

Returns

X的缩减特征子集,shape={n_samples, k_features}


generate_error_message_k_features(name)

None


get_metadata_routing()

Get metadata routing of this object.

Please check :ref:`User Guide <metadata_routing>` on how the routing
mechanism works.

Returns


get_metric_dict(confidence_interval=0.95)

返回指标字典

Parameters

Returns

字典,其中每个字典值都是一个列表,列表的长度为迭代次数(特征子集的数量). 这些列表对应的字典键如下: 'feature_idx': 特征子集的索引元组 'cv_scores': 各个交叉验证评分列表 'avg_score': 交叉验证评分平均值 'std_dev': 交叉验证评分平均值的标准差 'std_err': 交叉验证评分平均值的标准误差 'ci_bound': 交叉验证评分平均值的置信区间边界


get_params(deep=True)

Get parameters for this estimator.

Parameters

Returns


set_fit_request(self: mlxtend.feature_selection.sequential_feature_selector.SequentialFeatureSelector, , groups: Union[bool, NoneType, str] = '$UNCHANGED$') -> mlxtend.feature_selection.sequential_feature_selector.SequentialFeatureSelector*

Request metadata passed to the fit method.

Note that this method is only relevant if
``enable_metadata_routing=True`` (see :func:`sklearn.set_config`).
Please see :ref:`User Guide <metadata_routing>` on how the routing
mechanism works.

The options for each parameter are:

- ``True``: metadata is requested, and passed to ``fit`` if provided. The request is ignored if metadata is not provided.

- ``False``: metadata is not requested and the meta-estimator will not pass it to ``fit``.

- ``None``: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

- ``str``: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (``sklearn.utils.metadata_routing.UNCHANGED``) retains the
existing request. This allows you to change the request for some
parameters and not others.

.. versionadded:: 1.3

.. note::
This method is only relevant if this estimator is used as a
sub-estimator of a meta-estimator, e.g. used inside a
:class:`~sklearn.pipeline.Pipeline`. Otherwise it has no effect.

Parameters

Returns


set_params(params)

设置此估计器的参数. 有效参数键可以通过 get_params() 列出.

Returns

self


transform(X)

Reduce X to its most important features.

Parameters

Returns

Reduced feature subset of X, shape={n_samples, k_features}

Properties


named_estimators

Returns

命名估计器元组列表,例如 [('svc', SVC(...))]