This stage is a decision-making workflow for diagnosing missingness at the dataset and column levels.
In real life, missing data is common. Although it should ideally receive ample time and attention, the reality is that scientists and analysts often face tight deadlines, and consequently may fall down a rabbit hole or fail to meet team and personal aspirations, especially in the fast-paced environment of a startup.
Definition: missing data (or missing values) is a data value that is not stored for a variable in the observation of interest. (Kang, 2013)
There is no single correct method for handling missing data, as it depends on the data sample, the modelling problem and the technique used to reach our end-of-day objective, not to mention how unclean the data is. But that doesn't stop the problem from being feasible. The main challenge in automating this workflow is settling on the optimal method for diagnosing the missing values, given these many layers of perception.
Using Bayes' theorem, the problem of choosing the optimal method, Methodᵢ, where i = 1, 2, 3, ... indexes the methods explored in the current session, simplifies to the following expression:
P(Methodᵢ | x_model_problem ∧ x_data_domain_description ∧ x_data_field)where:
x_model_problem: the target objective to achieve from this data samplex_data_domain_description: the type or origin of this datasetx_data_field: The data column containing the missing values.
From a programmer's point of view, the data persisted across states in this decision-making cycle are insights that highlight the currently observed sample. These insights also persist across the agent's episodes, and can be stored in BigQuery for easy access during data transformations.
| Agent | Purpose | Output Format | Determinism Tactics |
|---|---|---|---|
| MissingMechanismClassifier | LLM classification of mechanism | JSON {mechanism, justification, risk_flags, confidence} | Constrained prompt + fallback parser |
| MissingImpactAssessor | Risk scoring across 4 domains | JSON | Defaults on parse failure |
| MissingStrategyRecommender | Ranked handling strategies | JSON array + rationale | Conservative fallback (mean_imputation) |
| (Heuristic Layer) | Pre-LLM signal extraction | Python dataclass | Deterministic numeric signals |
Types of Missing Dataset
According to the source, the first step is distinguishing how the missing values occur in the data sample. These are the tests for telling each mechanism apart, by data field type:
| Data Field Type | MAR vs MCAR | MNAR vs MAR | MNAR vs MCAR |
|---|---|---|---|
| Numeric (e.g., age, salary) | Little’s MCAR test; correlation tests between missing indicator & observed vars; logistic regression on missingness | Pattern-mixture models; Heckman selection models; sensitivity analysis with simulated unobserved values | Compare Little’s test with value-dependent dropout models; fit selection models predicting missing from true values |
| Binary classification | Chi-square test between missingness indicator & class; logistic regression of missingness ~ class | Logistic regression with observed covariates + EM imputation; examine residual dependence | Randomization/permutation tests vs fitted dropout models; check if imbalance remains after controlling for class |
| Multilabel classification | Missingness indicator regressed on known labels; random forests for feature importance | Pattern-mixture analysis across label sets; semi-supervised EM algorithms | Compare observed-label-predictive models with latent class models predicting missingness |
| Continuous (sensor data) | Time-series autocorrelation of missingness indicator; runs tests; logistic regression on device status | Joint modeling of outcome + missingness process (shared parameter models); survival analysis for dropout | Monte Carlo dropout simulation to test if missing aligns with extreme tails; likelihood ratio tests |
| Long text (speech, transcripts) | Logistic regression: missingness ~ metadata (speaker, duration, file size); clustering missing vs non-missing groups | Latent variable models on semantic embeddings; adversarial ML (train classifier to distinguish missing vs not) | Compare uniform random corruption vs topic-dependent dropout (e.g. TF-IDF clusters more missing) |
| Other text (name, email) | Chi-square test missingness ~ demographic groups; multiple imputation then compare fit metrics | Sensitivity analysis with reweighted likelihoods; Bayesian models with informative priors on unobserved values | Compare uniform random missing (MCAR) with models linking rare/unusual values to missingness (MNAR) |
Decision-Making Tree in Distinguishing Missing Values
┌───────────────────────────┐
│ Start: Missing? │
└─────────────┬─────────────┘
│
┌─────────────┴─────────────┐
│ │
┌────────▼─────────┐ ┌─────────▼─────────┐
│ Test MCAR (Is │ │ No missing data │
│ missingness │ │ → Done │
│ completely random?)│ └──────────────────┘
└─────────┬─────────┘
│
┌─────────────────┼──────────────────┐
│ │
┌───────▼────────┐ ┌─────────▼─────────┐
│ MCAR confirmed │ │ MCAR rejected │
│ (Little’s test │ │ (missingness not │
│ not rejected, │ │ purely random) │
│ no predictors) │ └─────────┬─────────┘
└────────────────┘ │
│
┌────────────▼──────────────┐
│ Test MAR (Dependence on │
│ observed variables?) │
└────────────┬──────────────┘
│
┌─────────────────────┼─────────────────────┐
│ │
┌──────────▼─────────┐ ┌───────────▼──────────┐
│ MAR confirmed │ │ Residual dependence │
│ (missingness can │ │ remains after all │
│ be explained by │ │ observed variables │
│ known covariates) │ │ tested │
└──────────┬─────────┘ └───────────┬──────────┘
│ │
┌──────────▼─────────┐ ┌───────────▼───────────┐
│ Treat as MAR for │ │ Suspect MNAR │
│ imputation models │ │ (missingness depends │
│ and ML pipelines │ │ on unobserved value │
└────────────────────┘ │ itself; use selection │
│ models, sensitivity │
│ analysis) │
└───────────────────────┘Quantifying the Classes Attempt
However, this classification doesn't consider the context of the observed dataset, or of the data column where the missing values appear. The following are draft XOR / truth tables based on my understanding of Kang's paper. These matrix representations can guide an LLM's decision-making (online learning) processes, or serve as validation tests and rules.
MCAR
| Missing values | Non-Missing Values | |
|---|---|---|
| Missing Values | 0 | 0 |
| Non-Missing values | 0 | 0 |
MAR
| Missing values | Non-Missing Values | |
|---|---|---|
| Missing Values | 0 | 1 |
| Non-Missing values | 0 | 0 |
MNAR
| Missing values | Non-Missing Values | |
|---|---|---|
| Missing Values | 0.5 | 0.5 |
| Non-Missing values | 0.5 | 0.5 |
Worthy Considerations
In many applications, missing values may not appear in a consistent form. The most common forms in datasets are empty strings, pd.NA, None, np.nan, etc.
Explored Methods for Handling Missing Values
Common methods for handling missing values include:
- Expectation-Maximization
- Imputation Methods
- Sensitivity analysis
- Standardizing over the parameters from the column's approximated distribution
Concluding Actions
Actions taken on the dataset at the end of this stage:
- Dropping rows.
- Imputation strategies, e.g. mean, mode, etc., or adding an extra label such as 'UNKNOWN' for multi-label data types.
Resources
- Kang, H. (2013). The prevention and handling of the missing data. Korean Journal of Anesthesiology. https://pmc.ncbi.nlm.nih.gov/articles/PMC3668100/