NaN in your
feature columns — locally or through the hosted API — and get finite
predictions back. No imputation step is required before calling the model.
Missing targets are different:
y_train must be numeric and complete.
Drop context rows whose target is missing — a filled-in target is a made-up
label, and it will steer every prediction.What happens to a NaN
You don’t have to do anything, but it helps to know the defaults:- Numeric features — missing values are imputed inside the model’s own preprocessing (server-side when you call the hosted API). Statistics come from your context rows, never from the query rows.
- Categorical features (DataFrame inputs via the
synthefyclient) — with the default ordinal encoding, a missing value staysNaNand is imputed server-side alongside the numeric columns; withcategorical_encoding="onehot", missing values get their own indicator column instead. - Columns with no observed values — a feature that is entirely missing carries no signal; it is neutralized rather than invented.
Imputing yourself
Sometimes you want the fill values under your control — to keep them consistent across models in a comparison, or to encode domain knowledge (for instance, a missing sensor reading that really means zero). Any imputation works, but the recipe we use in production and in our own benchmark harness is per-column train median, then 0 for columns with no observed values:- Median, not zero. On a non-centered feature, zero-filling plants an often-wild outlier in every incomplete row. The median stays inside the feature’s real range and is robust to skew and outliers, which tabular data has in abundance.
- Train statistics only. The test rows are filled with medians computed from the training rows. Computing fill values from the test set leaks information about the data you are predicting on and inflates evaluation scores.