Pre processor
fyt.core.processing.pre_processor
¶
PreProcessor
¶
Bases: BaseEstimator, TransformerMixin
PreProcessor class that builds and executes a scikit-learn pipeline.
The pipeline performs data preprocessing based on the provided configuration.
pipeline
property
¶
The preprocessing pipeline.
Returns:
| Name | Type | Description |
|---|---|---|
ColumnTransformer |
ColumnTransformer
|
The preprocessing pipeline. |
random_state
property
writable
¶
The random state.
fit(X, y=None)
¶
Fit the preprocessing pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
DataFrame | DataFrame
|
Input features. |
required |
y
|
Series | Series | ndarray | None
|
Target variable (optional). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
PreProcessor |
PreProcessor
|
Fitted PreProcessor instance. |
handle_zero_imputation(X)
¶
Handle zero imputation if configured.
Converts zeros to NaN only for features that are targeted by imputation components with impute_zeros=True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
DataFrame | DataFrame
|
Input features. |
required |
Returns:
| Type | Description |
|---|---|
|
Features with zeros converted to NaN for specified features only. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If X is neither a polars nor a pandas DataFrame. |
transform(X)
¶
Transform the data using the fitted pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
DataFrame | DataFrame
|
Input features to transform. |
required |
Returns:
| Type | Description |
|---|---|
|
Transformed features. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the PreProcessor has not been fitted yet. |