Skip to main content
Vectors let us compare one attribute at a time — for example, filtering strictly for “blue gym bags.” To combine and compare multiple attributes at once (colour and price, for example), we use matrices. A matrix is a two-dimensional array (an m-by-n table): each row is an observation (one product), and each column is a feature (type, colour, price, rating, etc.). In mathematical notation we write a matrix as rows of numbers inside square brackets; in code it’s a 2-D array or list of lists.
The image shows a matrix notation concept with a table listing products, their types, colors, prices, and ratings. There is also a person standing next to the table, possibly explaining the concept.
Each row represents one bag and each column represents a feature. For example, Alice has found a light-blue gym bag in the inventory — that corresponds to a single row in the matrix.
The image shows a table titled "Finding the Perfect Bag With Matrix," listing bag attributes like ID, type, color, price, and rating, alongside a person presenting the information.
Rather than applying filters one at a time, a matrix lets us combine multiple criteria (e.g., colour ≈ blue AND price ≈ 23) and run vectorized operations to select matching rows efficiently. This is much faster and more scalable than iterating through each record and applying individual checks.
In data terms: rows = observations (products), columns = features. A matrix with m rows and n columns is often called an m-by-n matrix.
Simple Python example showing a matrix as a list of rows and filtering by price:
# Each row: [id, type, color, price, rating]
products = [
    [1, "backpack", "blue", 23.50, 4.6],
    [2, "gym-bag", "light blue", 22.80, 4.4],
    [3, "duffel", "black", 35.00, 4.7],
]

# Find products priced around $23 (within $1)
result = [row for row in products if abs(row[3] - 23.0) <= 1.0]
print(result)
# Example output:
# [[1, 'backpack', 'blue', 23.5, 4.6], [2, 'gym-bag', 'light blue', 22.8, 4.4]]
For richer, context-aware recommendations we extend matrices into tensors. A tensor is a multi-dimensional array — in practice often three or more dimensions. Think of a tensor like a Rubik’s cube: each slice is a matrix, and stacking slices creates additional axes of information. A common tensor layout in recommendation systems is:
  • users × products × interactions (or time).
  • The interactions axis can enumerate clicks, purchases, ratings, adds-to-cart, or time steps.
These additional dimensions capture user behaviour across multiple modes so models can learn patterns across users, items, and interaction types. To make the difference clear:
RepresentationDimensionsExample use
Vector1DSingle user preferences for colours
Matrix2DProducts × features (type, colour, price, rating)
Tensor3D+Users × Products × Interactions (clicks, ratings, time)
The image shows a 3D matrix labeled with product features and interactions, alongside a "You Might Also Like" section with product recommendations and prices. A person is speaking in the lower-right corner.
Applied to Alice: the tensor tracks not only product features but also how Alice interacted with those products (clicked, searched, added to cart, rated). By learning multi-dimensional patterns (e.g., Alice tends to click blue backpacks and rate them highly), recommendation models can surface items she’s likely to buy next — such as backpacks, blue trainers, or gym equipment related to items she viewed. Because tensors encode richer relationships than flat lists or 2-D matrices, models built on them can make stronger, more personalized predictions. Vectors, matrices, and tensors are therefore core building blocks in search systems, recommendation engines, and many machine-learning models.
The image is a presentation slide summarizing the uses of vectors, matrices, and tensors in data representation, alongside a person explaining.
Better-structured, multi-dimensional data leads to smarter systems. When customers find what they need quickly and accurately, conversion and retention improve. Further reading and resources:

Watch Video