Created
July 17, 2018 17:46
-
-
Save crawles/e3f47e10775e9650c2e2ba6bb8dd7f13 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def get_normalization_parameters(traindf, features): | |
"""Get the normalization parameters (E.g., mean, std) for traindf for | |
features. We will use these parameters for training, eval, and serving.""" | |
def _z_score_params(column): | |
mean = traindf[column].mean() | |
std = traindf[column].std() | |
return {'mean': mean, 'std': std} | |
normalization_parameters = {} | |
for column in features: | |
normalization_parameters[column] = _z_score_params(column) | |
return normalization_parameters | |
NUMERIC_FEATURES = ['housing_median_age', 'total_rooms', 'total_bedrooms', | |
'population', 'households', 'median_income'] | |
normalization_parameters = get_normalization_parameters(traindf, NUMERIC_FEATURES) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment