Home > Mobile >  Sklearn pipeline transform specific columns - ValueError: too many values to unpack (expected 2)
Sklearn pipeline transform specific columns - ValueError: too many values to unpack (expected 2)

Time:05-18

i am trying make pipeline with scaler, onhotencoder, polynomialfeature, and finally linear regression model

from sklearn.pipeline import Pipeline
pipeline = Pipeline([
                    ('scaler', StandardScaler(), num_cols),
                    ('polynom', PolynomialFeatures(3), num_cols), 
                    ('encoder', OneHotEncoder(), cat_cols),
                   ('linear_regression', LinearRegression() )
])

but when i fit the pipeline i have ValueError: too many values to unpack (expected 2)

pipeline.fit(x_train,y_train)
pipeline.score(x_test, y_test)

CodePudding user response:

If I understand correctly, you want to apply some steps of the pipeline to specific columns. Instead of doing it by adding the column names ad the end of the pipeline stage (which is incorrect and causes the error), you have to use a enter image description here

  • Related