Reputation: 1
I am using Jupyter Notebook to run this using a csv file but this is giving an error and I have tried the answer given here: TypeError: __init__() got an unexpected keyword argument 'categorical_features' but that is not helping.I cannot figure out what to do here.
# 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)
Error:
---------------------------------------------------------------------------
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'
Upvotes: 0
Views: 622