liveBook · Manning

Chapter 4: Linear algebraic tools in machine learning

What you will learn in chapter 4 of Math and Architectures of Deep Learning

This chapter introduction frames high-dimensional data as structured matrices whose feature-vector rows occupy nonuniform regions of feature space, motivating the linear-algebra tools studied next.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduction frames high-dimensional data as structured matrices whose feature-vector rows occupy nonuniform regions of feature space, motivating the linear-algebra tools studied next.

Key terms: data matrix, feature vectors, input instances, feature space, dimensions, high-dimensional data, class, subregion, matrix structures, linear algebraic tools

4.1 Distribution of feature data points and true dimensionality

This section shows how high-dimensional feature data can often be represented more compactly by exploiting correlated features and projecting points onto the lower-dimensional subspace where they cluster.

Key terms: document descriptor vector, document space, vocabulary, sparse representation, word frequency, correlated dimensions, document feature vectors, document descriptor space, 45-degree line, gun-violence topic

4.2 Quadratic forms and their minimization

This section introduces quadratic forms as symmetric matrix expressions that represent hyperspheres and hyperellipsoids in any number of dimensions and arise in Taylor expansions and PCA.

Key terms: quadratic form, square symmetric matrix, xᵀAx, hypersphere, ellipse, hyperellipsoid, position vector, center vector, diagonal matrix, off-diagonal terms

4.2.1 Minimizing quadratic forms

This section shows that a symmetric quadratic form over unit-vector directions is maximized and minimized by eigenvectors associated with its largest and smallest eigenvalues.

Key terms: quadratic form, unit vector, unit length, direction, Q=x̂ᵀAx̂, diagonalization, symmetric matrix, orthogonal matrix, eigenvectors, eigenvalues

4.2.2 Symmetric positive (semi)definite matrices

This subsection defines symmetric positive semidefinite and positive definite matrices through their quadratic forms and eigenvalues.

Key terms: symmetric positive semidefinite matrix, symmetric positive definite matrix, quadratic form, eigenvalues

4.3 Spectral and Frobenius norms of a matrix

This section introduces matrix norms as matrix-level counterparts to a vector's magnitude and previews the spectral and Frobenius norms.

Key terms: vector norm, matrix norm, spectral norm, Frobenius norm

4.3.1 Spectral norms

This subsection defines a matrix’s spectral norm as its greatest amplification of a unit vector and relates it to the eigenvalues of AᵀA and singular values.

Key terms: spectral norm, unit vector, amplifier, L2 norm, quadratic form, AᵀA, largest eigenvalue, largest singular value

4.3.2 Frobenius norms

This subsection defines the Frobenius norm as a matrix-magnitude measure based on its entries and relates it to singular values.

Key terms: Frobenius norm, root mean square, singular values, eigenvalues of AᵀA

4.4 Principal component analysis

This section builds the mean-and-covariance description of how one-dimensional and multidimensional data points are distributed, preparing the notion of spread needed for PCA.

Key terms: mean, variance, spread, standard deviation, mean vector, multidimensional data point, coordinate axes, X0, X1, covariance matrix

4.4.1 Direction of maximum spread

This subsection derives PCA’s principal axes by showing that data variance along a unit direction is maximized by covariance-matrix eigenvectors with the largest eigenvalues.

Key terms: unit vector l̂, dot product, covariance matrix C, quadratic form, l̂ᵀCl̂, variance, maximum variance, largest eigenvalue, eigenvector, covariance matrix

4.4.2 PCA and dimensionality reduction

This section explains how PCA reduces data dimensionality by projecting data clustered near a lower-dimensional line or plane onto the principal axes with the largest principal values.

Key terms: principal component, principal axis, principal value, dimensionality reduction, projection, lower-dimensional subspace, spread, orthogonal, normal, perturbations

4.4.3 PyTorch code: PCA and dimensionality reduction

This subsection provides PyTorch PCA examples for correlated and uncorrelated datasets and plots their results.

Key terms: PCA, PyTorch, correlated dataset, uncorrelated dataset, dimensionality reduction

4.4.4 Limitations of PCA

This subsection explains that linear PCA fails to represent nonlinear data patterns accurately because its principal axes are straight lines.

Key terms: linear PCA, non-linearly correlated data, first principal axis, projection, loss of information

4.4.5 PCA and data compression

This section explains how PCA compresses multidimensional data by retaining projections onto only the leading principal axes and discarding low-variance components.

Key terms: PCA, data compression, principal axes, projections, principal components, principal values, smaller principal values, JPEG 98, image compression

4.5 Singular value decomposition

This section introduces the SVD theorem, which decomposes any matrix into orthogonal eigenvector matrices and a diagonal matrix of ordered singular values.

Key terms: singular value decomposition, SVD, SVD theorem, singular matrix, nonsingular matrix, U, Σ, Sigma, V, orthogonal matrix

4.5.1 Informal proof of the SVD theorem

This subsection informally builds the singular-value decomposition result by relating the symmetric positive-semidefinite matrices AᵀA and AAᵀ and constructing corresponding orthonormal singular vectors.

Key terms: AᵀA, symmetric positive semidefinite, singular values, singular vectors, orthogonal eigenvectors, unit vectors, AAᵀ, left singular vector, right singular vector, singular value

4.5.2 Proof of the SVD theorem

This subsection proves the singular value decomposition by constructing the orthogonal matrices and diagonal singular-value matrix, first for matrices with at least as many rows as columns and then analogously for the reverse case.

Key terms: singular value decomposition, AᵀA, AAᵀ, eigenvectors, eigenvalues, singular values, zero entries, Σ, extra eigenvectors, UΣ

4.5.3 Applying SVD: PCA computation

This subsection shows that SVD can compute PCA by forming the covariance matrix from a mean-subtracted, row-oriented data matrix and extracting its eigenstructure.

Key terms: data matrix, mean-subtracted, X^T X, covariance matrix, singular value decomposition, SVD, principal component analysis, PCA, eigenvalues, eigenvectors

4.5.4 Applying SVD: Solving arbitrary linear systems

This section shows how singular value decomposition solves square, overdetermined, and underdetermined linear systems more robustly than directly inverting the coefficient matrix.

Key terms: matrix inversion, determinant, numerically unstable, overdetermined system, underdetermined system, linear combination, singular value decomposition, SVD, U, Σ

4.5.5 Rank of a matrix

This section defines matrix rank through independent rows or columns and relates rank to degeneracy, singular values, invertibility, and solving linear systems.

Key terms: rank, linearly independent rows, linearly independent columns, singular values, degenerate, linearly dependent, zero determinant, noninvertible, full rank, rectangular matrix

4.5.6 PyTorch code for solving linear systems with SVD

This subsection points to PyTorch listings that implement SVD to solve invertible and overdetermined linear systems.

Key terms: singular value decomposition, SVD, linear system, overdetermined linear system, pseudo-inverse, PyTorch

4.5.7 PyTorch code for PCA computation via SVD

4.5.8 Applying SVD: Best low-rank approximation of a matrix

This section explains why and how truncating an SVD produces the best lower-rank approximation of a matrix under Frobenius-norm error.

Key terms: data matrix, lower-rank matrix, small variances, noise, nonlinear pattern, Frobenius norm, approximation error, rank-r approximation, e = ||A − Ar||F, singular value decomposition

4.6 Machine learning application: Document retrieval

This section frames document retrieval as matching a query to a small document collection using a bag-of-words representation.

Key terms: document retrieval, query phrase, documents, bag of words model, matching approach, word appears, document, toy example, conceptual simplicity

4.6.1 Using TF-IDF and cosine similarity

This section explains document retrieval by representing documents as sparse TF-IDF word vectors and comparing them with cosine similarity.

Key terms: term frequency, TF, term, word, inverse document frequency, IDF, down-weight, common terms, document feature vector, vocabulary

4.6.2 Latent semantic analysis

This section explains how latent semantic analysis uses PCA/SVD-derived topics to compare documents through indirect term relationships rather than only shared words.

Key terms: cosine similarity, document vectors, direct overlap, latent semantic similarities, term co-occurrence, topic, document feature space, linear subspace, principal components, high variance

4.6.3 PyTorch code to perform LSA

This subsection points to a PyTorch listing that computes latent semantic analysis (LSA) for the chapter's toy document dataset.

Key terms: latent semantic analysis, LSA, PyTorch, toy dataset

4.6.4 PyTorch code to compute LSA and SVD on a large dataset

This subsection demonstrates PyTorch SVD-based LSA on a large synthetic document-term dataset and interprets its principal components and singular values.

Key terms: document vector, data matrix X, vocabulary, x0, x1, x2, singular values, principal components, SVD, dimensionality

4.7 Summary

This summary recaps how quadratic forms, PCA, SVD, and document-vector methods reveal important structure in machine-learning data.

Where this is used later

Concepts explained in this chapter

← Chapter 3: Classifiers and vector calculus Chapter 5: Probability distributions in machine learning →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.