当前位置:
首页 >
jupyter notebook 报错:TypeError: __init__() got an unexpected keyword argument ‘categorical_features‘
发布时间:2025/4/5
61
豆豆
生活随笔
收集整理的这篇文章主要介绍了
jupyter notebook 报错:TypeError: __init__() got an unexpected keyword argument ‘categorical_features‘
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
文章目录
- 问题
- 解决
- 参考
问题
报错代码:
# 创建虚拟变量 onehotencoder = OneHotEncoder(categorical_features = [0]) X = onehotencoder.fit_transform(X).toarray() labelencoder_Y = LabelEncoder() Y = labelencoder_Y.fit_transform(Y)解决
新版的sklearn升级了函数接口,导致上述代码不可用。
# 创建虚拟变量 from sklearn.compose import ColumnTransformer onehotencoder = ColumnTransformer([('encoder', OneHotEncoder(), [0])], remainder = 'passthrough') X = onehotencoder.fit_transform(X) labelencoder_Y = LabelEncoder() Y = labelencoder_Y.fit_transform(Y)参考
https://stackoverflow.com/questions/59476165/typeerror-init-got-an-unexpected-keyword-argument-categorical-features
总结
以上是生活随笔为你收集整理的jupyter notebook 报错:TypeError: __init__() got an unexpected keyword argument ‘categorical_features‘的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: jupyter notebook报错:I
- 下一篇: 剑指offer:二叉树的镜像