AI & Machine Learning Fundamentals

Chapter 4
Data Foundations and the AI Data Lifecycle

Advance Diploma in Artificial Intelligence and Machine Learning
AI & Machine Learning Fundamentals   •   Advance Diploma

Data Foundations and the AI Data Lifecycle

Introduction

Artificial intelligence systems learn patterns from data. Their accuracy, fairness, safety, and usefulness therefore depend not only on model architecture but also on how data is defined, collected, labelled, stored, transformed, governed, and retired. A sophisticated algorithm trained on incomplete, biased, or poorly documented data can produce unreliable results. This is often expressed as “garbage in, garbage out,” although the relationship is more complex: high-quality data does not guarantee a good model, but poor-quality data places a firm limit on what a model can learn.

The data lifecycle provides a systematic way to manage data from its initial creation or acquisition through processing, use, sharing, archiving, and deletion. In AI projects, the lifecycle is iterative rather than strictly linear. Model evaluation may reveal labelling errors; deployment may reveal population shift; and new regulatory requirements may require changes to storage or consent practices.

Learning Objectives

By the end of this chapter, a learner should be able to:

  1. Distinguish important data types, sources, and representations.
  2. Explain the stages of an AI data lifecycle.
  3. Evaluate data quality, labelling practice, and dataset suitability.
  4. Describe storage, integration, metadata, and feature-representation choices.
  5. Identify privacy, security, bias, fairness, and governance risks.
  6. Apply lifecycle principles to the design of a reliable AI application.

1. Data Types and Sources

1.1 Structured, semi-structured, and unstructured data

Structured data is organised according to a fixed schema, commonly in relational tables. Examples include customer identifiers, transaction amounts, dates, and product codes. Structured data is convenient for querying and statistical analysis, but a rigid schema may not capture complex human behaviour.

Semi-structured data contains organisational markers without conforming fully to a relational table. JSON documents, XML files, application logs, and email headers are examples. Fields may be optional or nested, which makes schema validation important.

Unstructured data lacks a predefined tabular schema. Images, audio, video, free-text documents, and social-media posts are common examples. These data often require specialised representation methods such as tokenisation, embeddings, spectrograms, or visual feature extraction.

Data can also be classified by measurement scale:

ScaleMeaningExampleTypical treatment
NominalCategories without orderBlood group, product typeEncoding or grouping
OrdinalOrdered categories with unequal or unknown intervalsSatisfaction levelOrdered encoding; avoid assuming equal distance
IntervalEqual intervals, but no meaningful zeroTemperature in °CDifferences are meaningful
RatioEqual intervals and meaningful zeroMass, income, durationRatios are meaningful

A variable’s scale affects which summaries and transformations are valid. For example, calculating an average product category is meaningless, whereas calculating the average delivery time is usually meaningful.

1.2 Primary and secondary sources

Primary data is collected for the current purpose, such as sensor readings, surveys, interviews, experiments, or direct observations. It offers greater control over design and consent but can be costly and slow.

Secondary data was collected for another purpose and subsequently reused. Public datasets, administrative records, purchased data, and historical company records are examples. Reuse requires checking whether the original population, definitions, permissions, and collection procedures match the AI task.

Other useful distinctions include:

  • Static versus streaming data: a historical file versus continuously arriving events.
  • First-party versus third-party data: data collected by the organisation versus data obtained from another provider.
  • Observed versus generated data: recorded events versus synthetic or simulated examples.
  • Cross-sectional versus longitudinal data: observations at one point in time versus repeated observations of entities over time.

These distinctions matter because they affect representativeness, temporal leakage, privacy, and deployment behaviour.

2. The AI Data Lifecycle

A practical lifecycle contains the following connected stages:

  1. Purpose definition and data planning
  2. Collection or acquisition
  3. Ingestion and storage
  4. Cleaning and validation
  5. Labelling and annotation
  6. Integration and transformation
  7. Feature representation and dataset construction
  8. Model development and evaluation
  9. Deployment and monitoring
  10. Retention, archiving, or deletion
Iterative AI data lifecycle Plan purposeand consent Collect andingest Clean, label,and integrate Represent andevaluate Deploy, monitor,improve or retire AI data lifecycleGovernance, documentation and quality checks apply at every stage
Iterative AI data lifecycle
Figure: Iterative AI data lifecycle

Figure: The AI data lifecycle is iterative, with governance and quality assurance applied throughout.

2.1 Purpose definition

Before collecting data, the team should specify the decision to support, the intended users, the prediction target, acceptable error types, population, time horizon, and legal basis for processing. A target that is vague or measured through a convenient proxy can create fundamental validity problems. For example, using historical expenditure as a proxy for medical need may reproduce unequal access to healthcare rather than measure need itself.

A data specification should document:

  • the unit of observation, such as a person, transaction, image, or time interval;
  • the target variable and its operational definition;
  • inclusion and exclusion criteria;
  • expected data volume, frequency, and format;
  • provenance, ownership, consent, and permitted use;
  • quality thresholds and retention requirements.

2.2 Collection and acquisition

Collection methods include sensors, application programming interfaces, surveys, experiments, business transactions, public records, and human annotation. Sampling design is central. A dataset may be large yet unrepresentative if it systematically excludes rural users, people with disabilities, low-connectivity regions, or minority language speakers.

Sampling bias occurs when the probability of inclusion differs in a way related to the phenomenon being studied. Selection bias can enter through voluntary participation, convenience sampling, historical business processes, or platform-specific user behaviour. Data collection should therefore record sampling decisions and coverage, not just rows and columns.

2.3 Ingestion and storage

Ingestion transfers data from source systems into an environment where it can be managed. Important controls include schema checks, checksums, timestamps, access control, encryption, and immutable audit logs.

A data warehouse generally stores structured, curated data for reporting and analytical queries. A data lake stores large volumes of raw or lightly processed data in varied formats. A lakehouse combines flexible storage with stronger transactional and analytical management. A feature store manages reusable, versioned features for model training and serving.

Storage design should distinguish:

  • raw data, preserved for traceability;
  • cleaned or standardised data, used for analysis;
  • curated training datasets, versioned for reproducibility;
  • derived features, subject to lineage and access controls.

Backups, disaster recovery, geographic residency, availability requirements, and cost must be considered alongside model performance.

3. Data Quality and Validation

Data quality is multidimensional. Common dimensions include accuracy, completeness, consistency, timeliness, validity, uniqueness, and provenance. A dataset can be complete but inaccurate, or accurate but too old for the application.

For a field with n records, the missingness rate is:

rmissing = nmissing / n

Here, nmissing is the number of missing values and n is the total number of records. The ratio is dimensionless and assumes that each record contributes one value for the field. If rmissing = 0.08, then 8% of values are missing. The pattern of missingness is often more important than the overall percentage: missing income values concentrated in one demographic group may create unfairness.

Useful validation checks include:

  • range checks, such as age between plausible lower and upper bounds;
  • type checks, such as dates conforming to an agreed format;
  • referential checks, such as every transaction referring to a valid customer ID;
  • uniqueness checks for keys;
  • distribution checks against historical or expected distributions;
  • temporal checks preventing future information from entering past records;
  • duplicate and near-duplicate detection;
  • reconciliation against trusted totals.

Missing data

Missingness may be MCAR (missing completely at random), MAR (missing at random conditional on observed variables), or MNAR (missing not at random). These are modelling assumptions, not labels that can always be proven from the data. Deleting incomplete records may reduce sample size and introduce bias. Alternatives include explicit missing-value indicators, statistically justified imputation, domain-based defaults, or redesigning the collection process. Imputation must be fitted only on the training data when evaluating a model, otherwise information can leak from the validation or test set.

Data leakage

Leakage occurs when information unavailable at prediction time influences training. Examples include using a final diagnosis to predict admission risk, calculating a customer feature with post-outcome transactions, or allowing near-duplicate images across training and test sets. Leakage can produce impressive evaluation results that collapse in deployment.

4. Labelling and Annotation

Supervised learning requires target labels, but labels are not automatically objective facts. A label may be produced by a clinician, an employee, a crowd worker, a historical decision, or a rule. Each source introduces assumptions and possible error.

An annotation protocol should specify the task, label definitions, examples, edge cases, escalation rules, worker qualifications, and quality checks. For subjective tasks, multiple independent annotations are preferable. Agreement can be summarised using an agreement statistic. For two annotators classifying the same items, Cohen’s kappa is commonly defined as:

κ = (po − pe) / (1 − pe)

Here, po is observed agreement and pe is agreement expected by chance under the chosen marginal-frequency model. The statistic assumes categorical annotations and is sensitive to class prevalence; it should not be interpreted as a complete measure of label quality. A low value may indicate ambiguous instructions, difficult cases, or genuine disagreement rather than careless annotation.

Labels should be versioned because definitions can change. In high-stakes settings, adjudication, expert review, and uncertainty labels may be more appropriate than forcing every example into a single class.

5. Integration, Transformation, and Feature Representation

AI projects commonly combine data from incompatible systems. Integration requires entity resolution, common identifiers, unit conversion, time-zone handling, code mapping, and conflict resolution. A customer may appear under several spellings; a temperature may be recorded in Celsius in one source and Fahrenheit in another. Lineage should record where each derived field came from and which transformations were applied.

A feature is an input representation used by a model. Feature engineering may include scaling, aggregation, encoding, tokenisation, image normalisation, or extraction of temporal patterns. Transformation choices must preserve meaning and be reproducible.

For a value x with training-set mean μ and standard deviation σ, standardisation is:

z = (x − μ) / σ

The resulting value has no physical unit. The mean and standard deviation must be calculated on the training set and then reused for validation and production data. This prevents information leakage and ensures consistent serving behaviour. Standardisation is useful for many distance-based and gradient-based methods, but it is not universally necessary; tree-based models often do not require it.

Categorical variables may be represented using one-hot encoding, ordinal encoding, hashing, or learned embeddings. The choice depends on cardinality, ordering, model family, and operational constraints. High-cardinality identifiers can cause memorisation and poor generalisation. A feature should be assessed for predictive value, stability, interpretability, privacy risk, and possible discrimination.

6. Splitting Data and Evaluating Representativeness

A dataset is commonly divided into training, validation, and test partitions. The training set fits model parameters; the validation set supports model selection and tuning; the test set estimates performance on unseen data. The test set must remain isolated until final evaluation.

Random splitting is inappropriate when observations are time-dependent, grouped by person, or spatially correlated. In those cases, use time-based, group-based, or geographically aware splitting. Otherwise, records from the same person or near-identical events may appear in both training and test sets, exaggerating generalisation.

Representativeness should be assessed across relevant groups and operating conditions. Compare distributions of important variables, label prevalence, missingness, and error rates. A dataset need not reproduce every population proportion exactly, but deviations must be understood in relation to the intended deployment population.

7. Privacy, Security, Bias, and Governance

Personal data can identify a person directly or indirectly. Pseudonymisation replaces direct identifiers but does not make data anonymous if re-identification remains possible. Anonymisation aims to prevent identification using reasonably likely means, but it is difficult to guarantee, especially when datasets can be linked.

Responsible data governance includes purpose limitation, data minimisation, access control, retention limits, consent or another lawful basis, subject rights, breach response, and documented accountability. Applicable requirements depend on jurisdiction and sector; organisations must consult relevant laws such as data-protection, health, employment, or financial regulations rather than assuming that a dataset labelled “public” is unrestricted.

Security controls include encryption in transit and at rest, least-privilege access, secrets management, monitoring, secure deletion, and separation of development and production environments. Privacy-preserving techniques such as aggregation, differential privacy, federated learning, and secure multiparty computation can reduce exposure, but each introduces utility, complexity, or threat-model trade-offs.

Bias can enter through historical inequity, undercoverage, measurement error, labels, proxy variables, aggregation, or deployment feedback loops. Removing sensitive attributes does not necessarily remove bias because correlated proxies may remain. Fairness analysis should be connected to the decision context. Possible measures include group-specific error rates, calibration, equal opportunity, and demographic parity, but these measures can conflict mathematically and ethically. No single metric determines fairness in every application.

Governance artefacts should include a data inventory, data dictionary, dataset card, annotation guide, model-input specification, lineage record, risk assessment, access register, and change log. Documentation should state intended use, excluded use, known limitations, affected populations, and monitoring responsibilities.

8. Monitoring and Lifecycle Management

Data quality does not end at deployment. Monitoring should detect schema changes, missingness increases, unusual values, distribution drift, label delay, concept drift, latency problems, and subgroup performance degradation.

Data drift describes a change in input-data distribution. Concept drift describes a change in the relationship between inputs and the target. A fraud model, for example, may encounter new criminal strategies even when customer demographics remain stable. Monitoring thresholds should be linked to operational action: investigate, retrain, restrict use, or retire the system.

Every production feature should have an owner, definition, source, freshness expectation, validation rule, and fallback behaviour. Dataset and model versions should be reproducible through code, configuration, dependency records, and immutable references to source data. Retention schedules should specify when data is archived or securely deleted. Retirement is a governance decision, not merely a technical shutdown: downstream users, records, appeals, and contractual obligations must be addressed.

Applied Case: Illustrative Hospital Readmission Model

Background

A regional hospital proposes an AI system to identify patients at high risk of readmission within 30 days, allowing care coordinators to arrange follow-up support.

Problem

The initial dataset contains admission records, diagnoses, medication information, and historical readmissions. A preliminary model reports excellent accuracy, but an audit finds that the target label is partly based on whether a patient previously used the hospital’s emergency department. Patients who receive care elsewhere are less likely to be recorded as readmitted. The dataset also contains more records from urban patients and uses historical care intensity as a proxy for clinical need.

Analysis

The team defines the unit of observation as a hospital discharge and establishes a prediction time at discharge. Any information recorded after that time is excluded. It creates a data dictionary, checks missingness by demographic group, and compares local records with regional population statistics. A time-based split is used so that earlier admissions form training data and later admissions form validation and test data. Clinical experts review a sample of labels and disagreement cases.

The team discovers that medication fields are missing more often for patients transferred from smaller clinics. Rather than silently imputing all values, it adds a missingness indicator, investigates the collection process, and improves data exchange. It also tests subgroup sensitivity and false-negative rates, because failing to identify a patient who needs support may be more harmful than generating an additional review.

Approach and outcome

The hospital replaces the narrow historical-utilisation target with a carefully reviewed outcome definition, documents limitations, and deploys the model only as a decision-support tool. Care coordinators retain authority to review cases and patients can request explanation and correction of relevant information. Monitoring tracks calibration, referral workload, missingness, and subgroup outcomes. The model is retrained only after a documented review of changed data and clinical practice.

Learning points

The case demonstrates that data quality is inseparable from target definition, access patterns, fairness, temporal validity, and human governance. A higher score on a flawed target would not represent a better healthcare system.

Challenges and Best Practices

Common challenges include undocumented legacy data, incompatible identifiers, changing schemas, expensive annotation, privacy constraints, class imbalance, feedback loops, and pressure to deploy before validation is complete. Practical best practices are:

  1. Start with a written purpose and prediction-time definition.
  2. Maintain a data dictionary, lineage, ownership, and version history.
  3. Profile distributions, missingness, duplicates, and outliers before modelling.
  4. Separate training transformations from validation and test information.
  5. Use splits that reflect deployment: time, group, or geography where needed.
  6. Audit labels and measure disagreement rather than assuming labels are truth.
  7. Evaluate quality and performance across relevant subgroups.
  8. Minimise personal data and apply least-privilege access.
  9. Monitor drift, operational outcomes, and unexpected harms after deployment.
  10. Define retraining, incident response, retention, and retirement procedures in advance.

Contemporary Developments

Modern data platforms increasingly support automated lineage, data contracts, quality observability, feature stores, and privacy-preserving computation. Generative AI has increased the use of synthetic data, but synthetic examples do not automatically remove bias or privacy risk; they may reproduce source-data errors or create unrealistic distributions. Foundation models also create new concerns about web-data provenance, copyright, memorisation, and dataset documentation. Human-centred governance, reproducible pipelines, and independent evaluation remain necessary despite these technological developments.

Chapter Summary

Reliable AI begins with reliable data practice. Data must be classified according to structure, measurement scale, source, time, and intended use. The AI data lifecycle includes purpose definition, collection, ingestion, storage, validation, labelling, integration, feature representation, evaluation, deployment, monitoring, and retirement. Quality is multidimensional: completeness alone cannot establish accuracy or fitness for purpose. Missing data, leakage, sampling bias, ambiguous labels, and inappropriate splits can invalidate model results.

Storage architecture, metadata, lineage, versioning, and access control support reproducibility and accountability. Feature transformations must be fitted without using evaluation information. Privacy, security, fairness, and legal obligations apply throughout the lifecycle, not only at deployment. Finally, production systems require monitoring for drift, changing data quality, subgroup harms, and operational failure. Data governance is therefore a technical, organisational, and ethical discipline essential to dependable AI.

Key Terms

Data lifecycle: The stages through which data is planned, collected, processed, used, governed, retained, and deleted.

Structured data: Data organised according to a defined schema, usually in tables.

Semi-structured data: Data with organisational markers but a flexible or nested schema.

Unstructured data: Data without a predefined tabular structure, such as text, images, audio, or video.

Metadata: Information describing data, including its meaning, origin, format, owner, and time.

Data lineage: A record of data origins, transformations, movements, and derived outputs.

Data quality: The degree to which data is accurate, complete, valid, consistent, timely, unique, and fit for purpose.

Data leakage: Use of information during training that would not be available at prediction time.

Annotation: The process of assigning labels or structured judgments to data.

Feature: An input representation supplied to a machine-learning model.

Imputation: A method for replacing or handling missing values.

Data warehouse: A curated store designed mainly for structured analytical queries.

Data lake: A store capable of retaining large volumes of raw data in varied formats.

Pseudonymisation: Replacing direct identifiers while retaining a potential re-identification risk.

Anonymisation: Processing intended to prevent identification using reasonably likely means.

Sampling bias: Systematic distortion caused by how observations enter a dataset.

Data drift: Change in the distribution of input data over time.

Concept drift: Change in the relationship between inputs and the target over time.

Data minimisation: Collecting and retaining only data necessary for a defined purpose.

Feature store: A managed system for storing, documenting, versioning, and serving model features.

Review Questions

Short Answer Questions

  1. Distinguish structured, semi-structured, and unstructured data, giving one example of each.
  2. What is data leakage, and why can it produce misleading evaluation results?
  3. Name four dimensions of data quality.
  4. Explain the difference between pseudonymisation and anonymisation.
  5. Why should missingness be examined by subgroup rather than only as an overall percentage?

Long Answer Questions

  1. Explain the stages of an AI data lifecycle and show how governance applies at each stage.
  2. Compare data warehouses, data lakes, lakehouses, and feature stores in an AI project.
  3. Discuss how labelling protocols, annotator disagreement, and target definitions affect supervised learning.
  4. Explain how sampling, dataset splitting, and temporal validity influence claims about model generalisation.
  5. Discuss the relationship among data quality, privacy, fairness, security, and organisational accountability.

Analytical / Application Questions

  1. A bank combines customer records from three systems with different identifiers, currencies, and date formats. Design a data-integration and validation plan, including lineage and quality checks.
  2. A hiring model has similar overall accuracy for two demographic groups, but the false-negative rate is much higher for one group. Analyse possible data causes and propose an evaluation and governance response.
  3. Design a lifecycle-monitoring plan for a streaming fraud-detection system. Specify what should be monitored, how drift could appear, and what actions should follow detected degradation.

Multiple Choice Questions with Answers

Question 1

Which data type is most appropriately represented by a relational table with a fixed schema?

A. Structured data

B. Unstructured data

C. Synthetic data

D. Streaming data

Correct Answer: A. Structured data

Question 2

What is the primary purpose of a validation dataset?

A. To store raw source records

B. To tune and compare model choices before final testing

C. To replace the production database

D. To guarantee fairness

Correct Answer: B. To tune and compare model choices before final testing

Question 3

A field has 2,000 records, of which 100 are missing. What is its missingness rate?

A. 0.5%

B. 5%

C. 10%

D. 20%

Correct Answer: B. 5%

Question 4

Which situation is an example of data leakage?

A. Scaling features using training-set statistics

B. Using a diagnosis made after admission to predict admission risk

C. Removing duplicate records before splitting data

D. Recording the data-collection timestamp

Correct Answer: B. Using a diagnosis made after admission to predict admission risk

Question 5

In the equation z = (x − μ) / σ, what does μ represent?

A. The training-set mean

B. The number of missing values

C. The model learning rate

D. The prediction threshold

Correct Answer: A. The training-set mean

Question 6

Why may a time-based split be preferable to a random split?

A. It always increases accuracy

B. It reflects the temporal order of deployment and reduces future-information contamination

C. It eliminates the need for labels

D. It converts unstructured data into structured data

Correct Answer: B. It reflects the temporal order of deployment and reduces future-information contamination

Question 7

Which statement about pseudonymised data is correct?

A. It is always anonymous

B. It cannot be linked with any other dataset

C. Direct identifiers may be replaced, but re-identification risk can remain

D. It does not require access control

Correct Answer: C. Direct identifiers may be replaced, but re-identification risk can remain

Question 8

What does concept drift mean?

A. A change in the relationship between inputs and the target

B. A missing column in a database

C. A reduction in storage capacity

D. A disagreement between two annotators

Correct Answer: A. A change in the relationship between inputs and the target

Question 9

Which practice best supports reproducibility?

A. Overwriting the original dataset after cleaning

B. Keeping versioned data, code, transformations, and metadata

C. Removing timestamps from all records

D. Using only the largest available dataset

Correct Answer: B. Keeping versioned data, code, transformations, and metadata

Question 10

Why can removing a sensitive attribute fail to remove unfairness?

A. Models cannot use numerical variables

B. Correlated proxy variables may still encode information about the attribute

C. Sensitive attributes are required for every model

D. Fairness is determined only by dataset size

Correct Answer: B. Correlated proxy variables may still encode information about the attribute

AI & Machine Learning Fundamentals
Chapter 4 of 14