Contents
Deep Breakdown
What it tells me (Situation Awareness): The formula expresses any 3D vector as a linear combination of the three standard basis vectors. , , are unit vectors aligned with the -, -, -axes. The coefficients are the coordinates — how far to go in each direction. This decomposition makes every vector operation into a set of scalar operations on coordinates. All of data science is built on this: every data point is a vector, every model parameter is a vector, every embedding is a vector.
Flowchart
Real-world use
Where it is used
Every time you represent a data point, feature vector, weight vector, or embedding as a numeric array, you are using this decomposition. In Python: np.array([v1, v2, v3]). The coordinate representation is the computational form; the basis vector form shows the underlying structure.
Problem it solves
Provides the bridge between geometric vectors (arrows in space) and their numeric representations (arrays of numbers). Once you have coordinates, you can compute anything: distances, dot products, projections, matrix products. Without a choice of basis, vectors would be abstract geometric objects with no numeric handle.
How it solves the problem
The standard basis is orthonormal (each pair is perpendicular and each has length 1). This makes the coordinate extraction trivial: (dot product picks out the -component), , . Any other orthonormal basis would work too (PCA basis, Fourier basis), and the formula generalizes to dimensions and non-standard bases.
Example in a business
A DA prepares features for a customer churn model: age, account tenure, monthly spend. Each customer becomes a vector where , , . The choice of basis () is the original feature axes. After PCA, a new basis is chosen that aligns with variance directions. The same vector is re-expressed in the new coordinate system: same geometric object, different coordinates.
The formula, piece by piece
- : the vector being represented
- : the scalar coordinates (the components); can be any real numbers
- : unit basis vector along -axis:
- : unit basis vector along -axis:
- : unit basis vector along -axis:
- : scale each basis vector by its coordinate, then sum (linear combination)
- Alternative notations: (coordinate tuple), (column vector in matrix algebra)
The formula in words
"A vector in 3D space is described by how far it goes along the -axis ( units in the direction), the -axis ( units in the direction), and the -axis ( units in the direction). The vector is the sum of these three directional contributions." Tiny example: . . In words: go 2 units right (), 3 units down (), 1 unit forward ().
Critical Concepts
- Basis choice matters: the same physical vector has different coordinates in different bases. Standard basis gives the simplest coordinates.
- Generalization to dimensions: in ML, where can be 784 (MNIST pixels), 768 (BERT embedding dim), or any size.
- Orthonormality of standard basis: , , etc. This makes extracting coordinates easy.
- PCA changes the basis: PCA finds a new orthonormal basis aligned with data variance. Coordinates in the new basis are the principal component scores.
- Not the same as coordinates vs. vectors: coordinates are the numbers ; the vector is the geometric object. They are equivalent only once you have fixed a basis.
- Column vector notation: for matrix algebra, write as ; this is a matrix.
Step-by-step calculation (tiny example)
Step 1: Read the coordinates : , , .
Step 2: Expand using basis vectors . .
Step 3: Sum to recover the original vector .
Code examples
Beginner example (Python)
import numpy as np # -- Vector representation in standard basis ---
v1, v2, v3 = 4.0, -1.0, 2.0 # Standard basis vectors
i_hat = np.array([1.0, 0.0, 0.0])
j_hat = np.array([0.0, 1.0, 0.0])
k_hat = np.array([0.0, 0.0, 1.0]) # Reconstruct v from components
v_reconstructed = v1 * i_hat + v2 * j_hat + v3 * k_hat
v_direct = np.array([v1, v2, v3])
print(f"v (direct) = {v_direct}")
print(f"v (from basis) = {v_reconstructed}")
print(f"Equal? : {np.allclose(v_direct, v_reconstructed)}") # Extract coordinates via dot product with basis vectors
print(f"\nExtract v1 = v . i_hat : {np.dot(v_direct, i_hat)}")
print(f"Extract v2 = v . j_hat : {np.dot(v_direct, j_hat)}")
print(f"Extract v3 = v . k_hat : {np.dot(v_direct, k_hat)}")Beginner example (R)
# -- Vector representation in standard basis ---
v1 <- 4; v2 <- -1; v3 <- 2
i_hat <- c(1, 0, 0)
j_hat <- c(0, 1, 0)
k_hat <- c(0, 0, 1)
v_reconstructed <- v1 * i_hat + v2 * j_hat + v3 * k_hat
v_direct <- c(v1, v2, v3)
cat("v (direct) :", v_direct, "\n")
cat("v (from basis) :", v_reconstructed, "\n")
cat("Equal? :", isTRUE(all.equal(v_direct, v_reconstructed)), "\n") # Dot product extracts coordinates
cat("\nv1 via dot:", sum(v_direct * i_hat), "\n")
cat("v2 via dot:", sum(v_direct * j_hat), "\n")
cat("v3 via dot:", sum(v_direct * k_hat), "\n")Professional example (Python)
import numpy as np
import pandas as pd
from sklearn.decomposition import PCA
np.random.seed(42) # -- Business scenario: basis change via PCA ---
# Customer feature vectors in standard basis (age, tenure, spend).
# PCA finds a new basis aligned with data variance.
# Show same data expressed in original and PCA basis.
N = 200
FEATURE_NAMES = ["age", "tenure_months", "monthly_spend"] # Generate correlated customer features (standard basis coordinates)
age = np.random.normal(38, 10, N)
tenure_months = 2 * (age - 38) + np.random.normal(24, 8, N)
monthly_spend = 50 * (tenure_months / 12) + np.random.normal(200, 80, N)
X = np.column_stack([age, tenure_months, monthly_spend])
X_centered = X - X.mean(axis=0) # PCA: find new orthonormal basis
pca = PCA(n_components=3)
X_pca = pca.fit_transform(X_centered) # coordinates in new (PCA) basis # Print explained variance
explained = pd.DataFrame({ "PC": [f"PC{i+1}" for i in range(3)], "explained_var_ratio": pca.explained_variance_ratio_.round(4), "basis_vector_norm": [np.linalg.norm(pca.components_[i]).round(6) for i in range(3)],
})
print("PCA basis vectors (rows are new basis vectors):")
print(pd.DataFrame(pca.components_.round(4), columns=FEATURE_NAMES, index=["PC1", "PC2", "PC3"]).to_string())
print(f"\nExplained variance:")
print(explained.to_string(index=False))
print(f"\nFirst customer in original basis: {X[0].round(2)}")
print(f"First customer in PCA basis: {X_pca[0].round(4)}")
print("\nSame geometric object; different coordinates in a different orthonormal basis.")Professional example (R)
# Basis change: same data in original vs PCA basis
set.seed(42)
N <- 200
age <- rnorm(N, 38, 10)
tenure_months <- 2 * (age - 38) + rnorm(N, 24, 8)
monthly_spend <- 50 * (tenure_months / 12) + rnorm(N, 200, 80)
X <- cbind(age, tenure_months, monthly_spend)
X_centered <- scale(X, scale = FALSE)
pca <- prcomp(X_centered, rank. = 3)
X_pca <- pca$x
cat("First customer original basis:", round(X[1,], 2), "\n")
cat("First customer PCA basis:", round(X_pca[1,], 4), "\n")
cat("Same object; different coordinates.\n")Source: 1300 p. 126