jupyter notebook 报错:TypeError: __init__() got an unexpected keyword argument ‘categorical_features‘
生活随笔
收集整理的這篇文章主要介紹了
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:二叉树的镜像