Generally, Pipelines are used like this: pipe.fit(X_train, y_train). All transformer methds are fitted and transformed on X_train. Y train is only used for fitting the model. How I can construct a pipeline that transforms y_train? I have y which includes valyes ">=50k" and "<50k". I want to use LabelEncoder as transformer method.
X = df.drop('income', axis=1)
y = df[['income']]
y_preprocessing = Pipeline([
("labelencoder", LabelEncoder())
])
preprocessing = ColumnTransformer([
("y_preprocessing", y_preprocessing, ['income'])
])
when using
y_preprocessing.fit(y)
It gives a TypeError:
TypeError: fit() takes 2 positional arguments but 3 were given
when using
preprocessing.fit(y)
It also gives a TypeError:
TypeError: fit_transform() takes 2 positional arguments but 3 were given