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.
- 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_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 toinverse_transformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toinverse_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_inparameter ininverse_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
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.New in version 1.3.
- Parameters
- override_return_dfstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
override_return_dfparameter intransform.
- Returns
- selfobject
The updated object.