mlxtend version: 0.23.1

Adaline

Adaline(eta=0.01, epochs=50, minibatches=None, random_seed=None, print_progress=0)

自适应线性神经元分类器.

请注意,此实现的自适应线性神经元分类器期望二元类别标签 {0, 1}.

Parameters

Attributes

Examples

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

Methods


fit(X, y, init_params=True)

学习训练数据中的模型.

Parameters

Returns


get_params(deep=True)

获取此估计器的参数.

Parameters

Returns


predict(X)

预测目标值.

Parameters

Returns


score(X, y)

计算预测准确率

Parameters

Returns


set_params(params)

设置此估计器的参数. 该方法适用于简单估计器以及嵌套对象(如管道). 后者具有形式为<组件>__<参数>的参数,以便可以更新嵌套对象的每个组件.

Returns

self

改编自
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py
作者: Gael Varoquaux <gael.varoquaux@normalesup.org>
许可证: BSD 3条款

EnsembleVoteClassifier

EnsembleVoteClassifier(clfs, voting='hard', weights=None, verbose=0, use_clones=True, fit_base_estimators=True)

软投票/多数规则分类器,适用于scikit-learn估计器.

Parameters

Attributes

Examples

```
>>> import numpy as np
>>> from sklearn.linear_model import LogisticRegression
>>> from sklearn.naive_bayes import GaussianNB
>>> from sklearn.ensemble import RandomForestClassifier
>>> from mlxtend.sklearn import EnsembleVoteClassifier
>>> clf1 = LogisticRegression(random_seed=1)
>>> clf2 = RandomForestClassifier(random_seed=1)
>>> clf3 = GaussianNB()
>>> X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
>>> y = np.array([1, 1, 1, 2, 2, 2])
>>> eclf1 = EnsembleVoteClassifier(clfs=[clf1, clf2, clf3],
... voting='hard', verbose=1)
>>> eclf1 = eclf1.fit(X, y)
>>> print(eclf1.predict(X))
[1 1 1 2 2 2]
>>> eclf2 = EnsembleVoteClassifier(clfs=[clf1, clf2, clf3], voting='soft')
>>> eclf2 = eclf2.fit(X, y)
>>> print(eclf2.predict(X))
[1 1 1 2 2 2]
>>> eclf3 = EnsembleVoteClassifier(clfs=[clf1, clf2, clf3],
...                          voting='soft', weights=[2,1,1])
>>> eclf3 = eclf3.fit(X, y)
>>> print(eclf3.predict(X))
[1 1 1 2 2 2]
>>>

更多使用示例,请参见
https://rasbt.github.io/mlxtend/user_guide/classifier/EnsembleVoteClassifier/

```

Methods


fit(X, y, sample_weight=None)

学习每个分类器的训练数据权重系数.

Parameters

Returns


fit_transform(X, y=None, fit_params)

Fit to data, then transform it.

Fits transformer to `X` and `y` with optional parameters `fit_params`
and returns a transformed version of `X`.

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)

返回用于支持 GridSearch 的估计器参数名称.


predict(X)

预测X的类别标签.

Parameters

Returns


predict_proba(X)

预测X的类别概率.

Parameters

Returns


score(X, y, sample_weight=None)

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy
which is a harsh metric since you require for each sample that
each label set be correctly predicted.

Parameters

Returns


set_fit_request(self: mlxtend.classifier.ensemble_vote.EnsembleVoteClassifier, , sample_weight: Union[bool, NoneType, str] = '$UNCHANGED$') -> mlxtend.classifier.ensemble_vote.EnsembleVoteClassifier*

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_output(, transform=None)*

Set output container.

See :ref:`sphx_glr_auto_examples_miscellaneous_plot_set_output.py`
for an example on how to use the API.

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


set_score_request(self: mlxtend.classifier.ensemble_vote.EnsembleVoteClassifier, , sample_weight: Union[bool, NoneType, str] = '$UNCHANGED$') -> mlxtend.classifier.ensemble_vote.EnsembleVoteClassifier*

Request metadata passed to the score 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 ``score`` 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 ``score``.

- ``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


transform(X)

返回每个估计器对X的类别标签或概率.

Parameters

Returns

LogisticRegression

LogisticRegression(eta=0.01, epochs=50, l2_lambda=0.0, minibatches=1, random_seed=None, print_progress=0)

逻辑回归分类器.

请注意,此逻辑回归实现期望二元类别标签为 {0, 1}.

Parameters

Attributes

Examples

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

Methods


fit(X, y, init_params=True)

学习训练数据中的模型.

Parameters

Returns


get_params(deep=True)

获取此估计器的参数.

Parameters

Returns


predict(X)

预测目标值.

Parameters

Returns


predict_proba(X)

Predict class probabilities of X from the net input.

Parameters

Returns


score(X, y)

计算预测准确率

Parameters

Returns


set_params(params)

设置此估计器的参数. 该方法适用于简单估计器以及嵌套对象(如管道). 后者具有形式为<组件>__<参数>的参数,以便可以更新嵌套对象的每个组件.

Returns

self

改编自
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py
作者: Gael Varoquaux <gael.varoquaux@normalesup.org>
许可证: BSD 3条款

MultiLayerPerceptron

MultiLayerPerceptron(eta=0.5, epochs=50, hidden_layers=[50], n_classes=None, momentum=0.0, l1=0.0, l2=0.0, dropout=1.0, decrease_const=0.0, minibatches=1, random_seed=None, print_progress=0)

多层感知器分类器,采用逻辑S形激活函数

Parameters

Attributes

Examples

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

Methods


fit(X, y, init_params=True)

学习训练数据中的模型.

Parameters

Returns


get_params(deep=True)

获取此估计器的参数.

Parameters

Returns


predict(X)

预测目标值.

Parameters

Returns


predict_proba(X)

Predict class probabilities of X from the net input.

Parameters

Returns


score(X, y)

计算预测准确率

Parameters

Returns


set_params(params)

设置此估计器的参数. 该方法适用于简单估计器以及嵌套对象(如管道). 后者具有形式为<组件>__<参数>的参数,以便可以更新嵌套对象的每个组件.

Returns

self

改编自
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py
作者: Gael Varoquaux <gael.varoquaux@normalesup.org>
许可证: BSD 3条款

OneRClassifier

OneRClassifier(resolve_ties='first')

OneR(一规则)分类器.

Parameters

Attributes

Methods


fit(X, y)

学习训练数据中的规则.

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


predict(X)

预测X的类别标签.

Parameters

Returns


score(X, y, sample_weight=None)

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy
which is a harsh metric since you require for each sample that
each label set be correctly predicted.

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


set_score_request(self: mlxtend.classifier.oner.OneRClassifier, , sample_weight: Union[bool, NoneType, str] = '$UNCHANGED$') -> mlxtend.classifier.oner.OneRClassifier*

Request metadata passed to the score 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 ``score`` 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 ``score``.

- ``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

Perceptron

Perceptron(eta=0.1, epochs=50, random_seed=None, print_progress=0)

感知器分类器.

请注意,此感知器的实现期望二元类别标签为 {0, 1}.

Parameters

Attributes

Examples

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

Methods


fit(X, y, init_params=True)

学习训练数据中的模型.

Parameters

Returns


get_params(deep=True)

获取此估计器的参数.

Parameters

Returns


predict(X)

预测目标值.

Parameters

Returns


score(X, y)

计算预测准确率

Parameters

Returns


set_params(params)

设置此估计器的参数. 该方法适用于简单估计器以及嵌套对象(如管道). 后者具有形式为<组件>__<参数>的参数,以便可以更新嵌套对象的每个组件.

Returns

self

改编自
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py
作者: Gael Varoquaux <gael.varoquaux@normalesup.org>
许可证: BSD 3条款

SoftmaxRegression

SoftmaxRegression(eta=0.01, epochs=50, l2=0.0, minibatches=1, n_classes=None, random_seed=None, print_progress=0)

软性最大回归分类器.

Parameters

Attributes

Examples

使用示例请参见 https://rasbt.github.io/mlxtend/user_guide/classifier/SoftmaxRegression/

Methods


fit(X, y, init_params=True)

学习训练数据中的模型.

Parameters

Returns


get_params(deep=True)

获取此估计器的参数.

Parameters

Returns


predict(X)

预测目标值.

Parameters

Returns


predict_proba(X)

Predict class probabilities of X from the net input.

Parameters

Returns


score(X, y)

计算预测准确率

Parameters

Returns


set_params(params)

设置此估计器的参数. 该方法适用于简单估计器以及嵌套对象(如管道). 后者具有形式为<组件>__<参数>的参数,以便可以更新嵌套对象的每个组件.

Returns

self

改编自
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py
作者: Gael Varoquaux <gael.varoquaux@normalesup.org>
许可证: BSD 3条款

StackingCVClassifier

StackingCVClassifier(classifiers, meta_classifier, use_probas=False, drop_proba_col=None, cv=2, shuffle=True, random_state=None, stratify=True, verbose=0, use_features_in_secondary=False, store_train_meta_features=False, use_clones=True, n_jobs=None, pre_dispatch='2n_jobs')*

scikit-learn 估计器的"堆叠交叉验证”分类器.

在 mlxtend v0.4.3 中新增

Parameters

Attributes

Examples

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

Methods


decision_function(X)

预测X的类别置信度得分.

Parameters

Returns


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

拟合集成分类器和元分类器.

Parameters

Returns


fit_transform(X, y=None, fit_params)

Fit to data, then transform it.

Fits transformer to `X` and `y` with optional parameters `fit_params`
and returns a transformed version of `X`.

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)

返回用于网格搜索支持的估计器参数名称.


predict(X)

预测目标值.

Parameters

Returns


predict_meta_features(X)

获取测试数据的元特征.

Parameters

Returns


predict_proba(X)

预测X的类别概率.

Parameters

Returns


score(X, y, sample_weight=None)

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy
which is a harsh metric since you require for each sample that
each label set be correctly predicted.

Parameters

Returns


set_fit_request(self: mlxtend.classifier.stacking_cv_classification.StackingCVClassifier, , groups: Union[bool, NoneType, str] = '$UNCHANGED$', sample_weight: Union[bool, NoneType, str] = '$UNCHANGED$') -> mlxtend.classifier.stacking_cv_classification.StackingCVClassifier*

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_output(, transform=None)*

Set output container.

See :ref:`sphx_glr_auto_examples_miscellaneous_plot_set_output.py`
for an example on how to use the API.

Parameters

Returns


set_params(params)

设置此估计器的参数.

有效的参数键可以通过 ``get_params()`` 列出.

Returns

self


set_score_request(self: mlxtend.classifier.stacking_cv_classification.StackingCVClassifier, , sample_weight: Union[bool, NoneType, str] = '$UNCHANGED$') -> mlxtend.classifier.stacking_cv_classification.StackingCVClassifier*

Request metadata passed to the score 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 ``score`` 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 ``score``.

- ``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

Properties


named_classifiers

None

StackingClassifier

StackingClassifier(classifiers, meta_classifier, use_probas=False, drop_proba_col=None, average_probas=False, verbose=0, use_features_in_secondary=False, store_train_meta_features=False, use_clones=True, fit_base_estimators=True)

一个用于分类的scikit-learn估计器的堆叠分类器.

Parameters

Attributes

Examples

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

Methods


decision_function(X)

预测X的类别置信度得分.

Parameters

Returns


fit(X, y, sample_weight=None)

拟合集成分类器和元分类器.

Parameters

Returns


fit_transform(X, y=None, fit_params)

Fit to data, then transform it.

Fits transformer to `X` and `y` with optional parameters `fit_params`
and returns a transformed version of `X`.

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)

返回估计器参数名称以支持网格搜索.


predict(X)

预测目标值.

Parameters

Returns


predict_meta_features(X)

获取测试数据的元特征.

Parameters

Returns


predict_proba(X)

预测X的类别概率.

Parameters

Returns


score(X, y, sample_weight=None)

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy
which is a harsh metric since you require for each sample that
each label set be correctly predicted.

Parameters

Returns


set_fit_request(self: mlxtend.classifier.stacking_classification.StackingClassifier, , sample_weight: Union[bool, NoneType, str] = '$UNCHANGED$') -> mlxtend.classifier.stacking_classification.StackingClassifier*

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_output(, transform=None)*

Set output container.

See :ref:`sphx_glr_auto_examples_miscellaneous_plot_set_output.py`
for an example on how to use the API.

Parameters

Returns


set_params(params)

设置此估计器的参数.

有效的参数键可以通过 ``get_params()`` 列出.

Returns

self


set_score_request(self: mlxtend.classifier.stacking_classification.StackingClassifier, , sample_weight: Union[bool, NoneType, str] = '$UNCHANGED$') -> mlxtend.classifier.stacking_classification.StackingClassifier*

Request metadata passed to the score 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 ``score`` 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 ``score``.

- ``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

Properties


named_classifiers

None