OneToOneFeatureMixin#

class sklearn.base.OneToOneFeatureMixin[source]#

为简单的变换器提供get_feature_names_out方法。

此mixin假设输入特征和输出特征之间存在一对一的对应关系,例如StandardScaler

示例

>>> import numpy as np
>>> from sklearn.base import OneToOneFeatureMixin, BaseEstimator
>>> class MyEstimator(OneToOneFeatureMixin, BaseEstimator):
...     def fit(self, X, y=None):
...         self.n_features_in_ = X.shape[1]
...         return self
>>> X = np.array([[1, 2], [3, 4]])
>>> MyEstimator().fit(X).get_feature_names_out()
array(['x0', 'x1'], dtype=object)
get_feature_names_out(input_features=None)[source]#

获取变换的输出特征名称。

参数:
input_featuresarray-like of str or None, default=None

输入特征。

  • 如果input_featuresNone,则使用feature_names_in_作为输入特征名称。如果feature_names_in_未定义,则生成以下输入特征名称:["x0", "x1", ..., "x(n_features_in_ - 1)"]

  • 如果input_features是类数组对象,则如果feature_names_in_已定义,input_features必须与feature_names_in_匹配。

返回:
feature_names_out字符串对象ndarray

与输入特征相同。