0

I am trying out code from Aurelien Geron's book 'Hands-on machine learning'. The part on preparing data for ML algos has the following code on transformation pipelines:

from sklearn.pipeline import FeatureUnion 
num_attribs = list(housing_num)
cat_attribs = ["ocean_proximity"]

num_pipeline = pipeline([
('selector', DataFrameSelector(num_attribs)), ('imputer', Imputer(strategy="median")), ('attribs_adder', CombinedAttributesAdder()), ('std_scaler', StandardScaler()),
])

cat_pipeline = pipeline([
('selector', DataFrameSelector(cat_attribs)), ('label_binarizer', LabelBinarizer()),
])

full_pipeline = FeatureUnion(transformer_list=[ ("num_pipeline", num_pipeline), ("cat_pipeline", cat_pipeline),
])

As I run this, I get an error 'name 'pipeline' is not defined'. How do I overcome this?

  • 2
    In the documentation of this book, it does `from sklearn.pipeline import Pipeline`. Check that P is in capital letter. Probably the error is here. – Alex Serra Marrugat Jun 08 '22 at 08:32
  • 1
    maybe this [link](https://stackoverflow.com/questions/48491566/name-dataframeselector-is-not-defined) help you – I'mahdi Jun 08 '22 at 11:04

0 Answers0