Why Every Data Scientist Should Be Paranoid About Data Accuracy

As artificial intelligence and machine learning revolutionize industries from healthcare to finance to transportation, the importance of data accuracy has never been higher. AI and ML models are only as good as the data they‘re trained on – "garbage in, garbage out," as the saying goes. Inaccurate data doesn‘t just lead to suboptimal model performance, but can cause AI systems to make costly mistakes and biased decisions that harm individuals and society.

Consider Microsoft‘s infamous Tay chatbot, which learned from Twitter interactions and quickly began spewing racist and misogynistic content. Or IBM‘s Watson Health, which gave "unsafe and incorrect" cancer treatment recommendations based on flawed training data. Bad data has also been implicated in wrongful arrests, discriminatory credit decisions, and fatal self-driving car accidents. As one AI expert puts it, "Poisoning an AI with bad data is like feeding a human baby lead and mercury."

Given these high stakes, every data scientist and ML engineer should be downright paranoid about the accuracy and integrity of their data. You should assume that your data is dirty until proven clean and take a rigorous, systematic approach to rooting out errors and inconsistencies.

In this post, we‘ll walk through a 7-step framework for assessing data accuracy, with a focus on the unique challenges of AI/ML projects. We‘ll highlight statistical techniques for detecting issues, coding tips for automating quality checks, and expert best practices for ensuring your models are only consuming high-grade data. By the end, you‘ll be equipped to be productively paranoid about your data quality.

The State of Data in the Machine Learning Era

Poor data quality is pervasive, and only becoming more problematic as companies increasingly rely on AI/ML. Consider the following statistics:

  • 80% of data scientists‘ time is spent finding, cleaning, and organizing data, according to one survey
  • Bad data costs the US over $3 trillion per year, per IBM
  • Only 3% of companies‘ data meets basic quality standards, an Experian study found
  • Data scientists spend up to 80% of their time on data preparation and quality issues, leaving only 20% for actual analysis, according to CrowdFlower

As companies store more data and ML models ingest a greater variety of data types, these issues are only getting worse. IBM estimates that poor data quality costs the US economy $3.1 trillion annually, and 27.5% of business leaders don‘t trust the data they use to make decisions.

For AI/ML applications in particular, bad data causes a slew of problems:

  • Biased outcomes: If your training data contains human biases around race, gender, age, etc., your model will learn those same biases. Amazon had to scrap an ML recruiting tool because it discriminated against women, since it was trained on historical hiring decisions that favored men.

  • Inaccurate predictions: Data quality issues like duplicate records, missing values, and outliers confuse ML algorithms and lead to poor predictive performance. One insurance company‘s ML fraud detection model had a 30% false positive rate due to messy data.

  • Lack of transparency: Many AI/ML systems are "black boxes" where it‘s difficult to trace outputs back to specific data points. If you don‘t know what data your model ingested, you can‘t fully explain or trust its predictions.

  • Wasted resources: Data scientists waste countless hours dealing with data quality problems, distracting them from higher-value work. Dirty data slows down the development and deployment of ML models.

Clearly, data accuracy isn‘t a "nice to have" but a necessity in the age of AI. So how can data scientists and ML engineers systematically assess and improve the quality of their data?

The 7-Step Data Accuracy Assessment Framework

To vet a data set for an AI/ML project, work through these seven steps:

1. Sense-Check the Data Shape

Your first step is making sure your data has the expected number of rows (observations) and columns (features). This is a quick gut check that you have all the data you need for your use case. Some tips:

  • If you pulled the data from an API or database, check that the row count matches the total number of records at the source
  • Be wary of data sets with far fewer rows than you expect based on business intuition (e.g. if you‘re analyzing a year of sales data and there‘s only a few hundred rows, you likely have missing data)
  • Make sure all the features needed for your model are present – a single missing column could derail your analysis

2. Dedupe the Data

Duplicate records artificially inflate some observations and confuse ML models. Some dupes are easy to spot, like records with the exact same values across all columns. But others are more subtle, like:

  • Records that are identical except for a unique ID column
  • Duplicates that exist across tables after a join or merge
  • Fuzzy dupes due to inconsistent spellings or formatting (e.g. "I.B.M." vs "IBM")

To systematically identify duplicates, try:

  • Grouping the data by all columns except the unique ID and counting the number of rows per group. Records that show up in groups larger than one are likely duplicates.
  • Using fuzzy string matching algorithms like Levenshtein distance to find similar records
  • Leveraging a deduping library like Dedupe for Python

Once you‘ve identified dupes, you‘ll need to decide how to handle them. In some cases you may want to keep the first instance of each record and discard the rest. In others you may need to aggregate the duplicate records in some way.

3. Flag Missing Data

Missing values are the bane of every data scientist‘s existence. They can bias your analysis, cause errors in aggregations, and confuse ML algorithms. Some common missing data issues:

  • Blank cells that read in as empty strings, NaNs, or zeros
  • Placeholder values like "999" or "UNKNOWN" used to indicate missingness
  • Columns that are entirely blank due to a data pull or merge issue

To efficiently flag missing data, use your tool of choice to:

  • Calculate the percentage of nulls, blanks, or zeros in each column
  • Create a missingness matrix or heatmap showing which columns tend to be missing together
  • Investigate columns and rows with a high proportion of missing data to understand the root cause

Once you‘ve diagnosed your missing data problems, you have a few options for dealing with them:

  • Removing observations with missing values (be careful this doesn‘t bias your data!)
  • Imputing missing values with the mean, median, or mode
  • Using a ML model to predict missing values based on other features

The right approach depends on the nature of your data and the requirements of your ML model.

4. Probe for Problematic Patterns

Next, dig into the distribution of values in each feature to uncover outliers, anomalies, and nonsensical values. Some red flags to look out for:

  • Numeric features with extremely large or small values relative to the rest of the distribution (e.g. an age of 150 or an income of -$10,000)
  • Categorical features with values that don‘t make sense in the context of the data (e.g. a "gender" feature with the value "potato")
  • Distributions that are surprisingly skewed or have an unusual shape compared to what you‘d expect based on domain knowledge

Some useful techniques for identifying problematic patterns:

  • Visualizing univariate distributions with histograms, box plots, or density plots
  • Calculating summary statistics like the mean, median, minimum, maximum, and standard deviation for each feature
  • Using the interquartile range (IQR) method to flag outliers that fall more than 1.5 times the IQR below the first quartile or above the third quartile
  • Leveraging unsupervised anomaly detection algorithms like Isolation Forest or LOF

Be sure to sense-check anything flagged by statistical methods against your understanding of the business process or real-world phenomenon you‘re modeling. Not everything that looks weird in the data is necessarily an error.

5. Cross-Validate Related Features

Another powerful way to assess data accuracy is to compare values across multiple related features. The intuition is that certain combinations of values should be impossible or extremely unlikely based on what you know about the data-generating process.

For example:

  • If you have columns for "age" and "years of work experience", anyone whose years of experience is greater than their age likely has bad data in one or both fields
  • In a medical data set, a patient‘s height and weight readings taken on the same day should be roughly consistent across different tables or data sources
  • For an ecommerce data set, the total dollar amount of a customer‘s transactions should equal the sum of their individual order amounts

Look for these kinds of logical inconsistencies by:

  • Merging related data sets and comparing values for the same observations
  • Calculating differences or ratios between numeric features that measure the same thing
  • Creating contingency tables to spot unlikely or impossible combinations of categorical variables

If you find conflicting values, you‘ll need to decide which source is most reliable or find a way to combine the information from multiple sources. ML techniques like probabilistic record linkage can help match and merge records referring to the same entity.

6. Trace Data Lineage

To really get to the bottom of data quality issues, you need to understand the full journey your data took from initial creation to your analytics environment. This means tracing the data lineage by:

  • Identifying all the source systems that fed into your data set
  • Documenting any transformations, aggregations, or filtering the data underwent
  • Understanding the business processes and incentives that influence how the data is captured

Tracing lineage can help you uncover issues like:

  • Inconsistencies in how different source systems record the same information
  • Data drops or corruption during ETL processes
  • Changes in the meaning of features over time as business definitions evolve

Some tips for tracing data lineage:

  • Interview business domain experts to understand the nuances of how data is collected and used
  • Create a data dictionary that specifies the definition, format, and expected values for each feature
  • Use a data lineage tool like OpenLineage to automatically track the movement of data through your pipelines

7. Institute Data Quality Checks

Finally, don‘t just assess data accuracy once and assume the job is done. Data quality degrades over time as new information flows in and business processes change. You need a system for continuously monitoring the health of your data.

Some best practices:

  • Create a schedule for regularly rerunning the data accuracy assessment process on your key data sets
  • Automate data quality checks using a tool like Great Expectations to catch issues as soon as they arise
  • Set up data quality alerts to notify you when certain accuracy thresholds are breached
  • Build data quality checks into the data ingestion process to prevent bad data from ever entering your analytics environment

By making data accuracy assessment a routine part of your AI/ML workflow, you can ensure that you‘re always working with the highest quality data possible.

As AI and ML weave their way into every corner of business and society, the importance of data accuracy has never been greater. Bad data doesn‘t just lead to inconvenience, but can cause serious real-world harms. We‘ve already seen examples of flawed data leading to biased hiring decisions, incorrect medical diagnoses, and even loss of life in self-driving cars.

The solution is for every data scientist and ML engineer to embrace productive paranoia when it comes to their data. Assume your data is dirty and rigorously interrogate its accuracy using a multi-step process like the one outlined in this post.

By proactively rooting out data quality issues, you can:

  • Improve the accuracy and fairness of your ML models
  • Reduce time wasted on data cleaning and earn trust from stakeholders
  • Avoid the reputational and legal risks of AI behaving badly due to bad data

Of course, no data set is perfect, and even the most robust accuracy assessment process may miss some issues. But by making data quality a top priority and instituting ongoing checks, you‘ll be well on your way to creating AI systems that are trustworthy, reliable, and ethical.

The road to better AI starts with better data. So be paranoid, be proactive, and be relentless in your pursuit of data accuracy. Your models (and society) will thank you.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Similar Posts