Serve historical feature values Stay organized with collections Save and categorize content based on your preferences.
Preview
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.
If you need to retrieve or serve current as well as historicalfeature data, use offline serving to fetch feature values fromBigQuery. For example, you can use offline serving to retrievethe feature values for specific timestamps to train a model.
All feature data, including historical feature data, is maintained inBigQuery, which constitutes the offline store for your feature values.To use offline serving, you must first register your BigQuerydata source by creating feature groups and feature values. Also, in the case ofoffline serving, every row containing the same entity ID must have adifferent timestamp. For more information about data sourcepreparation guidelines, seePrepare data source.
Before you begin
Authenticate toVertex AI, unless you've done so already.
To use the Python samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
If you're using a local shell, then create local authentication credentials for your user account:
gcloudauthapplication-defaultlogin
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
Fetch historical feature values
Use the following sample to fetch historical values from a feature from multipleentity IDs and timestamps.
Python
Before trying this sample, follow thePython setup instructions in theVertex AI quickstart using client libraries. For more information, see theVertex AIPython API reference documentation.
To authenticate to Vertex AI, set up Application Default Credentials. For more information, seeSet up authentication for a local development environment.
importbigframesimportbigframes.pandasimportpandasaspdfromgoogle.cloudimportbigqueryfromvertexai.resources.preview.feature_storeimport(Feature,FeatureGroup,offline_store)fromvertexai.resources.preview.feature_storeimportutilsasfs_utilsfg=FeatureGroup("FEATURE_GROUP_NAME")f1=fg.get_feature("FEATURE_NAME_1")f2=fg.get_feature("FEATURE_NAME_2")entity_df=pd.DataFrame(data={"ENTITY_ID_COLUMN":["ENTITY_ID_1","ENTITY_ID_2",],"timestamp":[pd.Timestamp("FEATURE_TIMESTAMP_1"),pd.Timestamp("FEATURE_TIMESTAMP_2"),],},)offline_store.fetch_historical_feature_values(entity_df=entity_df,features=[f1,f2],)Replace the following:
FEATURE_GROUP_NAME: The name of the existing feature groupcontaining the feature.
FEATURE_NAME_1 andFEATURE_NAME_2: The names of theregistered features from which you want to retrieve the feature values.
ENTITY_ID_COLUMN: The name of the column containing the entity IDs.You can specify a column name only if it's registered in the feature group.
ENTITY_ID_1 andENTITY_ID_2: The entity IDs for whichyou want to fetch the feature values. If you want to retrieve feature valuesfor the same entity ID at different timestamps, specify the same entity IDcorresponding to each timestamp.
FEATURE_TIMESTAMP_1 andFEATURE_TIMESTAMP_2: Thetimestamps corresponding to the historical feature values you want to retrieve.FEATURE_TIMESTAMP_1 corresponds toENTITY_ID_1,FEATURE_TIMESTAMP_2 corresponds toENTITY_ID_2, and so on.Specify the timestamps in the datetime format—for example,
2024-05-01T12:00:00.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.