Linear Algebra for Machine Learning
- 53Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is a vector, and how does the number of its entries relate to the dimension of its vector space?
53 questions
- 1
What is a vector, and how does the number of its entries relate to the dimension of its vector space?
Model answer
A vector is a one-dimensional array of numbers. A vector with three entries belongs to a three-dimensional vector space.
Explanation
A vector is an ordered one-dimensional array of numbers; the number of entries determines its dimension.
- 2
What is a feature vector? Give one example of what its entries might represent.
Model answer
A feature vector is a vector whose entries represent features of an object or example, such as a patient’s height, weight, and age.
Explanation
A feature vector is a vector whose entries describe features of an object, such as a patient’s height, weight, and age.
- 3
What does the term feature space mean in this context?
Model answer
A feature space is the collection of feature vectors and is often used synonymously with vector space.
Explanation
Feature space refers to the collection of vectors used to represent features, much like vector space refers to the collection of vectors generally.
- 4
Why are vectors useful for representing data for machine learning?
Model answer
Representing information as numerical vectors gives computers a form of data they can readily process.
Explanation
Numerical vectors let computers work with data in a form they can process, including data that was not originally numerical.
- 5
How can pixel values be used to represent black-and-white and grayscale images numerically?
Model answer
A black-and-white image can use values such as 0 and 1 for its pixels, while a grayscale image can use values such as 0 through 255.
Explanation
Pixel values can be represented numerically: binary images use two values, while grayscale images can use values from 0 to 255.
- 6
How can a two-dimensional image matrix be converted into a vector?
Model answer
One can flatten the pixel matrix by stacking its rows in order to form a one-dimensional vector.
Explanation
Flattening a pixel matrix by stacking its rows turns the two-dimensional pixel arrangement into a one-dimensional array.
- 7
How can a word such as “dog” be represented as a vector across a collection of articles?
Model answer
For each article, record the number of times the word appears; the resulting list of counts is a vector.
Explanation
A word’s vector can contain one count for each article, recording how often the word appears in that article.
- 8
How might a user’s movie interactions be represented as a vector?
Model answer
A user’s interactions can be represented by a vector containing watched/not-watched indicators or ratings for each item.
Explanation
Interactions can be encoded as binary watched/not-watched values or as numerical ratings, with entries arranged by item.
- 9
What is a one-hot encoding, and how can it represent words in a vocabulary?
Model answer
A one-hot encoding represents each item with a vector containing one 1 in its assigned position and 0s in all other positions.
Explanation
A one-hot encoding assigns each vocabulary item a vector with a 1 in its designated position and 0s elsewhere.
- 10
What is the mathematical name for the vectors used in one-hot encodings?
Model answer
One-hot vectors are also called standard basis vectors.
Explanation
In mathematics, the vectors with a single 1 and zeros elsewhere are standard basis vectors.
- 11
What happens to the size and nonzero-entry pattern of one-hot vectors when the vocabulary becomes very large?
Model answer
A vocabulary of tens of thousands of words produces very high-dimensional one-hot vectors, each with only one nonzero entry.
Explanation
With a vocabulary of tens of thousands of words, each one-hot vector has that many entries but only one nonzero entry.
- 12
How is the dot product of two same-length vectors calculated, and what kind of result does it produce?
Model answer
For vectors with the same number of entries, multiply corresponding entries and add the products; the result is a scalar.
Explanation
The dot product multiplies corresponding entries and sums those products, producing a number rather than a vector.
- 13
How can the dot product be interpreted as a measure of similarity, and what is its geometric intuition?
Model answer
The dot product can indicate how similar two vectors are; geometrically, it is related to the shadow or projection of one vector in the direction of the other.
Explanation
The dot product is presented as an indicator of similarity; its geometric intuition is related to the length of one vector’s projection in the direction of the other.
- 14
How does the length of the vector receiving the projection affect the relationship between a dot product and shadow length?
Model answer
If the vector in whose direction the shadow is measured has length 1, the dot product equals the shadow length; otherwise, the shadow length is proportional to it.
Explanation
When the vector receiving the projection has length 1, the dot product equals the shadow’s length; otherwise, the shadow length is proportional to the dot product.
- 15
Why can one-hot encodings fail to reflect the semantic similarity between words such as “cat” and “tiger”?
Model answer
Distinct one-hot vectors have a dot product of zero, even when the words they represent are semantically related, such as “cat” and “tiger.”
Explanation
The dot product of distinct one-hot vectors is zero because their 1s occur in different positions, so the product does not reflect semantic relatedness.
- 16
What does it mean for a data representation to be sparse?
Model answer
A representation is sparse when it contains many zero entries; one-hot vectors are a clear example.
Explanation
Sparsity means that a vector or other representation contains many zeros, which is typical of one-hot vectors.
- 17
Why can a user–movie data representation contain many unknown entries?
Model answer
A user–movie representation can be sparse because most users have not watched or rated most movies, leaving many entries unknown.
Explanation
In a large user–movie collection, each user has interacted with only a small portion of the movies, leaving many entries unknown.
- 18
What effect can replacing unknown user ratings with zeros have on a data representation?
Model answer
Unknown ratings may be represented as zeros, which can make the resulting data representation very sparse.
Explanation
The content notes that an application may replace unknown ratings with zeros, creating many zero entries in the representation.
- 19
What gives the entries of a feature vector their meaning?
Model answer
The entries of a feature vector encode information about the object, so their meaning comes from the features they represent.
Explanation
If entries in a vector represent features of an object, they should be interpreted according to those features rather than as numbers with no context.
- 20
What is a vector embedding?
Model answer
An embedding replaces a vector with a lower-dimensional vector intended to preserve useful meaning or structure.
Explanation
An embedding replaces a vector with one that has fewer entries and lies in a lower-dimensional space; it should also be meaningful for the task.
- 21
What problem are vector embeddings intended to address in data representation?
Model answer
Embeddings aim to compress high-dimensional representations into a smaller space while retaining or revealing meaningful relationships.
Explanation
The aim is to reduce the number of dimensions while producing representations that better capture relevant relationships than a naive encoding.
- 22
What is a matrix, and how can it act on a vector?
Model answer
A matrix is a two-dimensional array of numbers that can transform an input vector into an output vector.
Explanation
A matrix is a two-dimensional array, and multiplying it by a vector is one way to represent a transformation of that vector.
- 23
Why should a matrix transformation be understood as acting on a whole vector space rather than just one vector?
Model answer
A matrix represents a transformation of an entire vector space, so it acts according to the same rules on all vectors in that space.
Explanation
A matrix transformation applies shared rules to the entire vector space, not only to the particular vector used to illustrate the transformation.
- 24
What dimension condition must hold for two matrices to be multiplied in order?
Model answer
The number of columns in the first matrix must match the number of rows in the second matrix.
Explanation
For matrix multiplication to be defined, the first matrix’s column count must equal the second matrix’s row count.
- 25
What is the basic idea of matrix factorization?
Model answer
Matrix factorization seeks matrices, often smaller ones, whose product equals or approximates a given matrix.
Explanation
Factorization reverses the direction of multiplication: given a matrix, one seeks smaller matrices whose product gives the original.
- 26
What does the singular value decomposition guarantee about matrices?
Model answer
Although factorization can be difficult in general, every matrix can be expressed using a singular value decomposition.
Explanation
The content contrasts the difficulty of reversing multiplication with the fact that every matrix has a singular value decomposition.
- 27
How many matrices appear in the singular value decomposition of a matrix, and what is the factorization’s general form?
Model answer
The singular value decomposition factors an n-by-m matrix into a product of three special matrices.
Explanation
The singular value decomposition writes an n-by-m matrix as a product of three special matrices.
- 28
What structural properties of the matrices in the singular value decomposition are described in the content?
Model answer
The middle matrix is diagonal, and the other matrices have rows or columns that are orthonormal.
Explanation
The middle SVD matrix is diagonal; the other matrices have rows or columns that are unit vectors and mutually orthogonal.
- 29
What does orthonormality mean for a collection of vectors?
Model answer
Orthonormal vectors each have length 1, and the dot product of any two distinct vectors in the set is zero.
Explanation
Orthonormal vectors have length 1 and have dot product zero with one another.
- 30
Name several fields in which singular value decomposition is used.
Model answer
SVD is used in many fields, including machine learning, statistics, physics, genomics, and robotics.
Explanation
SVD is described as a fundamental linear algebra result with uses in fields such as statistics, physics, genomics, and robotics, as well as machine learning.
- 31
How can matrix factorization provide vector embeddings?
Model answer
Rows or columns of the factor matrices can provide lower-dimensional candidate embeddings for the original vectors.
Explanation
In a matrix factorization, rows or columns of the factor matrices can serve as lower-dimensional candidate vectors corresponding to the original data vectors.
- 32
How is a user-by-movie interaction matrix organized?
Model answer
A user-by-movie matrix has one row per user and one column per movie, with each cell recording whether or how the user interacted with that movie.
Explanation
A user-by-movie matrix places users along rows and movies along columns, with a cell recording their interaction.
- 33
How can watched and unwatched entries in a user–movie matrix be encoded numerically?
Model answer
A check mark can indicate a watched movie and be encoded as 1; an empty cell can be encoded as 0 or, in some applications, a negative number.
Explanation
In the example, a check mark indicates that a user watched a movie; checks can be treated as 1s and empty cells as 0s or, depending on the application, negative values.
- 34
How does the user–movie matrix give naive vector representations for a user and a movie?
Model answer
A user can be represented by the corresponding row of the user–movie matrix, and a movie by the corresponding column.
Explanation
A user’s original vector is a row of the matrix, while a movie’s original vector is a column.
- 35
What are examples of latent features that might underlie user–movie interaction data?
Model answer
Possible latent features include users’ age groups and movies’ audience types or blockbuster-versus-arthouse characteristics.
Explanation
The example identifies possible hidden characteristics such as age group for users and audience type or blockbuster-versus-arthouse character for movies.
- 36
What is a latent space, and why is it useful for representing users and movies?
Model answer
A latent space is a lower-dimensional vector space used to represent hidden features or structure in the data.
Explanation
A latent space is a lower-dimensional space intended to make hidden structure or features in the data visible.
- 37
How might two dimensions in a shared latent space represent user and movie features?
Model answer
A shared two-dimensional space could represent age-related preference along one dimension and blockbuster-versus-arthouse preference along another.
Explanation
A shared two-dimensional latent space can use one axis to reflect age brackets and another to reflect movie type, for example.
- 38
In the user–movie example, what role do the factor matrices play?
Model answer
The factor matrices are chosen so their product approximately reproduces the user–movie matrix; their rows or columns provide the embeddings.
Explanation
The factor matrices are chosen so that their product approximately reconstructs the user–movie matrix, and their rows or columns supply candidate embeddings.
- 39
What can the proximity and dot product of a user embedding and a movie embedding suggest in a recommendation example?
Model answer
Their embeddings are close in the latent space and have a relatively large dot product, suggesting that the user and movie are compatible in the represented features.
Explanation
The example places the embedding for user 3 near the embedding for Shrek; the dot product offers a numerical way to express their similarity, consistent with the user’s presumed interest in the movie.
- 40
How can a neural network generate a vector embedding, and how does its internal structure relate to linear algebra?
Model answer
A neural network can take an original data vector as input and produce a candidate embedding as output; its internal structure involves more than linear algebra.
Explanation
A neural network can map an original representation to a new vector, but its internal operations include components beyond linear algebra.
- 41
What two approaches to generating vector embeddings are described?
Model answer
Matrix factorization and neural networks are two approaches to producing vector embeddings.
Explanation
Both matrix factorization and neural networks are presented as ways to obtain lower-dimensional embeddings.
- 42
Define an eigenvector and its corresponding eigenvalue.
Model answer
An eigenvector of a matrix keeps its direction under the transformation and is scaled by a scalar called its eigenvalue.
Explanation
An eigenvector retains its direction under a matrix transformation and is only scaled; the scalar scaling factor is its eigenvalue.
- 43
What equation expresses the defining relationship between a matrix, an eigenvector, and its eigenvalue?
Model answer
If a matrix transforms a nonzero vector into a scalar multiple of itself, the vector is an eigenvector and that scalar is its eigenvalue.
Explanation
For example, if Mv=2v, then v is an eigenvector of M and 2 is its eigenvalue.
- 44
Beyond their role in describing matrix transformations, why are eigenvectors useful in data science?
Model answer
Eigenvectors can reveal valuable information about the structure or features of data.
Explanation
In data science, eigenvectors can encode useful information about data in addition to describing special directions of a transformation.
- 45
What is the goal of dimensionality reduction when data points lie near a lower-dimensional structure?
Model answer
Dimensionality reduction seeks a smaller-dimensional space that captures the structure along which the data is organized or clustered.
Explanation
Dimensionality reduction seeks a smaller space that captures the organization of the data, such as a line along which points cluster.
- 46
How can a collection of data points be organized into a matrix for dimensionality analysis?
Model answer
Represent each data point as a vector and stack the vectors into a matrix.
Explanation
Organizing each data point as a vector and stacking those vectors creates a matrix representing the data set.
- 47
Which matrix is examined for eigenvectors in the described dimensionality-reduction procedure, and why?
Model answer
One examines eigenvectors of the data matrix multiplied by its transpose, producing a square matrix suitable for eigenvector analysis.
Explanation
The described method examines eigenvectors of the data matrix multiplied by its transpose, rather than directly using eigenvectors of a generally non-square data matrix.
- 48
Why is the data matrix multiplied by its transpose before finding eigenvectors?
Model answer
The data matrix may not be square, while eigenvector analysis requires a square matrix; multiplying it by its transpose produces one.
Explanation
The content notes that eigenvectors are defined for square matrices, motivating the use of the data matrix multiplied by its transpose.
- 49
What statistical preprocessing steps are mentioned for the data matrix in principal component analysis?
Model answer
The data may be centered by subtracting the mean of each row and the resulting matrix may be divided by a constant.
Explanation
The statistical procedure may center the data by subtracting row means and scale the matrix by a constant; these steps are mentioned as additional details.
- 50
How does the eigenvector with the largest eigenvalue help identify the main direction of a data set?
Model answer
The eigenvector with the largest eigenvalue points in the principal direction of the data’s clustering.
Explanation
In the described setting, the eigenvector with the largest eigenvalue points in the direction along which the data is most strongly clustered.
- 51
What are the leading data direction and the associated analysis method called?
Model answer
The leading direction is the principal direction, or principal eigenvector, and the method is called principal component analysis (PCA).
Explanation
That leading direction is called the principal direction or principal eigenvector; the overall method is called principal component analysis.
- 52
What benefits can dimensionality reduction provide when relevant data occupies only part of a larger space?
Model answer
Working in a relevant lower-dimensional space can improve efficiency, save resources, and reveal structure in the data.
Explanation
Reducing dimensions can focus computation and resources on the smaller portion of the space occupied by relevant data, while revealing its structure.
- 53
Why must dimensionality reduction balance compression against information loss?
Model answer
Dimensionality reduction loses some information, so it should preserve as much useful information as possible while compressing the data.
Explanation
Compression necessarily discards some information, so an embedding should reduce dimensionality while avoiding the loss of too much useful information.

Ask anything
We've read this whole study set, so questions about it get the best answers.