6. Formulate Use Case
Why Create a Use Case? Creating a Use Case in FeatureByte, while optional, unlocks a range of powerful benefits. It serves as a clear blueprint for your prediction data, outlining its purpose and intended application. Moreover, Feature Ideation leverages this information to suggest features specifically tailored to your use case, streamlining feature engineering.
Let's Create a Use Case for Our Grocery Dataset.
Customer Activity Next Week before a purchase: 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.
Step 1: Establish a Target¶
In FeatureByte, you can set a target in two ways:
- Logical Approach: Similar to feature creation, this approach allows the computation of targets through FeatureByte.
- Descriptive Approach: Simply state what you want to predict.
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 target that is True 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.
Create Target in the User Interface¶
- Click
-
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.
Note that the Catalog now has two targets listed.
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
-
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
The Catalog has now one context listed.
Step 3: Create a Use Case¶
Navigate to the Use Cases catalog from the 'Formulate' section of the menu.
-
Click
-
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 transaction that the customer will be making in the store.
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.
Step 4: Review a Use Case¶
The Catalog now has two use cases listed.
Click on one use case to review it.