quick_anomaly_detector.models.ImputerNa
- class quick_anomaly_detector.models.ImputerNa(strategy='mean', fill_values=None)
A custom imputer transformer that extends scikit-learn’s SimpleImputer while preserving column names after imputation.
Parameters strategy : {‘mean’, ‘median’, ‘most_frequent’, ‘constant’}, default=’mean’
The imputation strategy.
- fill_valuestr, int, or float, optional
The constant value to fill missing values when strategy=’constant’.
Attributes strategy : str
The imputation strategy.
- fill_valuestr, int, or float
The constant value to fill missing values when strategy=’constant’.
Methods fit(X, y=None)
Fit the imputer to the data.
- transform(X, y=None)
Transform the data by imputing missing values and preserving column names.
Examples
from sklearn.pipeline import Pipeline quick_anomaly_detector.data_process import CustomImputer
- fill_values = {
‘column1’: 0, ‘column2’: ‘’
} pipeline = Pipeline([
(‘imputer’, CustomImputer(strategy=’mean’)), (‘fillna’, CustomImputer(strategy=’constant’, fill_value=fill_values)),
]) X_train_imputed = pipeline.fit_transform(X_train)
- __init__(strategy='mean', fill_values=None)
Methods
__init__([strategy, fill_values])fit(X[, y])fit_transform(X[, y])Fit to data, then transform it.
get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
set_output(*[, transform])Set output container.
set_params(**params)Set the parameters of this estimator.
transform(X[, y])