-
-
Save nl-2021/8f99e185523774c2e9682f8933625a5e 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
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