‘OneHotEncoder‘ object has no attribute ‘get_feature_names‘解决方案

    • 问题的发现

在聆听sklearn相关课程时,调用get_feature_names()函数出错

‘OneHotEncoder‘ object has no attribute ‘get_feature_names‘解决方案_第1张图片

刚开始以为是由于sklearn的版本过低,故使用了 conda update scikit-learn对sklearn库进行了升级,但问题并没有得到解决。

2.解决方案

使用OneHotEncoder库中的另一个函数:get_feature_names_out()进行替代

‘OneHotEncoder‘ object has no attribute ‘get_feature_names‘解决方案_第2张图片

你可能感兴趣的:(Sklearn学习,sklearn,人工智能,python)