Skip to content

Instantly share code, notes, and snippets.

@nl-2021
Created December 9, 2021 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nl-2021/8f99e185523774c2e9682f8933625a5e to your computer and use it in GitHub Desktop.
Save nl-2021/8f99e185523774c2e9682f8933625a5e to your computer and use it in GitHub Desktop.
from datetime import datetime, timedelta
import pandas as pd
from feast import FeatureStore
# The entity dataframe is the dataframe we want to enrich with feature values
entity_df = pd.DataFrame.from_dict(
{
"driver_id": [1001, 1002, 1003],
"label_driver_reported_satisfaction": [1, 5, 3],
"event_timestamp": [
datetime.now() - timedelta(minutes=11),
datetime.now() - timedelta(minutes=36),
datetime.now() - timedelta(minutes=73),
],
}
)
store = FeatureStore(repo_path=".")
training_df = store.get_historical_features(
entity_df=entity_df,
features=[
"driver_hourly_stats:conv_rate",
"driver_hourly_stats:acc_rate",
"driver_hourly_stats:avg_daily_trips",
],
).to_df()
print("----- Feature schema -----\n")
print(training_df.info())
print()
print("----- Example features -----\n")
print(training_df.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment