Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

transform.py 803 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  1. from sklearn.preprocessing import StandardScaler, OneHotEncoder
  2. from sklearn.compose import ColumnTransformer
  3. from sklearn.compose import make_column_selector as selector
  4. def preprocess():
  5. numeric_transformer = StandardScaler(with_mean=True, with_std=True)
  6. categorical_transformer = OneHotEncoder(handle_unknown='ignore')
  7. preprocessor = ColumnTransformer(
  8. transformers=[
  9. ('num', numeric_transformer, selector(dtype_exclude=object)),#self.numeric_features),
  10. ('cat', categorical_transformer, selector(dtype_include=object))#self.categorical_features)
  11. ],
  12. remainder='passthrough'
  13. )
  14. return preprocessor
  15. preprocess()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...