CUSTOMER Latest invoice Weekday
SDK code to create CUSTOMER_Latest_invoice_Weekday¶
Feature description:
Latest invoice Weekday for the customer
In [ ]:
Copied!
import featurebyte as fb
fb.use_profile("tutorial")
import featurebyte as fb
fb.use_profile("tutorial")
Activate catalog¶
In [ ]:
Copied!
catalog = fb.Catalog.activate("Grocery Dataset Tutorial")
catalog = fb.Catalog.activate("Grocery Dataset Tutorial")
Get view from table¶
In [ ]:
Copied!
# Get view from GROCERYINVOICE event table.
groceryinvoice_view = catalog.get_view("GROCERYINVOICE")
# Get view from GROCERYINVOICE event table.
groceryinvoice_view = catalog.get_view("GROCERYINVOICE")
In [ ]:
Copied!
# Extract day_of_week date part from Timestamp column for GROCERYINVOICE view.
groceryinvoice_view["Weekday of invoice"] = groceryinvoice_view["Timestamp"].dt.day_of_week
# Extract day_of_week date part from Timestamp column for GROCERYINVOICE view.
groceryinvoice_view["Weekday of invoice"] = groceryinvoice_view["Timestamp"].dt.day_of_week
Do window aggregation from GROCERYINVOICE¶
See SDK reference for features
See SDK reference to groupby a view
See SDK reference to do aggregation over time
In [ ]:
Copied!
# Group GROCERYINVOICE view by customer entity (GroceryCustomerGuid).
groceryinvoice_view_by_customer =\
groceryinvoice_view.groupby(['GroceryCustomerGuid'])
# Group GROCERYINVOICE view by customer entity (GroceryCustomerGuid).
groceryinvoice_view_by_customer =\
groceryinvoice_view.groupby(['GroceryCustomerGuid'])
In [ ]:
Copied!
# Get Latest invoice Weekday for the customer
customer_latest_invoice_weekday =\
groceryinvoice_view_by_customer.aggregate_over(
"Weekday of invoice", method="latest",
feature_names=["CUSTOMER_Latest_invoice_Weekday"],
windows=[None]
)["CUSTOMER_Latest_invoice_Weekday"]
# Get Latest invoice Weekday for the customer
customer_latest_invoice_weekday =\
groceryinvoice_view_by_customer.aggregate_over(
"Weekday of invoice", method="latest",
feature_names=["CUSTOMER_Latest_invoice_Weekday"],
windows=[None]
)["CUSTOMER_Latest_invoice_Weekday"]
Preview feature¶
Read on the feature primary entity concept
Read on the serving entity concept
In [ ]:
Copied!
#Check the primary entity of the feature'
customer_latest_invoice_weekday.primary_entity
#Check the primary entity of the feature'
customer_latest_invoice_weekday.primary_entity
In [ ]:
Copied!
#Get observation table: 'Preview Table with 10 Customers'
preview_table = catalog.get_observation_table(
"Preview Table with 10 Customers"
).to_pandas()
#Get observation table: 'Preview Table with 10 Customers'
preview_table = catalog.get_observation_table(
"Preview Table with 10 Customers"
).to_pandas()
In [ ]:
Copied!
#Preview CUSTOMER_Latest_invoice_Weekday
customer_latest_invoice_weekday.preview(
preview_table
)
#Preview CUSTOMER_Latest_invoice_Weekday
customer_latest_invoice_weekday.preview(
preview_table
)
Save feature¶
In [ ]:
Copied!
# Save feature
customer_latest_invoice_weekday.save()
# Save feature
customer_latest_invoice_weekday.save()
Add description and see feature definition file¶
In [ ]:
Copied!
# Add description
customer_latest_invoice_weekday.update_description(
"Latest invoice Weekday for the customer"
)
# See feature definition file
customer_latest_invoice_weekday.definition
# Add description
customer_latest_invoice_weekday.update_description(
"Latest invoice Weekday for the customer"
)
# See feature definition file
customer_latest_invoice_weekday.definition