featurebyte.Context.create¶
create(
name: str,
primary_entity: List[str],
description: Optional[str]=None,
treatment_name: Optional[str]=None,
user_provided_columns: Optional[List[UserProvidedColumn]]=None,
forecast_point_schema: Optional[ForecastPointSchema]=None
) -> ContextDescription¶
Create a new Context.
Parameters¶
- name: str
Name of the UseCase. - primary_entity: List[str]
List of entity names. - description: Optional[str]
Description of the Context. - treatment_name: Optional[str]
treatment name if this is a causal modeling context. - user_provided_columns: Optional[List[UserProvidedColumn]]
List of user-provided column definitions. - forecast_point_schema: Optional[ForecastPointSchema]
Schema for forecast point column if this is a forecasting context. Defines the granularity (day, week, etc.) and timezone handling.
Returns¶
- Context
The newly created Context.
Examples¶
>>> # Example with user-provided columns
>>> fb.Context.create(
... name="loan_approval_context",
... primary_entity=["customer"],
... user_provided_columns=[
... fb.UserProvidedColumn(
... name="annual_income",
... dtype=fb.DBVarType.FLOAT,
... feature_type=fb.FeatureType.NUMERIC,
... ),
... fb.UserProvidedColumn(
... name="credit_score",
... dtype=fb.DBVarType.INT,
... feature_type=fb.FeatureType.NUMERIC,
... ),
... ],
... )
>>> observational_treatment = fb.Treatment.create(
... name="Churn Campaign A/B test",
... dtype=DBVarType.INT,
... treatment_type=fb.TreatmentType.BINARY,
... source="observational",
... design="business-rule",
... time="static",
... time_structure="none",
... interference="none",
... treatment_labels=[0, 1],
... control_label=0,
... propensity=fb.Propensity(
... granularity="unit",
... knowledge="estimated", # Requires model-based p(T|X)
... ),
... )
>>> fb.Context.create(
... name="context_with_observational_treatment",
... primary_entity=primary_entity,
... treatment_name=observational_treatment.name,
... )