Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from sklearn.preprocessing import OneHotEncoder
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.impute import SimpleImputer
num_pipeline = Pipeline([
('attribs_adder', CombinedAttributesAdder()),
('std_scaler', StandardScaler()),
housing_num_tr = num_pipeline.fit_transform(housing_num)
from sklearn.compose import ColumnTransformer
num_attribs = list(housing_num)
cat_attribs = ["ocean_proximity"]
full_pipeline = ColumnTransformer([
("num", num_pipeline, num_attribs),
("cat", OneHotEncoder(), cat_attribs),
housing_prepared = full_pipeline.fit_transform(housing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment