在学习OReilly.Hands-On.Machine.Learning.with.Scikit-Learn.and.TensorFlow.2017.3时,执行以下代码会出错:
from sklearn.pipeline import FeatureUnion
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
num_attribs = ['longitude',
'latitude',
'housing_median_age',
'total_rooms',
'total_bedrooms',
'population',
'households',
'median_income']
cat_attribs = ["ocean_proximity"]
# 在sklearn 0.19下,由于LabelBinarizer的重写而导致代码失效
num_pipeline = Pipeline([
('selector', DataFrameSelector(num_attribs)),
('imputer', Imputer(strategy="median"