Last active
March 5, 2019 02:09
-
-
Save crawles/7f4cf1a6f9fca2012e60b82912554f50 to your computer and use it in GitHub Desktop.
This file contains 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
example = dict(dftrain.head(1)) | |
class_fc = tf.feature_column.indicator_column(tf.feature_column.categorical_column_with_vocabulary_list('class', ('First', 'Second', 'Third'))) | |
print('Feature value: "{}"'.format(example['class'].iloc[0])) | |
print('One-hot encoded: ', tf.keras.layers.DenseFeatures([class_fc])(example).numpy()) | |
# Feature value: "Third" | |
# One-hot encoded: [[0. 0. 1.]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment