Skip to content

6. Formulate Use Cases

Why Create a Use Case? Creating a Use Case in FeatureByte, while optional, offers significant benefits. It not only defines the goal and application of your prediction model but also helps organize your training data and improve post-deployment feature monitoring. Plus, it's used by FeatureByte Copilot to suggest features tailored to your use cases.

We'll Create Two Use Cases for Our Grocery Dataset:

  • Customer Expenditure Prediction: In-Store forecast of customer spending on product groups within two weeks.
  • Customer Segmentation: Segment customers active in the last 12 weeks.

Step 1: Establish a Target

In FeatureByte, you can set a target in two ways:

For the first Use Case (expenditure prediction), we'll follow the logical approach and define the target in the SDK.

For the second Use Case (segmentation), being an unsupervised Machine Learning problem without specific target values, we'll describe the target directly in the UI.

Create Target in the SDK

When you define Target Objects using the Python SDK, employ forward operations (different from backward operations for features).

More details on how to create a Target in SDK

Further information can be found in our SDK reference for Target.

Use the provided Python code snippet in a notebook, to create the target "CUSTOMER_x_PRODUCTGROUP_Sum_of_TotalCost_next_2_weeks".

import featurebyte as fb
# Set your profile to the tutorial environment
fb.use_profile("tutorial")
# Activate catalog
catalog = fb.Catalog.activate("Grocery Dataset UI Tutorial")
# Get view from GROCERYPRODUCT dimension table.
groceryproduct_view = catalog.get_view("GROCERYPRODUCT")
# Get view from INVOICEITEMS item table.
invoiceitems_view = catalog.get_view("INVOICEITEMS")
# Join GROCERYPRODUCT view to INVOICEITEMS view.
invoiceitems_view = invoiceitems_view.join(groceryproduct_view, rsuffix="")
# Create target by summing the TotalCost column in the next 14d
# per customer (GroceryCustomerGuid) and productgroup (ProductGroup)
target = invoiceitems_view\
    .groupby(['GroceryCustomerGuid', 'ProductGroup'])\
    .forward_aggregate(
        "TotalCost", method="sum",
        target_name="CUSTOMER_x_PRODUCTGROUP_Sum_of_TotalCost_next_2_weeks",
        window='14d',
        fill_value=0
    )
target.save()
target.update_description(
    "Sum of Total spent by the customer for a given product group over the next 14d period."
)

Once you ran the notebook, the target should appear in the Target Catalog under the 'Formulate' section of the menu.

Target Catalog with the SDK target

Create Target in the UI

Navigate to the Target catalog from the 'Formulate' section of the menu.

Click "Add Target".

Describe the customer segmentation target:

  • Target Name: Customer Segmentation
  • Primary Entity: customer
  • Description: Unsupervised customer segmentation into 8 groups

Create Unsurpervised Target

Note that the Catalog has now two targets listed.

Target Catalog

Step 2: Create a Context

A Context defines the scope and circumstances in which features are expected to be served.

Navigate to the Context catalog from the Formulate section of the menu.

Click "Add Context".

Empty Context Catalog

Describe the Context for the first use case (Customer Expenditure Prediction):

  • Context Name: In-Store Customer Engagement with ProductGroup
  • Primary Entity: customer, productgroup
  • Description: Evaluate future customer engagement with ProductGroup during its visit in the store to improve its shopping experience.

Create Customer x Product Group Context

Describe the Context for the second use case (Customer Segmentation):

  • Context Name: Active Customers in real-time scenarios
  • Primary Entity: customer
  • Description: Real-time predictions for Customers who have completed purchases within the last 12 weeks

Create Active Customer Context

The Catalog has now two contexts listed.

Context Catlog

Step 3: Create a Use Case

Link your Use Case with the appropriate Context and Target.

Note

Detailed use case descriptions enhance FeatureByte's capability to provide relevant feature suggestions.

Navigate to the Use Case catalog from the 'Formulate' section of the menu.

Click "Add Use Case".

Empty Use Case Catalog

The first use case can be described as follows:

  • Use Case Name: In-Store Prediction of Customer Spending on a given Product Group next 2 Weeks
  • Primary Entity: customer, productgroup
  • Context: In-Store Customer Engagement with ProductGroup
  • Target: CUSTOMER_x_PRODUCTGROUP_Sum_of_TotalCost_next_2_weeks
  • Description: Predict the expenditure of customer on a specific product group within a two-week period starting from the time of its visit in the store. This use case will help improve customer shopping experience.

Create Customer x Product Group Use Case

The second use case can be described as follows:

  • Use Case Name: Active Customer Real-time Segmentation
  • Primary Entity: customer
  • Context: Active Customers in real-time scenarios
  • Target: Customer Segmentation
  • Description: Segment in real-time active customers who have been active in the last 12 weeks

Create Customer Use Case

The Catalog has now two use cases listed.

Use Case Catalog