Guest User

Untitled

a guest
Jul 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. def get_normalization_parameters(traindf, features):
  2. """Get the normalization parameters (E.g., mean, std) for traindf for
  3. features. We will use these parameters for training, eval, and serving."""
  4.  
  5. def _z_score_params(column):
  6. mean = traindf[column].mean()
  7. std = traindf[column].std()
  8. return {'mean': mean, 'std': std}
  9.  
  10. normalization_parameters = {}
  11. for column in features:
  12. normalization_parameters[column] = _z_score_params(column)
  13. return normalization_parameters
  14.  
  15. NUMERIC_FEATURES = ['housing_median_age', 'total_rooms', 'total_bedrooms',
  16. 'population', 'households', 'median_income']
  17. normalization_parameters = get_normalization_parameters(traindf, NUMERIC_FEATURES)
Add Comment
Please, Sign In to add comment