Gators: A Lightning-Fast Data Preprocessing And Feature Engineering Python Library
| Package | |
| Quality | |
| Documentation | |
| Code style | |
| Downloads | |
| Community |
What is Gators?
Gators is a library built on top of Polars, designed to streamline your entire ML workflow from raw data to production-ready models — benchmarked faster than scikit-learn and feature-engine across common preprocessing tasks (see Benchmarks below).
Built by the PSP Data Team at PayPal, Gators makes data preprocessing and feature engineering both faster and simpler.
⚡ Key Features
- 🚀 Lightning Fast: Benchmarked faster than scikit-learn and feature-engine on common preprocessing tasks
- 🔄 Unified API: Consistent sklearn-style
.fit()and.transform()interface - 📦 Production Ready: Deploy the same Python code from notebook to production
- 🎯 Comprehensive: 108 preprocessing transformers across 11 categories
- 🔗 Pipeline Support: Chain transformers seamlessly with the Pipeline class
- 📤 ONNX Export: Export fitted pipelines to ONNX for low-latency inference (most transformers supported; a handful of
feature_generation_strtransformers can't convert due to ONNX's limited string-tensor op support) - 🎓 Easy to Learn: If you know sklearn, you already know Gators
📊 Benchmarks
Gators transformers are timed head-to-head against their closest scikit-learn
and feature-engine equivalents (same algorithm, fit + transform, best-of-3
runs) on a 500,000-row synthetic dataset:
| Transformer | gators (s) | scikit-learn (s) | feature-engine (s) | speedup vs sklearn | speedup vs feature-engine |
|---|---|---|---|---|---|
| NumericImputer (mean) | 0.005 | 0.025 | 0.012 | 5.2x | 2.4x |
| StandardScaler | 0.002 | 0.009 | n/a | 3.8x | n/a |
| QuantileClipper | 0.005 | n/a | 0.056 | n/a | 12.3x |
| EqualSizeDiscretizer (5 bins) | 0.025 | 0.112 | 0.182 | 4.5x | 7.3x |
| OneHotEncoder | 0.045 | 0.283 | 0.320 | 6.2x | 7.0x |
| OrdinalEncoder | 0.029 | 0.267 | 0.127 | 9.1x | 4.3x |
| TargetEncoder | 0.029 | 0.442 | 0.163 | 15.0x | 5.5x |
| WOEEncoder | 0.028 | n/a | 0.181 | n/a | 6.5x |
n/a = no equivalent implementation exists in that library. Measured on an
Apple M3 Max; hardware, dataset shape, and library versions all affect
absolute numbers, so results are fully reproducible with one command:
pip install -e ".[benchmarks]"
python benchmarks/run_benchmarks.py
See benchmarks/ for full methodology, caveats, and raw results.
�🛠️ What Can Gators Do?
🧹 Data Cleaning (16)
Clean and prepare your data with powerful transformers:
CastColumns- Convert column data typesCorrelationFilter- Remove highly correlated featuresDropColumns- Remove specified columnsDropConstantColumns- Remove columns with constant valuesDropDuplicateColumns- Remove duplicate columnsDropDuplicateRows- Remove duplicate rowsDropHighNaNRatio- Remove columns with high missing value ratioDropLowCardinality- Remove low-cardinality columnsDropNearConstantColumns- Remove near-constant columnsHighCardinalityFilter- Filter high-cardinality featuresRenameColumns- Rename columnsReplace- Replace values in dataRoundDigits- Round numeric columns to a fixed number of decimal placesRoundSignificantDigits- Round numeric columns to a fixed number of significant figuresSelectColumns- Keep only specified columnsVarianceFilter- Remove low-variance features
✂️ Clippers (5)
Detect and clip outliers:
CustomClipper- Custom min/max bounds per columnGaussianClipper- Clip based on mean ± n standard deviationsIQRClipper- Clip based on interquartile rangeMADClipper- Clip based on median absolute deviationQuantileClipper- Clip based on quantile thresholds
🔢 Categorical Encoding (10)
Transform categorical variables with advanced encoding techniques:
BinaryEncoder- Binary representation encodingCatBoostEncoder- CatBoost-style target encodingCountEncoder- Frequency-based encodingHashEncoder- Hashing trick for high-cardinality featuresLeaveOneOutEncoder- Leave-one-out target encodingOneHotEncoder- Classic one-hot encodingOrdinalEncoder- Frequency-ordered ordinal encodingRareCategoryEncoder- Replace rare/infrequent categories with a single labelTargetEncoder- Target mean encoding for supervised learningWOEEncoder- Weight of Evidence encoding
🎯 Feature Generation - Numeric (21)
Create powerful numeric features:
Mathematical Operations:
AsymmetryIndexFeatures- Generate asymmetry index featuresConcentrationIndexFeatures- Generate concentration index featuresDistanceFeatures- Calculate distance featuresEntropyFeatures- Generate Shannon entropy featuresFourierFeatures- Generate Fourier basis featuresGeneralizedRatioFeatures- Generate generalized ratio featuresHHIFeatures- Herfindahl–Hirschman Index featuresIsNull- Generate null-indicator featuresMathFeatures- Apply mathematical operations between column groupsPlanRotationFeatures- Rotate features in feature spacePolynomialFeatures- Generate polynomial and interaction featuresRatioFeatures- Create ratio features between columnsScalarMathFeatures- Apply scalar operations to columnsWeightedSumFeatures- Weighted sum of features
Aggregation & Statistics:
GroupLagFeatures- Generate lag features by groupGroupStatisticsFeatures- Generate group-based statisticsRollingStatisticsFeatures- Generate rolling-window statisticsRowStatisticsFeatures- Generate row-level statistics
Rule-based:
ComparisonFeatures- Generate comparison featuresConditionFeatures- Create conditional featuresRuleFeatures- Apply custom business rules
📝 Feature Generation - String (19)
Extract insights from text data:
CharacterStatistics- Extract character-level statisticsCombineFeatures- Concatenate selected string columnsContains- Binary indicator: string contains patternEndswith- Binary indicator: string ends with patternExtractSubstring- Extract a fixed-position substringInteractionFeatures- Exhaustive pairwise string concatenationLength- String lengthLower- Convert to lowercaseNGram- Generate character or word n-gram featuresOccurrences- Count pattern occurrencesPatternDetector- Detect regex patternsRegexExtractFeatures- Extract named groups via regexSplit- Split strings on a delimiterSplitExtract- Split and extract the nth tokenStartswith- Binary indicator: string starts with patternStringSimilarity- Fuzzy string similarity (Levenshtein / Jaro-Winkler)TfidfFeatures- Generate TF-IDF featuresUpper- Convert to uppercaseWordStatistics- Extract word-level statistics
📅 Feature Generation - DateTime (8)
Unlock temporal patterns:
BusinessTimeFeatures- Business hours/days calculationsCyclicFeatures- Circular encoding for cyclical time featuresDiffFeatures- Calculate time differences between columnsDurationToDatetime- Convert duration to datetime componentsHolidayFeatures- Detect and encode public holidaysOrdinalFeatures- Extract year, month, day, hour, etc.TimeBinFeatures- Bin times into categorical bucketsTimeWindowFeatures- Generate time-window aggregation features
🔄 Missing Value Imputation (6)
Handle missing data intelligently:
BooleanImputer- Impute boolean columns (constant or most-frequent)GroupByImputer- Group-based imputation (median/mean per group)IterativeImputer- Multivariate iterative imputationKNNImputer- K-nearest neighbours imputationNumericImputer- Impute numeric columns (mean, median, mode, constant, forward/backward fill)StringImputer- Impute string columns (mode or constant)
📊 Discretization (7)
Convert continuous variables into bins:
CustomDiscretizer- User-defined bin edgesEqualLengthDiscretizer- Equal-width binningEqualSizeDiscretizer- Equal-frequency binningGeometricDiscretizer- Geometric progression binningKMeansDiscretizer- K-means clustering-based binningQuantileDiscretizer- Quantile-based binningTreeBasedDiscretizer- Decision tree-based optimal binning
⚖️ Feature Scalers (9)
Normalize and transform your features:
ArcSinSquareRootScaler- Arcsine square-root transformationArcSinhScaler- Inverse hyperbolic sine transformationBoxCox- Box-Cox power transformationLog1pScaler- Log1p scaling — log(1 + x)MinmaxScaler- Min-max normalization to [0, 1]PowerScaler- Power transformationRobustScaler- Median/IQR-based robust scalingStandardScaler- Z-score standardizationYeoJohnson- Yeo-Johnson power transformation
✨ Feature Selection (6)
Select the most informative features:
CorrelationSelector- Drop features by pairwise Pearson correlationFeatureStabilitySelector- Keep features stable across data splitsInformationValueSelector- Filter by Information Value (IV)MutualInformationSelector- Filter by mutual information with targetPermutationImportanceSelector- Filter by permutation feature importancePSIFilter- Filter by Population Stability Index
🔗 Pipeline (1)
Chain all transformers together:
Pipeline- sklearn-compatible pipeline for chaining transformers
📤 ONNX Export
Export a fitted Pipeline or single transformer to a validated ONNX graph for low-latency, language-agnostic inference:
from gators.onnx_converters import pipeline_to_onnx
model = pipeline_to_onnx(fitted_pipeline) # → onnx.ModelProto
# Run with onnxruntime, Triton, or any ONNX-compatible runtime
Most transformers are supported, but a handful of feature_generation_str transformers
(CharacterStatistics, NGram, Occurrences, PatternDetector, RegexExtractFeatures,
StringSimilarity, WordStatistics) have no ONNX converter: they rely on variable-length
tokenization, list aggregates, or fuzzy string distance that ONNX's string-tensor op set
cannot express. Use check_pipeline_onnx_compatibility(pipeline) to audit a pipeline before
exporting - unsupported steps raise OnnxNotSupportedError (or pass through unchanged with
errors="coerce").
🚀 Quick Start
import polars as pl
from gators.data_cleaning import DropHighNaNRatio, VarianceFilter
from gators.encoders import OneHotEncoder
from gators.imputers import NumericImputer
from gators.scalers import StandardScaler
from gators.pipeline import Pipeline
# Load your data
X = pl.read_csv("data.csv")
# Build a preprocessing pipeline
pipeline = Pipeline(steps=[
('drop_nan', DropHighNaNRatio(max_ratio=0.5)), # drop columns with >50% missing values
('impute', NumericImputer(strategy='median')), # fill numeric nulls with column median
('variance', VarianceFilter(min_std_dev=0.01)), # remove near-zero-variance columns
('encode', OneHotEncoder()), # one-hot encode all string/categorical columns
('scale', StandardScaler()), # z-score standardize numeric columns
])
# Fit on training data, transform train + test
X_train_processed = pipeline.fit_transform(X_train)
X_test_processed = pipeline.transform(X_test)
# Export to ONNX for production inference
from gators.onnx_converters import pipeline_to_onnx
onnx_model = pipeline_to_onnx(pipeline)
📦 Installation
Requires Python 3.10 or higher.
pip install gators
With ONNX export support:
pip install "gators[onnx]"
Or install from source:
git clone https://github.com/paypal/gators.git
cd gators
pip install -e .
📚 Documentation
For detailed documentation, tutorials, and API reference, visit:
https://paypal.github.io/gators/
🎯 Use Cases
Gators is perfect for:
- Fraud Detection - Extensive feature engineering for anomaly detection
- Risk Modeling - Create powerful predictive features
- Customer Analytics - Transform complex customer data
- Time Series - Rich datetime feature engineering
- NLP Tasks - String feature extraction and encoding
- Production ML - Export preprocessing to ONNX and run anywhere
🏢 Used By
Gators powers ML pipelines at:
- PayPal (internal use)
🤝 Contributing
We welcome contributions! Please check out our contributing guidelines.
📄 License
Gators is licensed under the Apache License 2.0. See LICENSE file for details.
🙏 Credits
Developed by the PSP Data Team at PayPal.
Built by data scientists, for data scientists
Metadata
Release files for gators 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gators-1.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / gators-1.3.1-py3-none-any.whl
| Download URL | gators-1.3.1-py3-none-any.whl |
|---|---|
| Size | 360.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60ce0dca933305958005adf5f76cf54866681c2bd0fddc193791333adcff5ca7
|
|
BLAKE2b-256 checksum How to use checksums |
7d9486fc1cce8496c7bffa00dfd5007ded332497a40cbabe0eef1a8f6f83b067
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|