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:

text
P(Methodᵢ | x_model_problem ∧ x_data_domain_description ∧ x_data_field)

where:

  • x_model_problem : the target objective to achieve from this data sample
  • x_data_domain_description : the type or origin of this dataset
  • x_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.

AgentPurposeOutput FormatDeterminism Tactics
MissingMechanismClassifierLLM classification of mechanismJSON {mechanism, justification, risk_flags, confidence}Constrained prompt + fallback parser
MissingImpactAssessorRisk scoring across 4 domainsJSONDefaults on parse failure
MissingStrategyRecommenderRanked handling strategiesJSON array + rationaleConservative fallback (mean_imputation)
(Heuristic Layer)Pre-LLM signal extractionPython dataclassDeterministic 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 TypeMAR vs MCARMNAR vs MARMNAR vs MCAR
Numeric (e.g., age, salary)Little’s MCAR test; correlation tests between missing indicator & observed vars; logistic regression on missingnessPattern-mixture models; Heckman selection models; sensitivity analysis with simulated unobserved valuesCompare Little’s test with value-dependent dropout models; fit selection models predicting missing from true values
Binary classificationChi-square test between missingness indicator & class; logistic regression of missingness ~ classLogistic regression with observed covariates + EM imputation; examine residual dependenceRandomization/permutation tests vs fitted dropout models; check if imbalance remains after controlling for class
Multilabel classificationMissingness indicator regressed on known labels; random forests for feature importancePattern-mixture analysis across label sets; semi-supervised EM algorithmsCompare 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 statusJoint modeling of outcome + missingness process (shared parameter models); survival analysis for dropoutMonte 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 groupsLatent 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 metricsSensitivity analysis with reweighted likelihoods; Bayesian models with informative priors on unobserved valuesCompare 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 valuesNon-Missing Values
Missing Values00
Non-Missing values00
MAR
Missing valuesNon-Missing Values
Missing Values01
Non-Missing values00
MNAR
Missing valuesNon-Missing Values
Missing Values0.50.5
Non-Missing values0.50.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 ​