13. Compute Historical Feature Values
Compute historical feature values¶
Historical feature values are needed to train and test Machine Learning models.
Let's take the feature list we just created and compute feature values for a given observation table.
In [1]:
Copied!
import featurebyte as fb
# Set your profile to the tutorial environment
fb.use_profile("tutorial")
catalog_name = "Loan Applications Dataset SDK Tutorial"
catalog = fb.Catalog.activate(catalog_name)
import featurebyte as fb
# Set your profile to the tutorial environment
fb.use_profile("tutorial")
catalog_name = "Loan Applications Dataset SDK Tutorial"
catalog = fb.Catalog.activate(catalog_name)
14:11:26 | INFO | SDK version: 3.0.1.dev45 INFO :featurebyte:SDK version: 3.0.1.dev45 14:11:26 | INFO | No catalog activated. INFO :featurebyte:No catalog activated. 14:11:26 | INFO | Using profile: tutorial INFO :featurebyte:Using profile: tutorial 14:11:27 | INFO | Using configuration file at: /Users/gxav/.featurebyte/config.yaml INFO :featurebyte:Using configuration file at: /Users/gxav/.featurebyte/config.yaml 14:11:27 | INFO | Active profile: tutorial (https://tutorials.featurebyte.com/api/v1) INFO :featurebyte:Active profile: tutorial (https://tutorials.featurebyte.com/api/v1) 14:11:27 | INFO | SDK version: 3.0.1.dev45 INFO :featurebyte:SDK version: 3.0.1.dev45 14:11:27 | INFO | No catalog activated. INFO :featurebyte:No catalog activated. 14:11:27 | INFO | Catalog activated: Loan Applications Dataset SDK Tutorial INFO :featurebyte.api.catalog:Catalog activated: Loan Applications Dataset SDK Tutorial 16:12:25 | WARNING | Remote SDK version (1.1.0.dev7) is different from local (1.1.0.dev1). Update local SDK to avoid unexpected behavior. 16:12:25 | INFO | No catalog activated. 16:12:25 | INFO | Catalog activated: Grocery Dataset Tutorial
List feature lists in Catalog¶
In [2]:
Copied!
catalog.list_feature_lists()
catalog.list_feature_lists()
Out[2]:
id | name | num_feature | status | deployed | readiness_frac | online_frac | tables | entities | primary_entity | created_at | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 683d3c6ea3c52cb2862eea26 | 40 features for Loan Applications | 40 | DRAFT | False | 0.0 | 0.0 | [NEW_APPLICATION, CLIENT_PROFILE, BUREAU, INST... | [New Application, Client] | [New Application] | 2025-06-02T05:53:57.964000 |
Get Feature List from Catalog¶
In [3]:
Copied!
feature_list_name = "40 features for Loan Applications"
simple_feature_list = catalog.get_feature_list(feature_list_name)
feature_list_name = "40 features for Loan Applications"
simple_feature_list = catalog.get_feature_list(feature_list_name)
Loading Feature(s) |████████████████████████████████████████| 40/40 [100%] in 0.
Get an observation table¶
In [4]:
Copied!
# List observation tables
catalog.list_observation_tables()
# List observation tables
catalog.list_observation_tables()
Out[4]:
id | name | type | shape | feature_store_name | created_at | |
---|---|---|---|---|---|---|
0 | 683d3bde07274be4537267b1 | Applications up to Sept 2024 with Loan Defaults | source_table | [303270, 3] | playground | 2025-06-02T05:51:37.364000 |
In [5]:
Copied!
# Get observation table: 'Applications up to Sept 2024 with Loan Defaults'
training_observations = catalog.get_observation_table("Applications up to Sept 2024 with Loan Defaults")
# Get observation table: 'Applications up to Sept 2024 with Loan Defaults'
training_observations = catalog.get_observation_table("Applications up to Sept 2024 with Loan Defaults")
Compute historical features¶
In [6]:
Copied!
# Create training data
training_data_table = simple_feature_list.compute_historical_feature_table(
training_observations,
historical_feature_table_name=f"{feature_list_name} - TRAIN",
)
# Create training data
training_data_table = simple_feature_list.compute_historical_feature_table(
training_observations,
historical_feature_table_name=f"{feature_list_name} - TRAIN",
)
Done! |████████████████████████████████████████| 100% in 2:02.4 (0.01%/s) Done! |████████████████████████████████████████| 100% in 36.4s (0.03%/s)
In [7]:
Copied!
# List historical feature tables from catalog
catalog.list_historical_feature_tables()
# List historical feature tables from catalog
catalog.list_historical_feature_tables()
Out[7]:
id | name | feature_store_name | observation_table_name | shape | created_at | |
---|---|---|---|---|---|---|
0 | 683d3c98954f0aa89942addd | 40 features for Loan Applications - TRAIN | playground | Applications up to Sept 2024 with Loan Defaults | [303270, 43] | 2025-06-02T05:56:31.688000 |
Concepts in this tutorial¶
SDK reference for¶
- Historical feature table
- FeatureList.compute historical feature table()
- FeatureList.compute_historical_features() to compute directly a data frame