-
-
Save amankharwal/a9daf07b6f71a63178a95c254b092bbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.preprocessing import OneHotEncoder | |
from sklearn.pipeline import Pipeline | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.impute import SimpleImputer | |
num_pipeline = Pipeline([ | |
('imputer',SimpleImputer(strategy="median")), | |
('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