Answers for "_init__() got an unexpected keyword argument 'n_features_in_'"

1

__init__() got an unexpected keyword argument 'categorical_features'

from sklearn.preprocessing import LabelEncoder, OneHotEncoder
from sklearn.compose import ColumnTransformer

# Country column
ct = ColumnTransformer([("Country", OneHotEncoder(), [1])], remainder = 'passthrough')
X = ct.fit_transform(X)

# Male/Female
labelencoder_X = LabelEncoder()
X[:, 2] = labelencoder_X.fit_transform(X[:, 2])
Posted by: Guest on August-30-2020
0

TypeError: __init__() got an unexpected keyword argument 'categorical_features\

# Encoding categorical data
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
from sklearn.compose import ColumnTransformer # Here is the one

labelencoder_X_1 = LabelEncoder()
X[:, 1] = labelencoder_X_1.fit_transform(X[:, 1])

labelencoder_X_2 = LabelEncoder()
X[:, 2] = labelencoder_X_2.fit_transform(X[:, 2])

#onehotencoder = OneHotEncoder(categorical_features = [1]) Not this one

# use this instead
ct = ColumnTransformer([("Country", OneHotEncoder(), [1])], remainder = 'passthrough')

X = ct.fit_transform(X)
X = X[:, 1:])
Posted by: Guest on April-08-2022

Code answers related to "_init__() got an unexpected keyword argument 'n_features_in_'"

Code answers related to "Assembly"

Browse Popular Code Answers by Language