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

normalize.py 921 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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  1. """
  2. Standard Scaling the raw data
  3. """
  4. from sklearn.preprocessing import StandardScaler
  5. from mltrace import create_component, register
  6. import numpy as np
  7. import pickle
  8. @register(
  9. component_name="Pre-Processing", input_vars=["filename"], output_vars=["clean_version"]
  10. )
  11. def normalize():
  12. print("Normalizing the data")
  13. print("Loading split data")
  14. x_train = np.load("../data/processed_data/x_train.npy")
  15. x_test = np.load("../data/processed_data/x_test.npy")
  16. print("done")
  17. print("Scaling data with Standard Scaler")
  18. scaling = StandardScaler()
  19. scaling.fit(x_train)
  20. print("done")
  21. with open("../data/scaling_model.pkl", "wb") as x_f:
  22. pickle.dump(scaling, x_f)
  23. if __name__ == '__main__':
  24. # Create component
  25. create_component(
  26. name="Pre-Processing",
  27. description="Normalizes data",
  28. owner="shreyas",
  29. tags=["etl"],
  30. )
  31. normalize()
Tip!

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

Comments

Loading...