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.

Let's Create a Use Case for Our Grocery Dataset:

Customer Activity Next 1 week before a purchase: Predicting whether a customer will remain active during the two weeks following this purchase. The prediction is made just before the customer completes the purchase to enhance engagement of loyal customers during the transaction.

Step 1: Establish a Target

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

We'll follow first the logical approach and define the target in the SDK.

For those who don't have access to the SDK, we'll describe the target directly in the UI and create the same use case but using this descriptive target.

Create Target in the SDK

When defining Target Objects with the Python SDK, it's crucial to use 'forward operations' which focus on future outcomes or predictions, unlike 'backward operations' typically used for features. For more details, refer to our SDK reference on Target.

If you have installed FeatureByte SDK, use the provided Python code snippet in a notebook, to create the target "CUSTOMER_More_than_1_purchase_next_7d". If you prefer a no-code approach, follow the instructions in the descriptive approach section.

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.
invoice_view = catalog.get_view("GROCERYINVOICE")

# Groupby by Customer
invoice_view_by_customer = invoice_view.groupby(['GroceryCustomerGuid'])

# Count the number of invoices the next 7 days
target = invoice_view_by_customer.forward_aggregate(
    None,
    method="count",
    target_name="CUSTOMER_Count_of_invoices_next_week",
    window='7d',
)

# Create a binary feature if count is larger than 1
target = target > 1
target.name = "CUSTOMER_More_than_1_purchase_next_7d"
target.save()
target.update_description(
    "Whether customer will make more than 1 purchase the next 7 days"
)

Once you have run 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

Click Add Target Button

Create the target using the descriptive approach:

  • Target Name: CUSTOMER_More_than_1_purchase_next_7d_M
  • Primary Entity: customer
  • Data Type: Boolean
  • Description: Whether customer will make more than 1 purchase the next 7 days.
  • Include Horizon: 7 days.

Create Unsurpervised Target

Note that the Catalog now has 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.

Empty Context Catalog

Click Add Context Button

Describe the Context for our use case:

  • Context Name: In-Store Customer
  • Description: Predictions are generated while the customer is in the store and before the completion of the purchase.
  • Primary Entity: customer

Context Catlog

The Catalog has now one context listed.

Context Catlog

Step 3: Create a Use Case

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

Empty Use Case Catalog

Click Add Use Case Button

Our use case can be described as follows:

  • Use Case Name: Customer Activity Next Week before a purchase
  • Primary Entity: customer
  • Context: In-Store Customer
  • Target: CUSTOMER_More_than_1_purchase_next_7d
  • Description: Predicting whether a customer will remain active during the week following this purchase. The prediction is made just before the customer completes the purchase to enhance engagement during the transaction.

Note that we use the target 'CUSTOMER_More_than_1_purchase_next_7d' because we aim to exclude the upcoming transactions that the customer will be making in the store.

Create Use Case

Note

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

For those who don't have access to the SDK, we'll create the same use case but using the descriptive target.

The use case using the descriptive target can be described as follows:

  • Use Case Name: Customer Activity Next Week before a purchase (using the descriptive target)
  • Primary Entity: customer
  • Context: In-Store Customer
  • Target: CUSTOMER_More_than_1_purchase_next_7d_M
  • Description: Predicting whether a customer will remain active during the week following this purchase. The prediction is made just before the customer completes the purchase to enhance engagement during the transaction.

Create Customer Use Case

The Catalog now has two use cases listed.

Use Case Catalog