How can you handle missing data in a dataset used for deep learning?

Instruction: Discuss methods to deal with missing data in the context of preparing datasets for deep learning models.

Context: This question evaluates the candidate's knowledge of data preprocessing techniques, particularly handling missing data, a common issue in real-world datasets.

Updated

Example Answer

I first check what is missing, when it becomes missing, and whether that pattern matters for the prediction. Observed data alone usually cannot establish that missingness is random. A failed sensor and an intentionally skipped measurement can require different treatment.

For a numeric baseline, I would fit a median imputer on training data and add a missingness indicator. That lets the network distinguish an observed median from a substituted value. I would keep the same imputation rules at inference and validate on realistic missingness patterns.

A normal RNN or autoencoder does not automatically know how to handle NaN inputs. A specialized masked or imputation model needs an explicit input representation and training objective. For time series, I also track elapsed time since the last reading, and avoid filling a past value with a future measurement unavailable at prediction time. More elaborate imputation is worthwhile only if it improves the downstream task.

Concrete Example

If the training median temperature is 20, represent a missing reading as (value=20, missing=1) and an observed 20 as (value=20, missing=0). Keep the indicator definition consistent even if a feature first becomes missing in production.

scikit-learn imputation and missing indicators

Related Questions