6. Formulate Use Case
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, for FeatureByte Enterprise users, it's used by FeatureByte's Feature Ideation engine to suggest features tailored to your use cases.
We'll create one Use Case for our Credit Default Dataset:
Loan Default by client: Predict clients' payment difficulties the next 6 months for new loan based on its early stage application data and prior credit history.
We will define a Context, establish a Target and then link the Use Case with the Context and Target.
import featurebyte as fb
# Set your profile to the tutorial environment
fb.use_profile("tutorial")
catalog_name = "Credit Default Dataset SDK Tutorial"
catalog = fb.Catalog.activate(catalog_name)
16:39:17 | WARNING | Service endpoint is inaccessible: http://featurebyte-server:8088/ 16:39:17 | INFO | Using profile: tutorial 16:39:17 | INFO | Using configuration file at: /Users/gxav/.featurebyte/config.yaml 16:39:17 | INFO | Active profile: tutorial (https://tutorials.featurebyte.com/api/v1) 16:39:17 | INFO | SDK version: 2.1.0.dev113 16:39:17 | INFO | No catalog activated. 16:39:17 | INFO | Catalog activated: Credit Default Dataset SDK Tutorial 16:06:14 | INFO | No catalog activated. 16:06:14 | INFO | Catalog activated: Grocery Dataset Tutorial
Create a Context¶
A Context defines the scope and circumstances in which features are expected to be served.
Let's describe the Context for our use case:
- Context Name: New Loan Application (Early Stage)
- Description: Early-stage loan application under review, without external data.
- Primary Entity: New Application
context_name = "New Loan Application (Early Stage)"
fb.Context.create(
context_name,
primary_entity=["New Application"],
description="Early-stage loan application under review, without external data.",
)
name | New Loan Application (Early Stage) | ||||||||
created_at | 2025-03-01 08:39:18 | ||||||||
updated_at | None | ||||||||
description | Early-stage loan application under review, without external data. | ||||||||
author | None | ||||||||
primary_entities |
|
||||||||
default_eda_table | None | ||||||||
default_preview_table | None | ||||||||
associated_use_cases | [] |
Creating a Target¶
For this use case, we'll use the descriptive approach, as the target cannot be derived directly from the data and must be provided alongside the observation tables.
For an example of a target computed by the SDK, check out the Grocery SDK Tutorial.
target_name = "Loan_Default"
target = fb.TargetNamespace.create(
name=target_name,
window="182d",
dtype="INT",
primary_entity=["New Application"],
)
Create a Use Case¶
Let's link our Use Case with the Context and Target.
fb.UseCase.create(
name="Loan Default by client",
target_name=target_name,
context_name=context_name,
description=(
"Predict clients' payment difficulties the next 6 months for new loan based on its "
"early stage application data and prior credit history."
),
)
name | Loan Default by client | ||||||||
created_at | 2025-03-01 08:39:19 | ||||||||
updated_at | None | ||||||||
description | Predict clients' payment difficulties the next 6 months for new loan based on its early stage application data and prior credit history. | ||||||||
author | None | ||||||||
primary_entities |
|
||||||||
context_name | New Loan Application (Early Stage) | ||||||||
target_name | Loan_Default | ||||||||
default_eda_table | None | ||||||||
default_preview_table | None |
List targets, contexts and use cases in the catalog¶
catalog.list_targets()
id | name | dtype | entities | created_at | |
---|---|---|---|---|---|
0 | None | Loan_Default | INT | [New Application] | 2025-03-01T08:39:18.698000 |
catalog.list_contexts()
id | name | primary_entity_ids | description | |
---|---|---|---|---|
0 | 67c2c7b5d7a26c138f0538a3 | New Loan Application (Early Stage) | [67c2c76cfd2556fdb5ea9b8f] | Early-stage loan application under review, wit... |
catalog.list_use_cases()
id | name | default_preview_table_name | default_eda_table_name | description | |
---|---|---|---|---|---|
0 | 67c2c7b6d7a26c138f0538a6 | Loan Default by client | None | None | Predict clients' payment difficulties the next... |