AI Glossary / Mathematics and optimization / Beginner

Label vector

Definition

A label vector is an ordered collection of target values aligned with the examples in a dataset. For m examples with one scalar target each, it is commonly written y=(y₁,…,yₘ)ᵀ. Its position-by-position correspondence with the input data is essential: the first label belongs to the first example, and so on.

What it means

A feature matrix holds the information supplied to a model, while the label vector holds the answers used to train or evaluate it. In a sales-prediction task, rows might represent store-days and the corresponding targets might be units sold. In a classification task, targets might be category identifiers.
The word vector describes organization, not guaranteed numerical meaning. Category codes stored as numbers are still categories unless the task defines a meaningful numerical scale. The vector also does not certify that labels are accurate, complete, independent, or appropriate for the business question.
Terminology can vary: some authors call the collection of several labels for one example a label vector. This article follows the dataset-level convention, with one component per example, and explicitly identifies other shapes when needed.

How it works

Choose a stable ordering of examples and collect each example's target in that same order. A matrix X with m rows and d feature columns then pairs naturally with a target vector of length m. Numerical methods often display y as an m-by-1 column, although software may store a one-dimensional array instead.
Any operation that changes row order must apply the same change to the targets. Shuffling, filtering, splitting, and joining records should preserve example-target identity. Keeping a stable record key helps verify the pairing even when the calculation ultimately uses arrays.
If every example has several targets, use an explicitly described matrix or structured collection rather than pretending it is still one scalar per row. Missing labels likewise require a defined representation or mask; replacing them with zero is valid only when zero really means the observed target value.

Three practical examples

  • A regression pipeline can pair each building's measured features with its recorded energy consumption in a target vector.
  • A document classifier can align category identifiers with document embeddings before training and evaluation.
  • An experiment can store observed outcomes in one vector and predicted outcomes in another, comparing entries that refer to the same examples.

Think of it this way

Think of a teacher's answer record beside an ordered stack of student submissions. Every answer must remain beside the submission it describes. The analogy explains alignment, but machine-learning labels need not be exam answers, and correctly matching records does not establish that the answers themselves are reliable.

Worked example

Consider an original dataset with three record identifiers: A, B, and C. Their numerical targets are 10, 20, and 40, so the label vector in that order is y=(10,20,40)ᵀ. Suppose predictions in the same order are ŷ=(12,18,39)ᵀ. The errors are 2, −2, and −1. The mean squared error is (4+4+1)/3=3.
Now reorder the feature rows to C, A, B. The matching target vector must become (40,10,20)ᵀ, and the matching predictions become (39,12,18)ᵀ. The squared errors are now 1, 4, and 4, so their mean remains 3. Reordering every related object together changes presentation without changing this metric.
If the feature rows and predictions are reordered but the target vector is accidentally left as (10,20,40)ᵀ, the calculated errors become 29, −8, and −22. The reported mean squared error becomes (841+64+484)/3=463. The model has not changed; the broken correspondence has corrupted the evaluation.
This is why checking only that the feature matrix has three rows and the label vector has three entries is insufficient. Their lengths agree in both the correct and incorrect versions. Record identity, ordering, and the meaning of each target must agree as well.

Illustrative case study

In a fictional property-services firm, an analyst combines inspection features with a separate file of repair-cost targets. Both files contain the same number of records, but one export is sorted by inspection date and the other by property code. Pairing rows by position would silently attach some costs to the wrong properties.
The analyst joins on the agreed inspection identifier, checks for duplicate keys and missing matches, and then constructs the aligned feature matrix and label vector. A small set of manually reviewed pairs supports the alignment check. This fictional example illustrates data preparation; it does not claim a measured business outcome.

Common misconceptions and mistakes

Do not confuse the target vector with model predictions, model coefficients, or a list of unique class names. Do not assume identical vector lengths establish correct alignment. Sorting targets independently can destroy the learning problem while leaving all array dimensions valid.
Also, a zero target and an unknown target are different states. Category identifiers should not be averaged as if they were measurements. In multi-output tasks, document which dimension indexes examples and which indexes targets; ambiguous orientation can produce incorrect calculations or misleading reports.

Business use

Reliable target alignment is a basic condition for trustworthy training and evaluation. Teams should retain record identifiers, target definitions, collection dates where relevant, and the transformation history used to create the final vector. A changed business definition may require a new target version even when the values use the same storage type.
When diagnosing unexpectedly poor or unusually strong model results, inspect a few complete feature-target pairs. Alignment errors, duplicate joins, and inappropriate target availability can matter more than a change in algorithm. These checks support the validity of the comparison rather than guaranteeing future predictive performance.

People also ask

Must labels be numbers?

The underlying targets can be categories or other objects, though many numerical algorithms require a documented encoding.

Does every dataset have one label vector?

No. Unlabeled datasets have no observed targets, and multi-output datasets may require a target matrix or richer structure.

Can I shuffle the label vector?

Yes, if the associated examples receive exactly the same permutation. Independent shuffling generally breaks their correspondence.

Check your understanding

A dataset is reordered from A, B, C to B, C, A. Its original targets are (5,9,2). What is the correctly reordered target vector?

Answer: (9,2,5), preserving each record's own target.

Related terms

  • Label
  • Label space
  • Feature matrix
  • Labeled data point
  • Supervised learning
  • Mean Squared Error
  • target variable
  • prediction vector
  • data alignment

Learn next

Next, trace one record through a data join, a train-test split, and a batch shuffle. Verify its target at each step. Then study feature matrices to understand how row alignment connects the input and output sides of supervised learning.

  • Supervised learning

More in Mathematics and optimization

  • Absolute error loss - Absolute error loss measures a numerical prediction's error as the absolute difference between its predicted and reference values: L(y,y-hat)=|y-y-hat|.
  • Active-set method - An active-set method is an optimization approach that works with a changing subset of constraints believed to be tight at the solution.
  • Adjoint state method - The adjoint state method computes how a chosen objective changes when the parameters of a mathematical model change.
  • Σ-algebra
  • Algebraic connectivity - Algebraic connectivity is the second-smallest eigenvalue of a graph's Laplacian matrix.
  • Algorithm IMED - Algorithm IMED, short for Indexed Minimum Empirical Divergence, is a method for choosing actions in a stochastic multi-armed bandit problem.

Sources

Primary terminology reference: Alexander Jung and contributors, The Aalto Dictionary of Machine Learning, label vector entry: https://aaltodictionaryofml.github.io/ADictML_Main.pdf . The alignment example, error calculation, and fictional workflow are original illustrations.

Previous: Label space Next: Labeled data

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer