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:
Returns:

Fitted positivity filter

Return type:

UnivariateBoundingBox

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:
Returns:

a binary series of length X.shape[0] with True for each

sample determined to be in the support else False

Return type:

pandas.Series

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

assert_is_fitted()[source]#

Check if filter is fitted

Raises:

NotFittedError – if not fitted

set_fit_request(*, a='$UNCHANGED$')#

Configure whether metadata should be requested to be passed to the fit method.

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 (see sklearn.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 to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • 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:

a (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for a parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_predict_request(*, a='$UNCHANGED$')#

Configure whether metadata should be requested to be passed to the predict method.

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 (see sklearn.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 to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • 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:

a (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for a parameter in predict.

Returns:

self – The updated object.

Return type:

object

set_score_request(*, a='$UNCHANGED$')#

Configure whether metadata should be requested to be passed to the score method.

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 (see sklearn.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 to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • 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:

a (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for a parameter in score.

Returns:

self – The updated object.

Return type:

object

set_transform_request(*, a='$UNCHANGED$')#

Configure whether metadata should be requested to be passed to the transform method.

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 (see sklearn.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 to transform if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to transform.

  • 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:

a (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for a parameter in transform.

Returns:

self – The updated object.

Return type:

object