Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created September 25, 2020 11:32
Show Gist options
  • Save ntakouris/96a29d9fddaa0c0caaadc351b4a0ba13 to your computer and use it in GitHub Desktop.
Save ntakouris/96a29d9fddaa0c0caaadc351b4a0ba13 to your computer and use it in GitHub Desktop.
import tensorflow_transform as tft
def preprocessing_fn(inputs):
"""Preprocess input columns into transformed columns."""
x = inputs['x']
y = inputs['y']
s = inputs['s']
x_centered = x - tft.mean(x)
y_normalized = tft.scale_to_0_1(y)
s_integerized = tft.compute_and_apply_vocabulary(s)
x_centered_times_y_normalized = (x_centered * y_normalized)
return {
'x_centered': x_centered,
'y_normalized': y_normalized,
's_integerized': s_integerized,
'x_centered_times_y_normalized': x_centered_times_y_normalized,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment