Data Quality and its Usage in the AI and LLM Era
local graph
Chapter 14 — Data Quality and its Usage in the AI and LLM Era
Section titled “Chapter 14 — Data Quality and its Usage in the AI and LLM Era”Data quality refers to the overall utility of data based on attributes such as accuracy, completeness, reliability, relevance, and timeliness. It is an assessment of how well-suited data is for making decisions, driving processes, and achieving business objectives. The importance of data quality stems from its impact on the operational efficiency, strategic planning, and decision-making capabilities of an organization. High-quality data is critical for several practical reasons.
In this chapter, we present the data quality and its usage in the AI and Large Language Model (LLM) era. We also show practical use cases and features of the data in real applications.
The key topics covered in this chapter are as follows:
- Data quality and its usage
- Characterizing good data quality
- Examples of poor data quality and accidents
- Practicing with Python code
Data quality and its usage
Section titled “Data quality and its usage”Data quality is multifaceted, encompassing several characteristics or dimensions that collectively determine its suitability for use in operations, decision-making, and planning. Understanding these dimensions is crucial for assessing, improving, and maintaining the quality of data in any context. It refers to the overall utility of data based on attributes such as accuracy, completeness, reliability, relevance, and timeliness. It is an assessment of how well-suited data is for making decisions, driving processes, and achieving business objectives.
A high-quality dataset in the context of data science and machine learning is a collection of data that is accurate, complete, consistent, relevant, timely, and reliable. Such datasets are crucial for developing robust machine learning models that perform well in real-world applications.
Data quality needs to be maintained throughout the machine learning life cycle, from data collection through the data preprocessing stages until the testing phase, as any problems with data quality can affect all the next steps in processing. For instance, if we have an error where a column value is abnormally high, it can influence the normalization of the data, as well as feature extraction, and in turn the machine learning model parameters.
Now, in the following sections, let’s have a closer look at what constitutes a high-quality dataset and how these datasets are used in various real-world scenarios.
Characteristics of a high-quality dataset
Section titled “Characteristics of a high-quality dataset”Here are some of the key data quality dimensions:
- Accuracy: This dimension measures whether the data correctly describes real-world objects or events without errors. Accurate data is free from mistakes and precisely reflects the intended information.
- Completeness: Completeness assesses whether all the required data is present. Incomplete data can lead to incorrect decisions due to missing information. This dimension is crucial for ensuring that datasets are fully populated with all necessary data points.
- Consistency: Consistency refers to the data being uniform across different datasets or databases. It ensures that data does not contradict itself across the system and follows the same formats and standards, making it reliable for analysis and decision-making.
- Timeliness: Timeliness evaluates whether the data is up-to-date and available when needed. Data should be current and provided within a useful timeframe to be relevant for decision-making processes.
- Reliability: This dimension measures the degree to which data can be depended upon to be accurate and consistent over time. Reliable data maintains its integrity across various uses and applications.
Uses of high-quality datasets in real life
Section titled “Uses of high-quality datasets in real life”Here are some areas where these datasets are used:
In healthcare, this is how it is used:
- Care and research: High-quality datasets containing accurate and complete medical records are used to train models that can predict patient outcomes, recommend personalized treatments, and support diagnostic processes.
- Epidemiology: During events such as the COVID-19 pandemic, high-quality data on infection rates, recovery rates, and the effectiveness of interventions were crucial for modeling disease spread and informing public health decisions.
In finance, these are the uses:
- Risk management: Financial institutions use high-quality datasets to develop models that predict credit risk, detect fraudulent transactions, and automate risk assessment processes.
- Algorithmic trading: In stock trading, algorithms that can predict market movements more accurately are developed using detailed and up-to-date market data.
The retail uses are mentioned here:
- Customer Relationship Management (CRM): Retailers use high-quality datasets about customer behavior, preferences, and demographics to tailor marketing strategies and improve customer service.
- Supply chain optimization: High-quality data on sales, inventory levels, and logistics help companies optimize their supply chains, reducing costs and improving efficiency.
In autonomous vehicles, high-quality datasets that include varied scenarios of traffic, road conditions, and pedestrian interactions are used to train the algorithms that manage self-driving cars, ensuring they can operate safely and effectively in real-world conditions.
In the public sector, the high-quality data on traffic patterns, energy usage, and public safety are used to optimize city services and infrastructure. This leads to smarter resource management and an improved quality of life for residents.
Lastly, streaming services such as Netflix and Spotify use high-quality datasets on user preferences and behavior to train their recommendation engines, which personalize content suggestions to enhance user experience.
In each of these cases, the quality of the dataset directly influences the effectiveness of the models and systems developed from it. This underscores the importance of investing in high-quality data collection, storage, and processing practices to ensure the reliability and utility of data-driven applications in real life.
Examples of good data quality in AI and LLMs
Section titled “Examples of good data quality in AI and LLMs”In this section, we will give examples and characteristics of good and bad data quality in AI and LLM usage. We will clarify them within various areas, such as Natural Language Processing (NLP), computer vision, and so on.
In the field of NLP, the quality of datasets significantly affects the performance and reliability of models designed to understand and generate human language.
Here are examples of both high-quality and low-quality datasets in NLP, along with their influences on AI applications.
High-quality dataset examples in NLP
Section titled “High-quality dataset examples in NLP”First, let us see a few high-quality dataset examples.
Stanford Natural Language Inference (SNLI) corpus
Section titled “Stanford Natural Language Inference (SNLI) corpus”The SNLI dataset (https://nlp.stanford.edu/projects/snli/) comprises 570,000 human-written English sentence pairs, each manually labeled for balanced classification into one of three categories: entailment, contradiction, or neutral. This dataset is used to support tasks in Natural Language Inference (NLI).
The influence is that models trained on SNLI tend to perform well in understanding context, contradiction, and entailment in sentences, which is crucial for applications such as automated reasoning, chatbots, and assistant technologies. The thorough annotation process ensures a broad understanding of language nuances.
Common Crawl corpus
Section titled “Common Crawl corpus”Common Crawl (https://commoncrawl.org/) is a massive repository of web-crawled data collected over more than a decade, containing petabytes of data from the internet. It includes text in many languages and from various sources and formats.
The influence is that this corpus allows for the training of robust, generalizable language models because of its diversity and size. Models trained on such data can understand and generate text across different contexts and styles, making them highly effective for translation services, content generation, and more.
Penn Treebank
Section titled “Penn Treebank”The Penn Treebank (https://catalog.ldc.upenn.edu/LDC99T42) is an extensively annotated corpus that includes part-of-speech tagging, syntactic tree structures, and other linguistic annotations for English words.
The influence is that this dataset has been foundational for developing and benchmarking algorithms in syntactic analysis of English, improving the linguistic accuracy of NLP models. It’s crucial for tasks that require understanding the grammatical structure of sentences, such as syntax-based text parsing and complex question-answering systems.
Low-quality dataset examples in NLP
Section titled “Low-quality dataset examples in NLP”Here are some low-quality dataset examples.
Online reviews with in-moderated content
Section titled “Online reviews with in-moderated content”Datasets compiled from user-generated online reviews without any moderation or cleaning often contain spam, inconsistencies in labeling sentiment, and a high prevalence of irrelevant information.
The influence of training on such datasets can lead to models that are unreliable in sentiment analysis, prone to errors in understanding user opinions, and easily manipulated by spam-like text patterns.
Social media datasets with limited pre-processing
Section titled “Social media datasets with limited pre-processing”When datasets harvested from social media platforms are used without adequate pre-processing to remove noise (such as hashtags, mentions, and non-standard language), they can introduce significant noise into training data.
The result is that models trained on these datasets might struggle with language generation and understanding tasks due to the informal, abbreviated, and inconsistent nature of the text. This affects their performance in more formal or standardized NLP tasks.
Datasets with poor translation quality
Section titled “Datasets with poor translation quality”These are multilingual datasets created through automatic translation tools that do not accurately capture the nuances of languages.
The influence is that these datasets can lead to the development of translation models that misunderstand or misrepresent phrases and expressions in different languages, leading to communication errors and reduced efficacy in international applications.
Multilingual datasets are difficult to use to train models that accurately understand and generate human language across a variety of tasks. To overcome quality issues, here’s what we can do:
- Enable the training of models that accurately understand and generate human language across a variety of tasks
- Support the development of robust systems that can generalize well to new, unseen data
- Overcome models that are inaccurate, biased, or ineffective in real-world applications
- Cause models to adopt and propagate the inaccuracies, biases, and noise from the training data
The quality of datasets in NLP is crucial for ensuring that language models perform effectively and ethically, underscoring the need for careful dataset selection, curation, and ongoing evaluation in NLP projects.
Computer vision
Section titled “Computer vision”In the field of computer vision, the quality of datasets plays a crucial role in the performance and reliability of AI models.
Let’s explore some examples of high-quality and low-quality datasets in computer vision, highlighting their influences on various applications.
High-quality dataset examples in computer vision
Section titled “High-quality dataset examples in computer vision”Here are some high-quality dataset examples:
- ImageNet (https://www.image-net.org/): ImageNet is a large, well-annotated dataset of over 14 million images categorized according to the WordNet hierarchy. Each image is labeled with information about what sort of objects are pictured. ImageNet has been fundamental in advancing the development of deep learning models for image classification, object detection, and more. Its extensive size and diversity have allowed for the training of robust models that perform well across various tasks and environments.
- Common Objects in Context (COCO) (https://cocodataset.org/#home): COCO is a rich dataset designed for object detection, segmentation, and captioning tasks. It contains over 330,000 images with over 200,000 labeled instances of 80 categories of objects found in everyday scenes. COCO has been critical for the development of state-of-the-art models that require an understanding of context in images. Its complex annotations enable more accurate and nuanced AI models that can detect and describe multiple elements in a single scene effectively.
- Labeled Faces in the Wild (LFW) (https://vis-www.cs.umass.edu/lfw/): LFW is a collection of face photographs designed for studying the problem of unconstrained face recognition. LFW contains more than 13,000 images of faces collected from the web and has been used widely in the evaluation of face recognition algorithms. Its real-world, varied conditions challenge models to perform reliably in recognizing faces across changes in angle, lighting, and expressions.
Low-quality dataset examples in computer vision
Section titled “Low-quality dataset examples in computer vision”Here are some low-quality dataset examples:
- Biased facial recognition sets: Facial recognition datasets may under-represent certain demographics or contain mostly low-resolution, poorly captured images. These datasets can lead to AI models that perform poorly on underrepresented groups, resulting in higher error rates and biases in facial recognition technology. This can cause significant issues in security systems, hiring processes, and other areas where facial recognition is used.
- Noisy vehicle recognition datasets: Some vehicle recognition datasets include a lot of background noise, unclear images, or incorrect annotations. Models trained on these datasets may struggle to accurately identify vehicles, especially in different or challenging lighting and weather conditions. This can affect applications in traffic management, autonomous driving, and security.
- Small object datasets with sparse annotations: These are datasets intended for object detection that have sparse annotations, where many objects are not labeled, or where labels are inaccurate. Sparse annotations can lead to models that fail to detect objects consistently or accurately, limiting their usefulness in real-world applications such as robotic vision and automated inspection systems.
More accurate and robust datasets are capable of understanding complex scenes and contexts, are less biased, and are more universally applicable. Conversely, low-quality datasets can lead to models that are less accurate and more prone to errors, biased, and potentially discriminatory.
Limited in their real-world applicability due to poor generalization, the impact of dataset quality in computer vision demonstrates the critical need for careful dataset curation, constant evaluation, and refinement of data sources to ensure the development of effective and fair AI systems.
So far, we have presented the features of good and poor data quality. In the following section, we will discuss the accidents that are primarily caused by poor data quality in real life.
Data quality accidents
Section titled “Data quality accidents”Here are some examples of data quality accidents:
- Healthcare misdiagnoses: Inaccurate patient data due to data entry errors or incomplete medical histories can lead to misdiagnoses or unsuitable treatment, endangering patient health. These errors can happen or be overlooked due to a lack of knowledge or competence, problems in data gathering, or simply a lack of focus.
- Financial reporting errors: A famous example is the $6 billion trading loss by JPMorgan Chase in 2012, known as the “London Whale” incident. This incident was partly attributed to spreadsheet errors and inadequate risk models.
- Retail inventory mismanagement: Overstocking or understocking due to incorrect inventory data can result in significant financial losses for retailers, affecting their profitability. Inventory forecasting often includes machine learning applications and relies on a trained model. However, the model’s accuracy highly depends on having the right data on the state of the inventory, demand, sales, and so on. If any of the data has systematic or random errors, this will affect the performance of the model.
- Airlines scheduling mistakes: Airlines rely on accurate data for scheduling flights, crews, and maintenance. Data quality issues here can lead to flight delays, cancellations, and inefficiencies, costing millions and damaging the airline’s reputation.
- Utility billing errors: Inaccuracies in customer data or meter readings can lead to incorrect utility billing, resulting in customer dissatisfaction, complaints, and potential legal issues.
These examples highlight the critical importance of maintaining high data quality across various domains. Data quality issues can have far-reaching consequences, underscoring the need for robust data management and quality assurance practices.
After many theoretical descriptions and examples of poor data quality-related accidents, we will move to a new section, in which we will delve into how to program with the Python language to operate on good data quality.
Writing Python code to practice good data quality
Section titled “Writing Python code to practice good data quality”Ensuring good data quality involves employing techniques to cleanse, validate, and manage data efficiently.
In the next section, three Python examples are presented to demonstrate different ways to achieve better data quality in datasets. These examples include data cleansing, validation, and handling missing values using popular Python libraries such as pandas and numPy.
Example 1 – data cleansing with pandas
Section titled “Example 1 – data cleansing with pandas”This example will demonstrate how to remove duplicates and handle erroneous entries in a dataset using pandas:
import pandas as pd# Sample data# It contains features that can be present in a phishing detection datasetdata = { 'Phishing_detect_Name': ['Alice', 'Bob', 'Charlie', 'David', 'Alice'], 'Phishing_detect_Age': [25, 30, 35, 40, 25], 'Phishing_detect_Email': [ '[email protected]', 'bob@example', '[email protected]', }df = pd.DataFrame(data)# Remove duplicatesdf = df.drop_duplicates()# Correcting erroneous email entriesdf['Phishing_detect_Email'] = \ df['Phishing_detect_Email'].apply( lambda x: x if x.endswith('@example.com') else None)print(df)This code removes any duplicate rows and fixes email entries that don’t follow the correct format.
Example 2 – data validation
Section titled “Example 2 – data validation”Here, we will check whether the data meets certain conditions, such as ensuring that ages are within a reasonable range and emails are in a proper format:
import pandas as pd# Datadata = pd.DataFrame( { 'Phishing_detect_Name': ['Alice', 'Bob', 'Charlie', 'David'], # 120 and -1 are unrealistic values for age 'Phishing_detect_Age': [29, 120, -1, 35], 'Phishing_detect_Email': [ 'charlie@example', '[email protected]'] }) # Validate age rangedata['Phishing_detect_Age'] = \ data['Phishing_detect_Age'].apply( lambda x: x if 0 < x < 100 else None)# Validate email formatimport re def validate_email(email): pattern = r'^\w+@\w+\.\w+$' return email if re.match(pattern, email) else Nonedata['Phishing_detect_Email'] = \ data['Phishing_detect_Email'].apply(validate_email)print(data)This example corrects unrealistic age values and validates the email format using a regular expression.
Example 3 – handling missing values
Section titled “Example 3 – handling missing values”Handling missing values effectively is crucial for maintaining data quality. This example demonstrates replacing missing values with the median or most frequent value of the column:
import pandas as pdimport numpy as np # Sample data with missing valuesdata = pd.DataFrame( { 'Product_ID': [101, 102, 103, 104], 'Price': [25, 20, None, 30], 'Category': ['Electronics', None, 'Electronics', 'Clothing'] })# Fill missing numeric values with the mediandata['Price'].fillna(data['Price'].median(), inplace=True)# Fill missing categorical values with the most frequent categorydata['Category'].fillna(data['Category'].mode()[0], inplace=True)print(data)These examples use pandas for data manipulation, showcasing common techniques for enhancing data quality, such as cleansing, validation, and dealing with missing values. Such practices are fundamental for preparing a dataset for further analysis or machine learning tasks.
Summary
Section titled “Summary”In this chapter, we presented the content of data quality and its usage in the AI and LLM era first. We then explored several examples of good and bad data quality. Lastly, we showed how to write Python code to practice good data quality. Data quality refers to the overall utility of data based on attributes such as accuracy, completeness, reliability, relevance, and timeliness. It is an assessment of how well-suited data is for making decisions, driving processes, and achieving business objectives.
We hope you can grasp the features of good and poor data quality in your practical applications.
In the next chapter, several topics related to data quality will be presented. You will learn about the connections among data, such as correlation, causation, bias, and so on.