Advertisement
elena1234

scaling, standardization and Z score in Python

Mar 22nd, 2023 (edited)
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. titanic.fare.plot(figsize = (12,8))
  2. titanic.age.plot(figsize = (12,8))
  3. plt.show()
  4.  
  5. mean_age = titanic.age.mean()
  6. mean_fare = titanic.fare.mean()
  7.  
  8. std_age = titanic.age.std()
  9. std_fare = titanic.fare.std()
  10.  
  11. titanic["age_z"] = round((titanic.age-mean_age) / std_age,2)
  12. titanic["fare_z"] = round((titanic.fare-mean_fare) / std_fare,2)
  13.  
  14. round(titanic.describe(),2)
  15.  
  16. titanic.fare_z.plot(figsize = (12,8))
  17. titanic.age_z.plot(figsize = (12,8))
  18. plt.show()
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement