Artificial Intelligence • Data Engineering and Preparation • 17 min read

Data Types and Data Collection for AI

An artificial intelligence system learns or makes decisions using information about the world. That information may arrive as numerical measurements, database records, documents, images, audio recordings, or streams of sensor readings. Before choosing an AI model, developers must understand what the data represents, where it comes from, and whether it is suitable for the intended task.

Data collection is the process of acquiring observations or records for a defined purpose. A dataset is an organized collection of those records. Collecting a large dataset is not enough: its coverage, accuracy, legality, and relationship to the problem determine whether it can support a reliable system.

This article builds on Data Analysis with Pandas and SQL and introduces the data lifecycle before Data Cleaning and Preprocessing.

First intuition: numbers are not automatically useful data

Suppose you want to predict tomorrow’s electricity demand. You could collect readings from smart meters, local temperature, calendar dates, and historical demand. Each source has a different format and a different meaning. A temperature value of 29 is ambiguous unless you know whether it means Celsius or Fahrenheit; a meter reading is misleading unless you know when and where it was recorded.

A useful first-pass data record might look like this:

{
  "timestamp": "2026-11-01T15:00:00+05:00",
  "temperature_c": 29.0,
  "demand_kw": 420.5,
  "site_id": "site-17"
}

The value of the record comes from its meaning, units, timing, provenance, and coverage, not merely from the fact that it is stored digitally. This is why data collection decisions must follow the problem definition rather than begin with “collect as much as possible.”

1. What counts as data in an AI system?

Data is recorded information that can be stored, processed, and analyzed. In machine learning, individual observations or examples provide information that a model can use to learn patterns or be evaluated against them.

Consider a system that predicts whether a machine needs maintenance. One observation could contain temperature, vibration, operating hours, and an indicator of a confirmed mechanical fault.

machine_idtemperature_cvibration_mm_shours_usedfault_detected
M0164.22.1180No
M0291.47.81,420Yes
M0372.03.4610No

Here, each row is an observation. The measurements could become features (model inputs), while fault_detected could become the target (the value to predict). The identifier machine_id helps track records but might not be a meaningful predictive feature.

The same record can support different tasks. If the objective is to estimate future temperature, temperature_c might be the target instead. The task determines how data is interpreted.

2. Structured, semi-structured, and unstructured data

One common classification describes how data is organized.

OrganizationDefinitionTypical examplesCommon handling
StructuredFollows an explicit schema of fields and relationshipsDatabase tables, CSV recordsSQL, Pandas, tabular models
Semi-structuredContains recognizable keys or markers without a fixed relational table layoutJSON, XML, application logsParsing, validation, schema normalization
UnstructuredDoes not naturally fit a fixed table of predefined fieldsDocuments, images, audio, videoSpecialized preprocessing and representations

These categories are practical descriptions, not strict boundaries. A JSON document can follow a rigid schema, and an image file has structured metadata even though its visual content is not tabular.

Structured data

Structured data typically organizes observations into rows and variables into columns. Field names, types, and constraints help software interpret records consistently. For example, a transaction table may define amount as a decimal number and created_at as a timestamp.

Relational databases are useful when records must be queried, joined, checked against constraints, and updated reliably. Tables are also a common input to traditional machine-learning algorithms.

Semi-structured data

Semi-structured records commonly use nested objects or lists:

{
  "device_id": "sensor-17",
  "time": "2026-10-30T10:15:00Z",
  "readings": {
    "temperature_c": 28.4,
    "humidity_percent": 61
  }
}

A program can extract fields such as readings.temperature_c, but it must also handle missing keys, changes in schema, and unexpected values.

Unstructured data

A photograph contains pixels, an audio recording contains sampled sound signals, and a document contains text and potentially layout information. Such sources generally need conversion into numerical representations before model training. An image may become a tensor of pixel values; text may become token IDs; audio may become waveform samples or time-frequency features.

Calling data unstructured does not mean it lacks meaningful patterns. It means those patterns are not directly presented as conventional rows and columns.

3. Data types by content and measurement

Another useful classification concerns what a value means, rather than how the entire dataset is stored.

Data typeMeaningExampleImportant consideration
NumericalQuantities represented by numbersAge, pressure, speedUnits, ranges, precision
CategoricalMembership in a class or labelDevice type, countryValid categories, rare values
OrdinalCategories with a meaningful orderLow, medium, highGaps between levels may not be equal
BooleanTwo logical statesPassed/failedDefinition of each state
TextWords or character sequencesReviews, support ticketsLanguage, encoding, context
ImageSpatial arrays of pixel valuesX-ray, road camera frameResolution, lighting, labels
AudioSound sampled over timeSpeech, machine noiseSampling rate, background noise
VideoOrdered visual frames, often with audioTraffic recordingTemporal alignment, frame rates
Time seriesValues indexed by timeHourly energy usageOrder, frequency, temporal leakage
GraphEntities connected by relationshipsSocial network, citation networkNodes, edges, changing structure
SpatialLocation-related measurementsGPS coordinates, mapsCoordinate systems, location precision

A dataset can include several types simultaneously. A healthcare record might combine numeric measurements, categorical codes, notes, and medical images. Systems built to work across such inputs are called multimodal AI systems.

Numerical measurements: units matter

A sensor reading of 35 means little without a unit and context. Is it 35 degrees Celsius, 35 degrees Fahrenheit, or an uncalibrated device value? If two sources encode temperatures in different units, a model may learn misleading relationships.

Distinguish continuous quantities (such as mass, often measured on a scale) from discrete counts (such as number of website visits). Stored data can still be rounded or limited by sensor resolution.

Categorical values are not automatically numerical

A category such as red, blue, or green may be internally encoded as 0, 1, or 2, but those numbers do not imply an inherent distance or ranking. Likewise, a customer ID may consist entirely of digits without representing a measurable quantity.

Encoding choices are explored in Feature Engineering, Encoding, and Scaling.

Time introduces dependencies

Time-series observations are often dependent on earlier observations. Randomly mixing future and past records can make a forecast appear accurate by leaking information that would not have been available at prediction time. Sampling frequency, time zones, clock synchronization, and missing intervals also matter.

4. How data is collected

Collection methods should be chosen to match the problem, operating environment, and permissions available.

Source or methodExampleStrengthCommon risk
Operational databasesOrders or support recordsReflects actual activityRecords were created for operations, not research
Application eventsClicks, searches, interactionsCaptures behavior over timeIncomplete instrumentation or consent issues
Sensors and IoT devicesTemperature, motion, vibrationDirect physical measurementsDrift, calibration errors, connectivity gaps
Surveys and formsPreferences, questionnairesCan target specific questionsRecall and response bias
Human annotationImages labeled with objectsTask-specific targetsInconsistent interpretation
Public or licensed datasetsResearch datasetsUseful for learning and baselinesLicensing, representativeness, stale data
APIsWeather or financial feedsProgrammatic accessRate limits, schema changes, use restrictions
ExperimentsControlled intervention outcomesCan support stronger causal conclusionsCost, ethics, design constraints
SimulationsSynthetic robot trajectoriesControlled, scalable scenariosGap between simulation and reality

Primary data is gathered directly for the current investigation, while secondary data was previously collected for another purpose. Secondary data may be convenient but can omit variables necessary for the new task.

Data obtained from websites or platforms should be collected only through permitted methods, with appropriate respect for copyright, access restrictions, privacy, and applicable terms and laws.

5. From collection to a usable dataset

A reliable workflow records how data moves from a source into a dataset suitable for exploration and eventual model development.

Data collection workflow from defined objectives and sources to ingestion, validation, storage, and downstream preparation.
Data preparation follows collection. Preserving the original records and documenting their origins makes subsequent processing more auditable.

Define the task first

Write down what an individual record represents, which inputs will be available when predictions are made, and what output the system must produce. For an equipment-failure predictor, a record might represent one machine on one day, not a machine’s entire lifetime.

Establish a collection protocol

A collection protocol specifies which records are eligible, over what period, how frequently observations are captured, and what metadata is recorded. It should also describe what happens when devices go offline, users withdraw consent, or sources become unavailable.

Preserve raw records

When feasible, keep an immutable or separately versioned raw copy before transformation. Preserve source identifiers and ingestion timestamps. This makes it easier to investigate errors without relying on a cleaned dataset that has lost its original context.

6. Sampling and representativeness

A population is the full group about which a system intends to make claims. A sample is the subset of observations actually collected.

Suppose a model will be used on road images taken both day and night. If nearly all training images were collected at noon, the dataset may not represent the intended operating conditions even if it contains thousands of photographs.

Common sampling strategies

  • Simple random sampling: Choose observations randomly from a defined population when a suitable sampling frame exists.
  • Stratified sampling: Divide the population into important groups and sample from each group.
  • Systematic sampling: Select observations at a fixed interval after an appropriate starting point.
  • Convenience sampling: Use easily accessible observations; inexpensive, but often biased.
  • Time-based sampling: Collect observations over specified periods, which can capture changes and seasonality if designed carefully.

A large convenience sample is not automatically more representative than a smaller, well-designed sample.

Selection bias and coverage bias

Selection bias occurs when the process that determines which observations enter a dataset distorts the relationships being studied. Coverage bias arises when parts of the intended population are missing or underrepresented.

Examples include surveying only active app users to learn why people abandon an app, or training speech recognition only on quiet studio recordings and expecting equal performance in noisy streets.

Stratification can help ensure group coverage, but it does not by itself repair every source of bias. Evaluate whether the collection process mirrors the actual use case.

7. Labels, targets, and ground truth

In supervised learning, a dataset contains input examples paired with target values, often called labels. The label may come from a direct measurement, a verified outcome, expert annotation, or an existing operational record.

A label is not always unquestionable truth. Consider an image labeled “damaged component.” Two trained annotators may disagree about a borderline case. A diagnosis may be revised later, and a customer-churn label may depend on the chosen time window.

Good labeling practices include:

  1. Write a clear operational definition of every label.
  2. Train annotators on representative examples and edge cases.
  3. Track disagreement and use review or adjudication when appropriate.
  4. Preserve the label source, version, and time it was assigned.
  5. Audit labels for inconsistent rules, missing classes, and group-specific errors.

Ground truth usually means the reference outcome used to evaluate a prediction. Its reliability depends on how that outcome was established; calling a label ground truth does not make it error-free.

Detailed labeling and split design are covered in Data Splitting, Labeling, and Leakage.

8. Data provenance, lineage, and documentation

Data provenance describes where records came from and how they were obtained. Data lineage traces how records move through transformations and systems. Together, they make datasets easier to reproduce, audit, and maintain.

At minimum, record:

MetadataQuestion answered
SourceWhich system, device, organization, or dataset produced the records?
Collection periodWhen were observations recorded?
Ingestion timeWhen did this pipeline receive them?
Units and schemaHow should each field be interpreted?
Inclusion criteriaWhich observations were collected or excluded?
Label definitionWhat exactly does the target represent?
Permissions and licenseWhat uses of the data are authorized?
Known limitationsWhich populations, conditions, or values may be unreliable?
Dataset versionWhich exact set of records was used?

A data dictionary documents fields and their definitions. A dataset card or similar documentation can describe intended uses, collection procedures, composition, and limitations. These artifacts are especially useful when datasets are shared across teams.

9. Privacy, security, and appropriate use

Data collection for AI can involve personal, commercially sensitive, or otherwise restricted information. Access to data does not necessarily establish permission to use it for every model-training purpose.

Apply the following principles throughout the lifecycle:

  • Purpose limitation: Collect and use data for specific, legitimate purposes.
  • Data minimization: Avoid collecting fields that are not needed for the task.
  • Consent and lawful basis: Respect applicable legal requirements and any promises made to data subjects.
  • Access control: Restrict access according to responsibilities and sensitivity.
  • Secure storage and transfer: Use appropriate protections for data at rest and in transit.
  • Retention and deletion: Establish when data is deleted and how deletion requests or retention obligations are handled.
  • De-identification safeguards: Recognize that removing direct identifiers may not eliminate re-identification risk.

Personal identifiers are often unnecessary predictors. For instance, if the task is to estimate equipment failure, an operator’s name is unlikely to be required. Removing it early can simplify compliance and reduce exposure.

Applicable rules depend on jurisdiction, data type, use case, and contractual obligations. This article outlines engineering principles, not a substitute for legal review.

10. A practical Python collection example

The following example demonstrates basic ingestion and validation using an in-memory set of simulated sensor records. It does not collect personal information or call an external API.

import pandas as pd

records = [
    {"sensor_id": "A1", "temperature_c": 23.5, "time": "2026-11-01T08:00:00Z"},
    {"sensor_id": "A1", "temperature_c": 24.1, "time": "2026-11-01T09:00:00Z"},
    {"sensor_id": "A2", "temperature_c": 21.9, "time": "2026-11-01T08:00:00Z"},
]

df = pd.DataFrame(records)
df["time"] = pd.to_datetime(df["time"], utc=True, errors="coerce")
df["temperature_c"] = pd.to_numeric(
    df["temperature_c"], errors="coerce"
)

required = ["sensor_id", "temperature_c", "time"]
invalid = df[required].isna().any(axis=1)

print("Collected records:", len(df))
print("Records requiring review:", int(invalid.sum()))
print(df.dtypes)

The validation checks whether required values can be interpreted as the expected types. It does not establish that a sensor is calibrated or that a reading is physically plausible. Those require additional rules informed by the device specification and intended use.

For a real pipeline, include collection logs, access controls, retry policies, schema checks, and a raw-data preservation strategy. Avoid silently deleting records that fail validation: record the failure reason and decide how to handle them during preparation.

11. Common mistakes in AI data collection

MistakeWhy it mattersBetter approach
Collecting data before defining the targetCritical fields may be absentSpecify the task and prediction-time inputs first
Assuming more data is always betterDuplicates and bias can scale with volumeEvaluate coverage, uniqueness, and relevance
Ignoring units or timestampsValues become incomparableRecord schemas, units, and time zones
Treating operational labels as perfectErrors become training targetsAudit definitions and label quality
Using a convenient but narrow samplePerformance may fail in deploymentCompare sample coverage with the intended population
Losing source informationProblems become difficult to tracePreserve provenance, identifiers, and versions
Collecting unnecessary personal dataIncreases security and privacy risksMinimize fields and define permitted uses
Combining future and past observations carelesslyCan create data leakagePreserve temporal order and prediction-time constraints

12. How data collection connects to the AI lifecycle

Data collection is upstream of cleaning, feature representation, training, and evaluation. A model cannot recover a missing population merely by optimizing more aggressively, and high accuracy on an unrepresentative dataset may not transfer to real users.

A useful conceptual sequence is:

  1. Problem formulation: Decide what the system must predict or generate.
  2. Collection: Obtain records that represent the intended environment.
  3. Preparation: Correct or document errors and construct usable representations.
  4. Splitting and labeling: Establish independent evaluation data and reliable targets.
  5. Model development: Train and compare suitable approaches.
  6. Deployment and monitoring: Check whether incoming data still resembles intended conditions.

The process is iterative. Discovering weak coverage during evaluation may require changing the collection protocol rather than merely changing the model.

13. Check your understanding

  1. What is the difference between a dataset’s organization and the data types it contains?
  2. Why can a numerical identifier be a poor numerical feature?
  3. How might collection during only one time period bias a forecasting dataset?
  4. What is the difference between data provenance and data lineage?
  5. Why can a dataset with one million records still fail to represent its deployment population?
  6. Which metadata would you save for readings collected from an IoT temperature sensor?
  7. Why is a label from an operational database not necessarily a perfect ground-truth value?

References and further reading

Related articles in

Image preview

Fit