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_id | temperature_c | vibration_mm_s | hours_used | fault_detected |
|---|---|---|---|---|
| M01 | 64.2 | 2.1 | 180 | No |
| M02 | 91.4 | 7.8 | 1,420 | Yes |
| M03 | 72.0 | 3.4 | 610 | No |
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.
| Organization | Definition | Typical examples | Common handling |
|---|---|---|---|
| Structured | Follows an explicit schema of fields and relationships | Database tables, CSV records | SQL, Pandas, tabular models |
| Semi-structured | Contains recognizable keys or markers without a fixed relational table layout | JSON, XML, application logs | Parsing, validation, schema normalization |
| Unstructured | Does not naturally fit a fixed table of predefined fields | Documents, images, audio, video | Specialized 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 type | Meaning | Example | Important consideration |
|---|---|---|---|
| Numerical | Quantities represented by numbers | Age, pressure, speed | Units, ranges, precision |
| Categorical | Membership in a class or label | Device type, country | Valid categories, rare values |
| Ordinal | Categories with a meaningful order | Low, medium, high | Gaps between levels may not be equal |
| Boolean | Two logical states | Passed/failed | Definition of each state |
| Text | Words or character sequences | Reviews, support tickets | Language, encoding, context |
| Image | Spatial arrays of pixel values | X-ray, road camera frame | Resolution, lighting, labels |
| Audio | Sound sampled over time | Speech, machine noise | Sampling rate, background noise |
| Video | Ordered visual frames, often with audio | Traffic recording | Temporal alignment, frame rates |
| Time series | Values indexed by time | Hourly energy usage | Order, frequency, temporal leakage |
| Graph | Entities connected by relationships | Social network, citation network | Nodes, edges, changing structure |
| Spatial | Location-related measurements | GPS coordinates, maps | Coordinate 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 method | Example | Strength | Common risk |
|---|---|---|---|
| Operational databases | Orders or support records | Reflects actual activity | Records were created for operations, not research |
| Application events | Clicks, searches, interactions | Captures behavior over time | Incomplete instrumentation or consent issues |
| Sensors and IoT devices | Temperature, motion, vibration | Direct physical measurements | Drift, calibration errors, connectivity gaps |
| Surveys and forms | Preferences, questionnaires | Can target specific questions | Recall and response bias |
| Human annotation | Images labeled with objects | Task-specific targets | Inconsistent interpretation |
| Public or licensed datasets | Research datasets | Useful for learning and baselines | Licensing, representativeness, stale data |
| APIs | Weather or financial feeds | Programmatic access | Rate limits, schema changes, use restrictions |
| Experiments | Controlled intervention outcomes | Can support stronger causal conclusions | Cost, ethics, design constraints |
| Simulations | Synthetic robot trajectories | Controlled, scalable scenarios | Gap 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.
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:
- Write a clear operational definition of every label.
- Train annotators on representative examples and edge cases.
- Track disagreement and use review or adjudication when appropriate.
- Preserve the label source, version, and time it was assigned.
- 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:
| Metadata | Question answered |
|---|---|
| Source | Which system, device, organization, or dataset produced the records? |
| Collection period | When were observations recorded? |
| Ingestion time | When did this pipeline receive them? |
| Units and schema | How should each field be interpreted? |
| Inclusion criteria | Which observations were collected or excluded? |
| Label definition | What exactly does the target represent? |
| Permissions and license | What uses of the data are authorized? |
| Known limitations | Which populations, conditions, or values may be unreliable? |
| Dataset version | Which 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
| Mistake | Why it matters | Better approach |
|---|---|---|
| Collecting data before defining the target | Critical fields may be absent | Specify the task and prediction-time inputs first |
| Assuming more data is always better | Duplicates and bias can scale with volume | Evaluate coverage, uniqueness, and relevance |
| Ignoring units or timestamps | Values become incomparable | Record schemas, units, and time zones |
| Treating operational labels as perfect | Errors become training targets | Audit definitions and label quality |
| Using a convenient but narrow sample | Performance may fail in deployment | Compare sample coverage with the intended population |
| Losing source information | Problems become difficult to trace | Preserve provenance, identifiers, and versions |
| Collecting unnecessary personal data | Increases security and privacy risks | Minimize fields and define permitted uses |
| Combining future and past observations carelessly | Can create data leakage | Preserve 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:
- Problem formulation: Decide what the system must predict or generate.
- Collection: Obtain records that represent the intended environment.
- Preparation: Correct or document errors and construct usable representations.
- Splitting and labeling: Establish independent evaluation data and reliable targets.
- Model development: Train and compare suitable approaches.
- 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
- What is the difference between a dataset’s organization and the data types it contains?
- Why can a numerical identifier be a poor numerical feature?
- How might collection during only one time period bias a forecasting dataset?
- What is the difference between data provenance and data lineage?
- Why can a dataset with one million records still fail to represent its deployment population?
- Which metadata would you save for readings collected from an IoT temperature sensor?
- Why is a label from an operational database not necessarily a perfect ground-truth value?
Related PlainCS concepts
- AI Knowledge Map — the broader learning sequence.
- What Is Artificial Intelligence? — the field and its central approaches.
- Data Analysis with Pandas and SQL — exploring and querying tabular records.
- Data Cleaning and Preprocessing — handling errors, missing values, and transformations.
- Feature Engineering, Encoding, and Scaling — turning collected values into useful model inputs.
- Data Splitting, Labeling, and Leakage — creating valid training and evaluation sets.
- How to Formulate an AI Problem — connecting data requirements to a computational objective.
References and further reading
- NIST AI Risk Management Framework — data quality, governance, and AI risk.
- Google Machine Learning Crash Course — datasets, generalization, and practical ML concepts.
- Datasheets for Datasets (Gebru et al.) — systematic documentation of dataset creation, composition, and use.
- Pandas user guide — tabular ingestion and inspection in Python.
Related articles in
- AI Agents and Tool-Using Workflows — Learn agent goals, tool invocation, planning, state, permissions, and how to evaluate multi-step AI workflows.
- AI Development Tools: Git, Jupyter, and APIs — Learn how Git, Jupyter notebooks, Python environments, and APIs fit together in reproducible, secure artificial intelligence workflows.
- How AI Is Changing Theoretical Computer Science — AI is beginning to help researchers explore algorithms, mathematical structures, and formal proofs. Here is what it can do, what still needs human judgment, and why verification matters.