Skip to main content

Module scalers

Module scalers 

Source
Expand description

Per-column feature scalers, ported from tabfm/src/classifier_and_regressor.py’s PreprocessingPipeline, applied in this exact order: CustomStandardScaler -> one of 5 optional normalizers (if not "none") -> OutlierRemover (last, not second — verified against PreprocessingPipeline.fit). Each scaler exposes fit/transform mirroring sklearn’s split so the same fitted state (from training columns) can be applied to held-out columns.

Structs§

CustomStandardScaler
CustomStandardScaler: clip((x - mean) / (std + eps), -100, 100).
OutlierRemover
OutlierRemover (threshold=4.0 default): two-pass mean/std (outliers masked before the second pass), then a smooth log-based soft clip (NOT a hard clip) at the recomputed bounds.
PowerTransformer
PowerTransformer(method="yeo-johnson", standardize=True): per-feature MLE-fit lambda (via a ported scipy.optimize.brent), then standardize the transformed values.
QuantileTransformer
QuantileTransformer(output_distribution="normal"): empirical CDF (via linear-interpolated percentiles, sklearn’s default n_quantiles=1000 capped at the sample count) mapped through the inverse standard-normal CDF.
RobustScaler
RobustScaler(unit_variance=True): (x - median) / (IQR / 1.349...), where the divisor makes the scale consistent with a standard-normal’s std (1.349... = Φ⁻¹(0.75) - Φ⁻¹(0.25)).
StandardScaler
Plain sklearn.preprocessing.StandardScaler (ddof=0, no epsilon/clip) — used once, globally, on the raw regression target (y_scaler_ in TabFMRegressor), separate from the per-member CustomStandardScaler applied to features.

Functions§

apply_pipeline
One member’s full PreprocessingPipeline for a single column: fit on train_col, apply to both train_col and test_col. Order: CustomStandardScaler -> normalizer (if not NormMethod::None) -> OutlierRemover.
norm_ppf
Inverse standard-normal CDF (scipy.stats.norm.ppf), via Acklam’s rational approximation with one Halley’s-method refinement step (accurate to ~1e-9).
percentile_linear
NumPy’s default (“linear”) percentile interpolation on an already-sorted slice.