我正在使用Jupyter Notebook使用csv文件运行这个,但这给出了一个错误,我已经尝试了这里给出的答案:TypeError: init() got an unexpected keyword argument 'categorical_features'但这没有帮助。我不知道在这里该怎么做。
# Encoding categorical data
# Encoding the Independent Variable
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_X = LabelEncoder()
X[:, 0] = labelencoder_X.fit_transform(X[:, 0])
onehotencoder = OneHotEncoder(categorical_features = [0])
X = onehotencoder.fit_transform(X).toarray()
# Encoding the Dependent Variable
labelencoder_y = LabelEncoder()
y = labelencoder_y.fit_transform(y)
字符串
错误代码:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [22], in <cell line: 24>()
22 labelencoder_X = LabelEncoder()
23 X[:, 0] = labelencoder_X.fit_transform(X[:, 0])
---> 24 onehotencoder = OneHotEncoder(categorical_features = [0])
25 X = onehotencoder.fit_transform(X).toarray()
26 # Encoding the Dependent Variable
TypeError: OneHotEncoder.__init__() got an unexpected keyword argument 'categorical_features'
型
1条答案
按热度按时间ct2axkht1#
scikit-learn的版本不同