fair_forge.preprocessing¶
Classes
A transformation which is fitted with group information. |
|
A transformation which modifies both the dataset and the labels based on group information. |
|
|
|
Strategy for upsampling. |
|
|
- class fair_forge.preprocessing.GroupBasedTransform(*args, **kwargs)[source]¶
Bases:
_PreprocessorBase
,Protocol
A transformation which is fitted with group information.
- fit(X: ndarray[tuple[Any, ...], dtype[float32]], y: ndarray[tuple[Any, ...], dtype[int32]], *, groups: ndarray[tuple[Any, ...], dtype[int32]]) Self [source]¶
- class fair_forge.preprocessing.GroupDatasetModifier(*args, **kwargs)[source]¶
Bases:
_PreprocessorBase
,Protocol
A transformation which modifies both the dataset and the labels based on group information.
- class fair_forge.preprocessing.GroupPipeline(group_data_modifier: fair_forge.preprocessing.definitions.GroupDatasetModifier, estimator: fair_forge.methods.Method, random_state: int | None = None)[source]¶
Bases:
BaseEstimator
,GroupMethod
- fit(X: ndarray[tuple[Any, ...], dtype[float32]], y: ndarray[tuple[Any, ...], dtype[int32]], *, groups: ndarray[tuple[Any, ...], dtype[int32]]) Self [source]¶
- group_data_modifier: GroupDatasetModifier¶
- predict(X: ndarray[tuple[Any, ...], dtype[float32]]) ndarray[tuple[Any, ...], dtype[int32]] [source]¶
- set_fit_request(*, groups: bool | None | str = '$UNCHANGED$') GroupPipeline ¶
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if 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.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline
. Otherwise it has no effect.
- set_params(**params: Any) Self [source]¶
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline
). The latter have parameters of the form<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
estimator instance
- class fair_forge.preprocessing.Preprocessor(*args, **kwargs)[source]¶
Bases:
_PreprocessorBase
,Protocol
- class fair_forge.preprocessing.UpsampleStrategy(*values)[source]¶
Bases:
Enum
Strategy for upsampling.
- NAIVE = 'naive'¶
- UNIFORM = 'uniform'¶
- class fair_forge.preprocessing.Upsampler(strategy: fair_forge.preprocessing.group_pre_method.UpsampleStrategy = <UpsampleStrategy.UNIFORM: 'uniform'>, random_state: int = 0)[source]¶
Bases:
BaseEstimator
,GroupDatasetModifier
- fit(X: ndarray[tuple[Any, ...], dtype[float32]], y: ndarray[tuple[Any, ...], dtype[int32]], *, groups: ndarray[tuple[Any, ...], dtype[int32]]) Self [source]¶
Fit the preprocessing method to the data with group information.
- set_fit_request(*, groups: bool | None | str = '$UNCHANGED$') Upsampler ¶
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if 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.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline
. Otherwise it has no effect.
- set_transform_request(*, is_train: bool | None | str = '$UNCHANGED$', is_x: bool | None | str = '$UNCHANGED$') Upsampler ¶
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if 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.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline
. Otherwise it has no effect.- Parameters:
- Returns:
self – The updated object.
- Return type:
- strategy: UpsampleStrategy = 'uniform'¶