我在使用 onehotencoder 时遇到此错误,其中缺少 thecategorical_features 属性,我正在使用 google colab。
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
le = LabelEncoder()
X = star.iloc[:,:6].values
y = star.iloc[:,-1].values
X[:,5] = le.fit_transform(X[:,5])
y[:] = le.fit_transform(y[:])
ohe = OneHotEncoder(categorical_features= [5])
X = ohe.fit_transform(X).toarray()
TypeError Traceback (most recent call last)
<ipython-input-47-93f73a1a04ad> in <module>()
----> 1 ohe = OneHotEncoder(categorical_features= [5])
2 X = ohe.fit_transform(X).toarray()
TypeError: __init__() got an unexpected keyword argument 'categorical_features'
Run Code Online (Sandbox Code Playgroud)