【问题标题】:'OneHotEncoder' object has no attribute 'get_feature_names'“OneHotEncoder”对象没有属性“get_feature_names”
【发布时间】:2019-12-20 02:24:53
【问题描述】:

我正在尝试使用 scikit learn 的 OneHotEncoder 对象的 get_feature_names 函数提取特征,但它给我一个错误说 "'OneHotEncoder' 对象没有属性 'get_feature_names'"。

下面是代码sn-p

# Creating the object instance for label encoder
encoder = OneHotEncoder(sparse=False)
onehot_encoded = encoder.fit_transform(df[data_column_category])
onehot_encoded_frame = pd.DataFrame(onehot_encoded,columns = encoder.get_feature_names(data_column_category))

【问题讨论】:

    标签: python-3.x


    【解决方案1】:

    该功能是最近推出的,因此您可能只需要更新您的 sklearn 版本。

    你可以这样做:

    pip install -U scikit-learn
    

    【讨论】:

      猜你喜欢
      • 2021-08-06
      • 2021-01-08
      • 2017-11-24
      • 1970-01-01
      • 2023-02-03
      • 1970-01-01
      • 1970-01-01
      • 2012-12-01
      • 2021-08-03
      相关资源
      最近更新 更多