Use Charmed Feast from Charmed Kubeflow¶
This guide describes how to interact with Charmed Feast from a Notebook within the Charmed Kubeflow (CKF) dashboard.
Set up a Notebook for Charmed Feast¶
From the CKF dashboard, select
Notebooks
in the sidebar.Click
Create a new notebook
.Fill in the required fields such as:
Notebook name
.Notebook image
: You can use the defaultscipy
notebook image, which includes all necessary Feast dependencies.
Expand
Advanced configuration
.Under configuration options, check
Allow access to Feast
.
Warning
This step is required for all notebook images.
Click
Create
to launch the Notebook.
Note
Once the Notebook is running, click Connect
to open the environment.
Install Python dependencies¶
Warning
If you are not using the scipy
notebook image, you must manually install the required Python dependencies.
You can install the package dependencies within a Notebook as follows:
pip install feast[postgres]==0.49.0
Note
The Allow access to Feast
option automatically mounts a feature_store.yaml file into the Notebook.
Its location is set via the FEAST_FS_YAML_FILE_PATH
environment variable.
This configuration is used by the Feast SDK for all operations.
Tip
See Feast integration Notebook for a full Notebook example.
Define and register features using Feast apply¶
The feast apply
command registers new feature definitions and sets up the appropriate data models.
See Feast apply for more details.
You can run the command directly in your Notebook terminal or via script:
feast apply
Materialize data in the online store¶
To serve features at low latency, you must load data into the online store using materialize
.
See Materializing features for more details.
Here’s an example of usage:
store = FeatureStore(repo_path="specs")
start = datetime(2021, 4, 1)
end = datetime.utcnow()
store.materialize(start_date=start, end_date=end)
Retrieve historical features¶
Feast uses PostgreSQL as both its online
and offline
store in the Charmed Feast deployment.
Historical features are retrieved for training models based on timestamps.
See Historical feature retrieval to learn more about it.
Here’s an example of usage:
store = FeatureStore(repo_path="specs")
df = store.get_historical_features(
entity_df=entity_df,
features=[
"driver_hourly_stats2:conv_rate",
"driver_hourly_stats2:acc_rate",
"driver_hourly_stats2:avg_daily_trips",
],
).to_df()
Retrieve online features¶
Online features are served to your model during inference based on a primary key such as driver_id
.
See Retrieving online features for more information.
Here’s an example of usage:
feature_vector = store.get_online_features(
features=[
"driver_hourly_stats2:conv_rate",
"driver_hourly_stats2:acc_rate",
"driver_hourly_stats2:avg_daily_trips",
],
entity_rows=[
{"driver_id": 1004},
{"driver_id": 1005},
],
).to_dict()