featurebyte.Treatment.create¶
create(
name: str,
dtype: DBVarType,
treatment_type: TreatmentType,
source: AssignmentSource,
design: AssignmentDesign,
time: TreatmentTime="static",
time_structure: TreatmentTimeStructure="none",
interference: TreatmentInterference="none",
treatment_labels: Optional[List[Union[str, int, bool]]]=None,
control_label: Union[str, int, bool, NoneType]=None,
propensity: Optional[Propensity]=None
) -> TreatmentDescription¶
Create a new Treatment.
Parameters¶
- name: str
Name of the Treatment - dtype: DBVarType
Data type of the Treatment - treatment_type: TreatmentType
Scale of the treatment variable.
Valid values:
-binary:
Two-level treatment (for example, exposed vs control, coupon vs no coupon).
-multi_arm:
Discrete treatment with more than two levels (dosage tiers, variants).
-continuous:
Numeric treatment representing a dose, price, spend, or intensity.
Suitable for dose response estimators such as DR-learner and
continuous treatment DML or orthogonal ML. - source: AssignmentSource
High level source of treatment assignment. Determines the identification strategy and whether uplift style modeling is valid. - design: AssignmentDesign
Specific assignment design within the chosensource. - time: TreatmentTime
default: "static"
Time at which treatment is defined, for example static or time varying. - time_structure: TreatmentTimeStructure
default: "none"
Detailed temporal structure of the treatment process. - interference: TreatmentInterference
default: "none"
Structure of interference between units (violations of SUTVA). - treatment_labels: Optional[List[Union[str, int, bool]]]
List of raw treatment values used in the dataset.
Constraints
- Forcontinuoustreatments, this must beNone.
- Forbinarytreatments, this must be provided and contain exactly two values.
- Formulti_armtreatments, this must be provided and contain at least two values. - control_label: Union[str, int, bool, NoneType]
Value representing the control or baseline arm.
Constraints
- Forcontinuoustreatments, this must beNone.
- Forbinaryandmulti_armtreatments, this must be provided and
must be one oftreatment_labels. - propensity: Optional[Propensity]
OptionalPropensityspecification describing how treatment assignment probabilities p(T | ·) are known or estimated.
Constraints
- Forcontinuoustreatments,propensitymust beNone.
Returns¶
- Treatment
The created Treatment
Examples¶
Example 1: Simple A/B Test With Known Global Propensity
>>> treatment = fb.Treatment.create(
... name="Churn Campaign A/B test",
... dtype=DBVarType.INT,
... treatment_type=fb.TreatmentType.BINARY,
... source="randomized",
... design="simple-randomization",
... time="static",
... time_structure="instantaneous",
... interference="none",
... treatment_labels=[0, 1],
... control_label=0,
... propensity=fb.Propensity(
... granularity="global",
... knowledge="design-known",
... p_global=0.5, # 50/50 experiment
... ),
... )
>>> observational_treatment = fb.Treatment.create(
... name="Churn Campaign",
... 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)
... ),
... )
See Also¶
- TreatmentType: Enum for TreatmentType.
- Propensity: Schema for Propensity.
- AssignmentSource: Enum for AssignmentSource.
- AssignmentDesign: Enum for AssignmentDesign.
- TreatmentTime: Enum for TreatmentTime.
- TreatmentTimeStructure: Enum for TreatmentTimeStructure.
- TreatmentInterference: Enum for TreatmentInterference.