Context
A Context object defines the scope and circumstances in which features are expected to be served. Examples include:
-
weekly batch predictions for an active customer that has made at least one purchase over the past 12 weeks
-
real time predictions for a credit card transaction that has been recently processed
Creating a Context¶
Use the create()
class method to add a Context to the active catalog:
context = fb.Context.create(
name="Active Customer", # Name of the context
primary_entity=["Customer"] # Primary entity related to the context
)
While basic context creation requires only the entity identification, adding a detailed description is recommended. This description could cover:
- Contextual Subset Details: Characteristics of the entity subset being targeted.
- Serving Timing: Insights into when predictions are needed, whether in batch or real-time scenarios.
- Inference Data Availability: What data is available at the time of inference.
- Constraints: Any legal, operational, or other constraints.
context.update_description(
"This context identifies 'Active Customers' as those individuals "
"whose customerid in the Customer Profile have no recorded "
"termination date, signifying ongoing engagement or activity. \n"
"The serving of features related to this context can be invoked at "
"any point in time. \n"
"Furthermore, there are no specific operational, legal, or other constraints."
)
Association with Observation Table¶
Once the Context is defined, you can link an observation table using the add_observation_table()
method.
context = catalog.get_context("Active Customer")
context.add_observation_table(<observation_table_name>)
You can also define an observation table to be used as the default preview / eda table for the Context using the update_default_eda_table()
and update_default_preview_table()
methods.
Finally, you can list observation tables associated with the Context using the list_observation_tables()
method.