causallib.positivity.trimming.Trimming#
- class Trimming(learner=LogisticRegression(), threshold='auto')[source]#
- Parameters:
learner (
sklearn object) – Initialized sklearn modelthreshold (
str | float) –The threshold method or value. - if auto: finding the optimized threshold in a principled way. - if float, hard-coded value between 0 to 0.5 is used
in order to clip the propensity estimation.
- __init__(learner=LogisticRegression(), threshold='auto')[source]#
- Parameters:
learner (
sklearn object) – Initialized sklearn modelthreshold (
str | float) –The threshold method or value. - if auto: finding the optimized threshold in a principled way. - if float, hard-coded value between 0 to 0.5 is used
in order to clip the propensity estimation.
- fit(X, a)[source]#
Fit propensity model for positivity.
- Parameters:
X (
pandas.DataFrame) – covariate matrix of size (num_subjects, num_features)a (
pandas.Series) – treatment assignment of size (num_subjects,)
- predict(X, a, threshold=None)[source]#
Predict whether or not a sample is in the overlap region. Find samples that have probabilities to be assigned to one of the treatment groups, that is bigger than the cutoff threshold.
return a boolean indexer which is True if their probabilities are higher than the cutoff threshold and False otherwise. :param X: covariate matrix of size
(num_subjects, num_features)
- Parameters:
a (
pandas.Series) – treatment assignment of size (num_subjects,)threshold (
float|None) –The cutoff threshold. - if float, an optional value between 0 to 0.5 to clip the
propensity estimation.
if None, use the optimized cutoff in a principled way.
- Returns:
- a Series of length X.shape[0] with the same index as
X and only boolean values
- Return type:
- set_fit_request(*, a='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- set_predict_request(*, a='$UNCHANGED$', threshold='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
- Returns:
self – The updated object.
- Return type:
- set_score_request(*, a='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- set_transform_request(*, a='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
transformmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed totransformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it totransform.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.