13. Create Feature List
Create a feature list¶
A feature list is an essential component in machine learning, comprising a collection of features that are used to train models. Let's compile a feature list using some of the features we've created.
In [1]:
Copied!
import featurebyte as fb
# Set your profile to the tutorial environment
fb.use_profile("tutorial")
catalog_name = "Grocery 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 = "Grocery Dataset SDK Tutorial"
catalog = fb.Catalog.activate(catalog_name)
11:15:26 | INFO | SDK version: 3.2.0.dev66 INFO :featurebyte:SDK version: 3.2.0.dev66 11:15:26 | INFO | No catalog activated. INFO :featurebyte:No catalog activated. 11:15:26 | INFO | Using profile: staging INFO :featurebyte:Using profile: staging 11:15:26 | INFO | Using configuration file at: /Users/gxav/.featurebyte/config.yaml INFO :featurebyte:Using configuration file at: /Users/gxav/.featurebyte/config.yaml 11:15:26 | INFO | Active profile: staging (https://staging.featurebyte.com/api/v1) INFO :featurebyte:Active profile: staging (https://staging.featurebyte.com/api/v1) 11:15:26 | INFO | SDK version: 3.2.0.dev66 INFO :featurebyte:SDK version: 3.2.0.dev66 11:15:26 | INFO | No catalog activated. INFO :featurebyte:No catalog activated. 11:15:26 | INFO | Catalog activated: Grocery Dataset SDK Tutorial INFO :featurebyte.api.catalog:Catalog activated: Grocery Dataset SDK Tutorial 16:11:44 | INFO | Using configuration file at: /Users/gxav/.featurebyte/config.yaml 16:11:44 | INFO | Active profile: tutorial (https://tutorials.featurebyte.com/api/v1) 16:11:44 | WARNING | Remote SDK version (1.1.0.dev7) is different from local (1.1.0.dev1). Update local SDK to avoid unexpected behavior. 16:11:44 | INFO | No catalog activated. 16:11:44 | INFO | Catalog activated: Grocery Dataset Tutorial
List all features we created so far¶
In [2]:
Copied!
catalog.list_features()
catalog.list_features()
Out[2]:
id | name | dtype | readiness | online_enabled | tables | primary_tables | entities | primary_entities | created_at | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 68ef1190b71c16b74514b83d | CUSTOMER_vs_OVERALL_item_TotalCost_across_prod... | FLOAT | DRAFT | False | [GROCERYINVOICE, INVOICEITEMS, GROCERYPRODUCT] | [INVOICEITEMS] | [customer] | [customer] | 2025-10-15T03:14:38.474000 |
1 | 68ef116a37e5b9ed2860624a | CUSTOMER_Latest_invoice_Amount_Z_Score_to_invo... | FLOAT | DRAFT | False | [GROCERYINVOICE] | [GROCERYINVOICE] | [customer] | [customer] | 2025-10-15T03:13:51.207000 |
2 | 68ef112acbdce2fa954f3f85 | CUSTOMER_Std_of_invoice_Amount_28d | FLOAT | DRAFT | False | [GROCERYINVOICE] | [GROCERYINVOICE] | [customer] | [customer] | 2025-10-15T03:13:06.351000 |
3 | 68ef112acbdce2fa954f3f84 | CUSTOMER_Std_of_invoice_Amount_14d | FLOAT | DRAFT | False | [GROCERYINVOICE] | [GROCERYINVOICE] | [customer] | [customer] | 2025-10-15T03:13:05.888000 |
4 | 68ef112acbdce2fa954f3f83 | CUSTOMER_Avg_of_invoice_Amount_28d | FLOAT | DRAFT | False | [GROCERYINVOICE] | [GROCERYINVOICE] | [customer] | [customer] | 2025-10-15T03:13:05.462000 |
5 | 68ef112acbdce2fa954f3f82 | CUSTOMER_Avg_of_invoice_Amount_14d | FLOAT | DRAFT | False | [GROCERYINVOICE] | [GROCERYINVOICE] | [customer] | [customer] | 2025-10-15T03:13:05.011000 |
6 | 68ef112acbdce2fa954f3f81 | CUSTOMER_Count_of_invoice_28d | INT | DRAFT | False | [GROCERYINVOICE] | [GROCERYINVOICE] | [customer] | [customer] | 2025-10-15T03:13:04.596000 |
7 | 68ef112acbdce2fa954f3f80 | CUSTOMER_Count_of_invoice_14d | INT | DRAFT | False | [GROCERYINVOICE] | [GROCERYINVOICE] | [customer] | [customer] | 2025-10-15T03:13:04.233000 |
8 | 68ef112acbdce2fa954f3f7f | CUSTOMER_Latest_invoice_Amount | FLOAT | DRAFT | False | [GROCERYINVOICE] | [GROCERYINVOICE] | [customer] | [customer] | 2025-10-15T03:13:03.880000 |
9 | 68ef112acbdce2fa954f3f7b | CUSTOMER_x_PRODUCTGROUP_Sum_of_item_TotalCost_28d | FLOAT | DRAFT | False | [GROCERYINVOICE, INVOICEITEMS, GROCERYPRODUCT] | [INVOICEITEMS] | [customer, productgroup] | [customer, productgroup] | 2025-10-15T03:13:03.465000 |
10 | 68ef112acbdce2fa954f3f7a | CUSTOMER_x_PRODUCTGROUP_Sum_of_item_TotalCost_14d | FLOAT | DRAFT | False | [GROCERYINVOICE, INVOICEITEMS, GROCERYPRODUCT] | [INVOICEITEMS] | [customer, productgroup] | [customer, productgroup] | 2025-10-15T03:13:02.976000 |
11 | 68ef112acbdce2fa954f3f7e | CUSTOMER_x_PRODUCTGROUP_Time_Since_Latest_Time... | FLOAT | DRAFT | False | [GROCERYINVOICE, INVOICEITEMS, GROCERYPRODUCT] | [INVOICEITEMS] | [customer, productgroup] | [customer, productgroup] | 2025-10-15T03:13:02.464000 |
12 | 68ef110cd0ec86dc5121f2a2 | CUSTOMER_Age_band | VARCHAR | DRAFT | False | [GROCERYCUSTOMER] | [GROCERYCUSTOMER] | [customer] | [customer] | 2025-10-15T03:12:26.082000 |
13 | 68ef110cd0ec86dc5121f298 | CUSTOMER_Age | INT | DRAFT | False | [GROCERYCUSTOMER] | [GROCERYCUSTOMER] | [customer] | [customer] | 2025-10-15T03:12:19.677000 |
Get features from catalog¶
In [3]:
Copied!
customer_age_band = catalog.get_feature("CUSTOMER_Age_band")
customer_latest_invoice_amount = catalog.get_feature("CUSTOMER_Latest_invoice_Amount")
customer_count_of_invoice_14d = catalog.get_feature("CUSTOMER_Count_of_invoice_14d")
customer_avg_of_invoice_amount_14d = catalog.get_feature("CUSTOMER_Avg_of_invoice_Amount_14d")
customer_std_of_invoice_amount_14d = catalog.get_feature("CUSTOMER_Std_of_invoice_Amount_14d")
customer_latest_invoice_amount_Z_score_to_invoice_amount_28d = catalog.get_feature(
"CUSTOMER_Latest_invoice_Amount_Z_Score_to_invoice_Amount_28d"
)
customer_vs_overall_item_totalcost_across_product_productgroups_26w = catalog.get_feature(
"CUSTOMER_vs_OVERALL_item_TotalCost_across_product_ProductGroups_26w"
)
customer_x_productgroup_sum_of_item_totalcost_14d = \
catalog.get_feature("CUSTOMER_x_PRODUCTGROUP_Sum_of_item_TotalCost_14d")
customer_x_productgroup_time_since_latest_timestamp = \
catalog.get_feature("CUSTOMER_x_PRODUCTGROUP_Time_Since_Latest_Timestamp")
customer_age_band = catalog.get_feature("CUSTOMER_Age_band")
customer_latest_invoice_amount = catalog.get_feature("CUSTOMER_Latest_invoice_Amount")
customer_count_of_invoice_14d = catalog.get_feature("CUSTOMER_Count_of_invoice_14d")
customer_avg_of_invoice_amount_14d = catalog.get_feature("CUSTOMER_Avg_of_invoice_Amount_14d")
customer_std_of_invoice_amount_14d = catalog.get_feature("CUSTOMER_Std_of_invoice_Amount_14d")
customer_latest_invoice_amount_Z_score_to_invoice_amount_28d = catalog.get_feature(
"CUSTOMER_Latest_invoice_Amount_Z_Score_to_invoice_Amount_28d"
)
customer_vs_overall_item_totalcost_across_product_productgroups_26w = catalog.get_feature(
"CUSTOMER_vs_OVERALL_item_TotalCost_across_product_ProductGroups_26w"
)
customer_x_productgroup_sum_of_item_totalcost_14d = \
catalog.get_feature("CUSTOMER_x_PRODUCTGROUP_Sum_of_item_TotalCost_14d")
customer_x_productgroup_time_since_latest_timestamp = \
catalog.get_feature("CUSTOMER_x_PRODUCTGROUP_Time_Since_Latest_Timestamp")
Create feature list¶
In [4]:
Copied!
simple_feature_list = fb.FeatureList(
[
customer_age_band,
customer_latest_invoice_amount,
customer_count_of_invoice_14d,
customer_avg_of_invoice_amount_14d,
customer_std_of_invoice_amount_14d,
customer_latest_invoice_amount_Z_score_to_invoice_amount_28d,
customer_vs_overall_item_totalcost_across_product_productgroups_26w,
customer_x_productgroup_sum_of_item_totalcost_14d,
customer_x_productgroup_time_since_latest_timestamp,
],
name="Customer x ProductGroup Simple FeatureList",
)
simple_feature_list = fb.FeatureList(
[
customer_age_band,
customer_latest_invoice_amount,
customer_count_of_invoice_14d,
customer_avg_of_invoice_amount_14d,
customer_std_of_invoice_amount_14d,
customer_latest_invoice_amount_Z_score_to_invoice_amount_28d,
customer_vs_overall_item_totalcost_across_product_productgroups_26w,
customer_x_productgroup_sum_of_item_totalcost_14d,
customer_x_productgroup_time_since_latest_timestamp,
],
name="Customer x ProductGroup Simple FeatureList",
)
Preview feature list¶
In [5]:
Copied!
# Check the primary entity of the feature list
simple_feature_list.primary_entity
# Check the primary entity of the feature list
simple_feature_list.primary_entity
Out[5]:
[<featurebyte.api.entity.Entity at 0x31444eac0> { 'name': 'customer', 'created_at': '2025-10-15T03:06:58.482000', 'updated_at': '2025-10-15T03:07:01.153000', 'description': None, 'serving_names': [ 'GROCERYCUSTOMERGUID' ], 'catalog_name': 'Grocery Dataset SDK Tutorial' }, <featurebyte.api.entity.Entity at 0x31442ba10> { 'name': 'productgroup', 'created_at': '2025-10-15T03:06:59.192000', 'updated_at': '2025-10-15T03:07:02.278000', 'description': None, 'serving_names': [ 'PRODUCTGROUP' ], 'catalog_name': 'Grocery Dataset SDK Tutorial' }]
In [6]:
Copied!
# Get observation table: 'Preview Table with 10 items'
preview_table = catalog.get_observation_table("Preview Table with 10 items")
# Get observation table: 'Preview Table with 10 items'
preview_table = catalog.get_observation_table("Preview Table with 10 items")
In [7]:
Copied!
# Preview simple_feature_list
simple_feature_list.preview(preview_table)
# Preview simple_feature_list
simple_feature_list.preview(preview_table)
Out[7]:
POINT_IN_TIME | GROCERYINVOICEITEMGUID | CUSTOMER_Age_band | CUSTOMER_Latest_invoice_Amount | CUSTOMER_Count_of_invoice_14d | CUSTOMER_Avg_of_invoice_Amount_14d | CUSTOMER_Std_of_invoice_Amount_14d | CUSTOMER_Latest_invoice_Amount_Z_Score_to_invoice_Amount_28d | CUSTOMER_vs_OVERALL_item_TotalCost_across_product_ProductGroups_26w | CUSTOMER_x_PRODUCTGROUP_Sum_of_item_TotalCost_14d | CUSTOMER_x_PRODUCTGROUP_Time_Since_Latest_Timestamp | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2023-04-07 13:41:35 | f017e72e-1645-4fbe-988e-a9c09920c506 | 20-24 | 2.29 | 6 | 14.563333 | 9.129048 | -1.230802 | 0.806031 | 4.57 | 261.460556 |
1 | 2023-01-08 15:40:02 | 879de04d-36ef-49a3-b1f7-a96495100dbe | 40-44 | 1.47 | 4 | 7.605000 | 5.901197 | -1.031903 | 0.629724 | NaN | 2974.097500 |
2 | 2022-07-14 18:12:49 | a3245668-aeba-4259-87e1-1b99a1e7391c | 45-49 | 3.28 | 1 | 3.280000 | 0.000000 | NaN | 0.828964 | NaN | 1400.391944 |
3 | 2022-12-01 13:28:57 | 600a7549-9f3e-42f9-8408-e3996d6c4750 | 50-54 | 8.00 | 1 | 8.000000 | 0.000000 | -1.184455 | 0.733438 | NaN | 385.071944 |
4 | 2022-10-03 12:02:23 | f25a7864-4e0d-43bb-8191-0ffdf56b5a21 | 60-64 | 16.21 | 3 | 15.686667 | 10.151717 | -0.422419 | 0.751749 | NaN | 2017.952500 |
5 | 2022-12-12 10:27:30 | 9526bbd7-3b85-4bd5-99d7-2eecda85ada2 | 50-54 | 29.00 | 2 | 19.200000 | 9.800000 | -0.342691 | 0.750365 | 5.99 | 73.632222 |
6 | 2022-09-12 16:29:49 | f7de9fec-9e01-4478-8b2e-5a17427a53c1 | 30-34 | 63.04 | 7 | 20.120000 | 22.723340 | 1.963783 | 0.631107 | 6.79 | 217.573333 |
7 | 2023-03-18 09:43:40 | 7ec0da36-b85f-47cf-873e-461b5c2b1cbf | 30-34 | 26.01 | 8 | 21.716250 | 18.080614 | 0.413984 | 0.816261 | NaN | 1458.053889 |
8 | 2023-05-14 15:41:46 | e904b0bc-b342-4491-a7d9-216489b6ac01 | 50-54 | 67.87 | 1 | 67.870000 | 0.000000 | 1.000000 | 0.649150 | NaN | 768.540278 |
9 | 2022-10-30 09:08:11 | 5ee681b9-583c-4968-88bb-993704a6c54e | 85-89 | 51.02 | 2 | 87.385000 | 36.365000 | -1.000000 | 0.573548 | 7.47 | 113.858889 |
Save feature list¶
In [8]:
Copied!
# Save feature list
simple_feature_list.save()
# Add description
simple_feature_list.update_description("Simple feature list for the customer x productgroup engagement")
# Save feature list
simple_feature_list.save()
# Add description
simple_feature_list.update_description("Simple feature list for the customer x productgroup engagement")
Done! |████████████████████████████████████████| 100% in 3.1s (0.32%/s) Done! |████████████████████████████████████████| 100% in 6.1s (0.17%/s) Loading Feature(s) |████████████████████████████████████████| 9/9 [100%] in 0.4s Done! |████████████████████████████████████████| 100% in 6.1s (0.17%/s) Done! |████████████████████████████████████████| 100% in 6.1s (0.17%/s) Loading Feature(s) |████████████████████████████████████████| 9/9 [100%] in 0.4s