causallib.positivity.UnivariateBoundingBox#
- class UnivariateBoundingBox(quantile_alpha=0.1, continuous_columns=[], categorical_columns=[])[source]#
Filter positivity by calculating univariate support
- Parameters:
quantile_alpha (
float, optional) – Quantile cut-off for continuous variable support calculation. If not None, then the support for the continuous variables will be calculated using the data at quantile quantile_alpha/2 as the left end and quantile 1 - quantile_alpha/2 on the right end. Defaults to 0.1.continuous_columns (
List[str], optional) – Column names to treat as Continuous variables. Defaults to None.categorical_columns (
List[str], optional) – Column names to treat as categorical variables. Defaults to None.
- __init__(quantile_alpha=0.1, continuous_columns=[], categorical_columns=[])[source]#
- Parameters:
quantile_alpha (
float, optional) – Quantile cut-off for continuous variable support calculation. If not None, then the support for the continuous variables will be calculated using the data at quantile quantile_alpha/2 as the left end and quantile 1 - quantile_alpha/2 on the right end. Defaults to 0.1.continuous_columns (
List[str], optional) – Column names to treat as Continuous variables. Defaults to None.categorical_columns (
List[str], optional) – Column names to treat as categorical variables. Defaults to None.
- fit(X, a)[source]#
Fit the propensity filter
This fits a Support object for every column depending on its dtype. It also calculates the scales of the original data.
- Parameters:
X (
pandas.DataFrame) – covariates DataFramea (
pandas.Series) – treatment assignment Series
- Returns:
Fitted positivity filter
- Return type:
- fit_column(Xcol)[source]#
Fit an individual column
- Parameters:
Xcol (
pandas.Series|pandas.DataFrame) – a single column of data- Returns:
a fitted Support object
- Return type:
Support
- predict(X, a=None)[source]#
Predict whether the sample is in the support for all variables
Note that the treatment assignment vector a is not used with this method. Every sample must be in every joint support to be considered in the overlapped set, regardless of its treatment value.
- Parameters:
X (
pandas.DataFrame) – covariatesa (
pandas.Series) – treatment assignment
- Returns:
- a binary series of length X.shape[0] with True for each
sample determined to be in the support else False
- Return type:
- Raises:
NotFittedError – if not fitted
- property supports_table_#
DataFrame summarizing the fitted support variables.
- Raises:
NotFittedError – if not fitted
- property scaled_supports_table_#
DataFrame summarizing the fitted support variables in rescaled units.
- Raises:
NotFittedError – if not fitted
- 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$')#
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.
- 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.