Created
July 16, 2019 19:12
-
-
Save apetrov/3140216791e01da27d664b63206f7963 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
feature_columns = [] | |
for feature_name in CATEGORICAL_COLUMNS: | |
vocabulary = df[feature_name].unique() | |
column = tf.feature_column.categorical_column_with_vocabulary_list(feature_name, vocabulary) | |
embedding_column = tf.feature_column.embedding_column(column, dimension=len(vocabulary)) | |
feature_columns.append(embedding_column) | |
for feature_name in NUMERIC_COLUMNS: | |
feature_columns.append(tf.feature_column.numeric_column(feature_name, dtype=tf.float32)) | |
model = tf.keras.models.Sequential([ | |
tf.keras.layers.DenseFeatures(feature_columns), | |
tf.keras.layers.Dense(64), | |
tf.keras.layers.Dense(2,activation='sigmoid') | |
]) | |
X_train, X_test, y_train, y_test = train_test_split(df, df.y) | |
ds = tf.data.Dataset.from_tensor_slices((dict(X_train), y_train)) | |
model.fit(ds,epochs=100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment