Data Preparation and Feature Engineering
What this domain tests
Data Preparation and Feature Engineering checks whether you can load data into H2O correctly, create useful predictors without leakage, and keep training and scoring schemas aligned.
Core rules
- Parse data with
h2o.importFile()and inspect column types. H2O-3 distinguishes numeric, enum (categorical), string, time, and UUID. Convert categoricals withas.factor(); do not leave ZIP codes as numeric. - Split before fitting imputers, encoders, or scalers. Use
h2o.splitFrame(data, ratios = c(0.7, 0.15, 0.15), seed = 42)and keep the test frame untouched. - H2O-3 algorithms handle missing values in different ways; impute deliberately with
h2o.imputeif the algorithm or business rule requires it. Fit imputation values on training data only. - High-cardinality categoricals often need target encoding or frequency encoding. Compute target encoding inside cross-validation folds, with smoothing, so the target is not leaked into the feature.
- Time features must respect chronology: lag, rolling windows, and holiday flags must use only past data. Use time-based splits for time series, not random k-fold.
- Driverless AI recipes and transformers automate feature engineering, but you still validate that transformed features are available at scoring time.
Worked example
A churn model has a postal_code column with 8,000 levels and a cancel_date column. Using cancel_date as a feature leaks the outcome because it is populated only after cancellation; drop it. For postal_code, compute a smoothed target encoding on each training fold, then apply the fold's mapping to validation data. A random split would let the same customer appear in train and test; use a customer-level or time-based split. The reasoning is leakage control, not model complexity.
Traps
- Encoding or imputing before the train/test split.
- Treating numeric codes as continuous variables.
- Target encoding on the full dataset, which inflates validation scores.
- Using future-dated features in time-series models.
- Failing to align categorical levels between training and scoring, causing unseen-level errors.