Skip to content

Instantly share code, notes, and snippets.

@bgweber
Last active November 12, 2018 22:34
Show Gist options
  • Save bgweber/82b6d11b95e5f5c62855d60f5f1605b0 to your computer and use it in GitHub Desktop.
Save bgweber/82b6d11b95e5f5c62855d60f5f1605b0 to your computer and use it in GitHub Desktop.
# create feature encodings for the event and description fields
es = ft.EntitySet(id="plays")
es = es.entity_from_dataframe(entity_id="plays", dataframe=plays_df, index="play_id",
variable_types = { "event": ft.variable_types.Categorical,
"description": ft.variable_types.Categorical })
f1 = Feature(es["plays"]["event"])
f2 = Feature(es["plays"]["description"])
encoded, _= ft.encode_features(plays_df, [f1, f2], top_n=10)
encoded.reset_index(inplace=True)
# create an entry set of the encoded play data and games
es = ft.EntitySet(id="plays")
es = es.entity_from_dataframe(entity_id="plays", dataframe=encoded, index="play_id")
es = es.normalize_entity(base_entity_id="plays",new_entity_id="games", index="game_id")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment