Metalearner Propensity
compute_propensity_score
compute_propensity_score (X, treatment, p_model=None, X_pred=None, treatment_pred=None, calibrate_p=True)
*Generate propensity score if user didn’t provide
Args: X (np.matrix): features for training treatment (np.array or pd.Series): a treatment vector for training p_model (propensity model object, optional): ElasticNetPropensityModel (default) / GradientBoostedPropensityModel X_pred (np.matrix, optional): features for prediction treatment_pred (np.array or pd.Series, optional): a treatment vector for prediciton calibrate_p (bool, optional): whether calibrate the propensity score
Returns: (tuple) - p (numpy.ndarray): propensity score - p_model (PropensityModel): a trained PropensityModel object*
calibrate
calibrate (ps, treatment)
*Calibrate propensity scores with logistic GAM.
Ref: https://pygam.readthedocs.io/en/latest/api/logisticgam.html
Args: ps (numpy.array): a propensity score vector treatment (numpy.array): a binary treatment vector (0: control, 1: treated)
Returns: (numpy.array): a calibrated propensity score vector*
GradientBoostedPropensityModel
GradientBoostedPropensityModel (early_stop=False, clip_bounds=(0.001, 0.999), **model_kwargs)
Gradient boosted propensity score model with optional early stopping.
ElasticNetPropensityModel
ElasticNetPropensityModel (clip_bounds=(0.001, 0.999), **model_kwargs)
Propensity regression model based on the LogisticRegression algorithm.
SimplePropensityModel
SimplePropensityModel (clip_bounds=(0.001, 0.999), **model_kwargs)
Propensity regression model based on the LogisticRegression algorithm.
LogisticRegressionPropensityModel
LogisticRegressionPropensityModel (clip_bounds=(0.001, 0.999), **model_kwargs)
Propensity regression model based on the LogisticRegression algorithm.
PropensityModel
PropensityModel (clip_bounds=(0.001, 0.999), **model_kwargs)
Args: clip_bounds (tuple): lower and upper bounds for clipping propensity scores. Bounds should be implemented such that: 0 < lower < upper < 1, to avoid division by zero in BaseRLearner.fit_predict() step. model_kwargs: Keyword arguments to be passed to the underlying classification model.