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_features
为None
,则使用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
与输入特征相同。