2

I'm trying to build simple pipeline:

from sklearn.linear_model import Lasso
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import make_pipeline


make_pipeline([
    ('PolynomialFeatures', PolynomialFeatures(include_bias=False)),
    ('Lasso', Lasso(fit_intercept=True, max_iter=1000))])

And I'm getting error:

TypeError: Last step of Pipeline should implement fit or be the string 'passthrough'. '[('PolynomialFeatures', PolynomialFeatures(include_bias=False)), ('Lasso', Lasso())]' (type <class 'list'>) doesn't

What is wrong ? How can I fix it ?

Boom
  • 1,145
  • 18
  • 44

1 Answers1

4

you should use pipeline instead of make_pipeline due to you provided the steps with names (more on this here!).

from sklearn.linear_model import Lasso
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import make_pipeline, Pipeline


Pipeline([
    ('PolynomialFeatures', PolynomialFeatures(include_bias=False)),
    ('Lasso', Lasso(fit_intercept=True, max_iter=1000))])

output:

Pipeline(steps=[('PolynomialFeatures', PolynomialFeatures(include_bias=False)),
                ('Lasso', Lasso())])
meti
  • 1,921
  • 1
  • 8
  • 15