Navigation

Introduction to AI

Machine Learning

Deep Learning

Generative AI

Tools & Frameworks

General

Data Quality and AI Performance - Garbage In, Garbage Out

A common myth in machine learning is that more data is always better. In reality, high-quality data—even in smaller quantities—often outperforms large, poor-quality datasets. A model trained on a million mislabeled examples will learn spurious patterns instead of true relationships. Understanding data quality and implementing quality assurance processes is as critical as choosing the right algorithm.

Dimensions of Data Quality

Data quality is multidimensional. A dataset can be large but mislabeled, complete but biased, clean but unrepresentative of deployment scenarios.

Correctness and Labeling Accuracy

Labels must accurately reflect ground truth. In supervised learning, if labels are wrong, the model learns from incorrect examples. A medical imaging dataset where tumors are mislabeled as benign and vice versa will teach a model to be wrong in predictable ways.

Label agreement reveals this: if multiple annotators independently label the same data, high agreement suggests labels are reliable; low agreement indicates ambiguity or systematic errors. When agreement is low, either the labeling guidelines need clarification, or the task itself is inherently ambiguous and requires additional domain expertise.

Completeness

Missing values are common in real data. A dataset of patient records with missing test results or incomplete medical histories introduces uncertainty. A model trained on incomplete data learns to make predictions given what’s available, but this may not match deployment scenarios where data availability differs.

Strategies for handling missing data:

  • Deletion: remove examples with missing values (works if missingness is rare and unrelated to outcomes, otherwise biases the dataset)
  • Imputation: fill missing values with estimates (mean, median, k-nearest neighbors, or learned from other features)
  • Indicator variables: add a binary flag marking whether a value was originally missing, allowing the model to learn whether missingness itself is predictive

Consistency and Standardization

Data in different formats introduces noise: dates stored as “2024-07-29”, “07/29/2024”, and “July 29, 2024” are the same value represented inconsistently. Categories spelled differently (“USA”, “USA”, “United States”) represent the same entity. Inconsistency forces models to learn representations of the same concept multiple ways, using capacity inefficiently.

Standardization—defining canonical formats, normalizing text, resolving synonyms—improves data quality and model efficiency.

Representativeness and Coverage

A dataset collected from one demographic or geographic region may not represent others. A model trained on images from developed countries may perform poorly on satellite imagery from remote regions with different lighting, terrain, or building styles. A hiring model trained on historical hiring data may perpetuate historical biases if those decisions were discriminatory.

Data drift occurs when deployment data differs from training data in distribution or composition. A sentiment analysis model trained on social media posts may fail on customer reviews (different style, vocabulary, and sentiment distribution). Regular evaluation on held-out data from deployment environments helps detect drift early.

Outliers and Anomalies

Outliers are extreme values that don’t fit overall patterns. An outlier can be a genuine rare example (a person earning $1 million annually) or a data entry error (a person’s age recorded as 999 years). Both affect model training. Genuine outliers inform the model about extreme cases; errors mislead it.

Outlier detection flags unusual examples for inspection. Techniques include statistical methods (values beyond 3 standard deviations), isolation forests (building trees that isolate outliers), and learned approaches (anomaly detection models). Once outliers are identified, decisions about inclusion depend on whether they’re genuine rare cases (include) or errors (remove or correct).

Bias and Fairness

Data can systematically misrepresent certain groups. Historical hiring data may underrepresent women in technical roles because of historical discrimination, not lack of capability. A model trained on this data learns to discriminate similarly. Dataset bias is baked into the model; no algorithm can fully undo this.

Addressing bias requires:

  • Dataset auditing: systematically measure representation of different groups
  • Stratified sampling: ensure training data includes sufficient examples from underrepresented groups
  • Synthetic data generation: create additional examples for underrepresented groups to balance representation
  • Fair metric selection: optimize not just overall accuracy but per-group accuracy to ensure parity

Identifying Data Issues

Exploratory Data Analysis (EDA)

Visualize distributions of features and labels. Histograms reveal whether features are normally distributed or heavily skewed. Scatter plots reveal correlations and outliers. Box plots show the spread and outliers. This manual inspection often reveals the most glaring issues: impossible values, missing patterns, or distributions that don’t match domain knowledge.

Correlation and Feature Analysis

Highly correlated features are redundant; the model learns the same information twice, wasting capacity. Near-zero correlation suggests a feature is uninformative. Features strongly correlated with the label are predictive; uncorrelated features may be irrelevant noise. A feature perfectly collinear with another (redundant) creates numerical instability in some models.

Label Frequency Analysis

In classification, severely imbalanced classes (1000 examples of class A, 10 of class B) make learning difficult. A model trained on imbalanced data may simply predict the majority class and ignore minorities. Techniques include:

  • Rebalancing: oversample minority classes or undersample majority classes
  • Class weights: weight loss for minority classes higher during training
  • Different metrics: accuracy is misleading on imbalanced data; use precision, recall, or F1 instead

Cross-validation and Leakage Detection

Train-test splits should be random and representative. However, data leakage—where information from test set influences training—causes overoptimistic performance estimates. Examples:

  • Using a patient ID as a feature (IDs for hospitalized patients differ from outpatient IDs, providing hidden information about outcome)
  • Temporal leakage: using future information to predict the past
  • Preprocessing on the combined dataset: fitting scalers or imputers on train+test together

Detect leakage by monitoring whether test performance suddenly drops when models are deployed on new data.

Data Quality Best Practices

Version Control for Datasets

Track which examples are in which version of the dataset, similar to code version control. If model performance regresses, was it a code change or a data change? Knowing dataset versions helps answer this.

Annotation Guidelines and Quality Control

Clear guidelines reduce annotator disagreement and errors. Spot-check annotations: do some examples pass automated quality checks but look wrong to domain experts? Are annotators consistently misunderstanding specific cases? Iteratively refine guidelines based on these findings.

Automated Quality Monitoring

Build data validation pipelines that run continuously in production:

  • Check that features are in expected ranges
  • Alert if feature distributions shift significantly
  • Validate that labels (when delayed feedback is available) match predictions

Documentation

Document data lineage, collection methodology, known limitations, and recommendations for use. A dataset collected from one country and period may not generalize to different countries or future time periods. Future users of the data need to know.

The Cost-Benefit of Data Quality

Improving data quality has direct cost (hiring annotators, auditing, cleaning) and time cost (delaying model deployment). But the benefit is substantial: higher-quality data requires less model complexity to achieve good performance, generalizes better to new scenarios, and is less likely to fail or exhibit unexpected biases in deployment.

The adage “garbage in, garbage out” remains fundamentally true: even the most sophisticated algorithms cannot extract correct patterns from fundamentally wrong data. Investing in data quality is investing in model reliability.