qolmat.imputations.preprocessing.OneHotEncoderProjector

class qolmat.imputations.preprocessing.OneHotEncoderProjector(**kwargs)[source]

Class for one-hot encoding of categorical features.

It inherits from the class OneHotEncoder imported from category_encoders. The decoding function accepts non boolean values (as it is the case for the sklearn OneHotEncoder). In this case the decoded value corresponds to the largest dummy value.

__init__(**kwargs)[source]
reverse_dummies(X: DataFrame, mapping: Dict) DataFrame[source]

Convert dummy variable into numerical variables.

Parameters
XDataFrame

Input dataframe.

mapping: list-like

Mapping of column to be transformed to its new columns and value represented

Returns
numerical: DataFrame
set_inverse_transform_request(*, X_in: Union[bool, None, str] = '$UNCHANGED$') OneHotEncoderProjector

Configure whether metadata should be requested to be passed to the inverse_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 inverse_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 inverse_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.

New in version 1.3.

Parameters
X_instr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for X_in parameter in inverse_transform.

Returns
selfobject

The updated object.

set_transform_request(*, override_return_df: Union[bool, None, str] = '$UNCHANGED$') OneHotEncoderProjector

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.

New in version 1.3.

Parameters
override_return_dfstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for override_return_df parameter in transform.

Returns
selfobject

The updated object.

Examples using qolmat.imputations.preprocessing.OneHotEncoderProjector

Benchmark for categorical data

Benchmark for categorical data