Linear Algebra Primer Concepts
Linear Algebra Primer Concepts
AI
The number of vectors you get is equal to the number of training data instances
Linear algebra in data science/AI/ML
Vectors do not just represent data. They also help represent our model. Many types
of Machine Learning models represent their learning as vectors. All types of neural
networks do this. Given some data, it will learn dense representations of that data.
These representations are essentially categories kin to recognize new given data.
Data
Weight Vector
New Vector
Basis Vectors and Linear Combinations
y Let 𝑥𝑥� = 10 and 𝑦𝑦� = 01
𝑣𝑣 (1) = (𝑥𝑥1 , 𝑦𝑦1 ) be a unit vector (of magnitude
𝑣𝑣 (3) = (−2,2) 1) aligned with the x and y axis
x
Terminology Alert #1: Such unit
vectors aligned with the axes i.e. 𝑥𝑥�
𝑣𝑣 (2) = (𝑥𝑥2 , 𝑦𝑦2 ) and 𝑦𝑦� are called “BASIS VECTORS”
Question: Now 𝑣𝑣 (1) can be represented in terms of 𝑥𝑥� and 𝑦𝑦� How?
Physical meaning: 𝑣𝑣 (1) is composed of 𝑥𝑥1 parts of feature 𝑥𝑥� and 𝑦𝑦1 parts of
feature 𝑦𝑦�
Two alternatives to visualize multiple training data instances (the training set)
(i) Points in the feature space (the axes)
(ii) A list of vectors
Basis Vectors “Choice” could be arbitrary
Instead of unit vectors aligned with the axes,
Terminology alert !
Conclusion: In 𝑅𝑅2 𝑥𝑥� = 10 and 𝑦𝑦� = 01 are called “standard
Basis vectors are a matter of basis” (which are also orthonormal i.e.,
choice. One can take liberties perpendicular to each other)
according to the nature of the
problem 𝑣𝑣� and 𝑤𝑤
� are orthonormal wrt to each other but
Not wrt to the standard basis
Understanding the Span
• Definition:
set of all linear combinations (nothing but points or vectors)
that you can potentially reach given a set of vectors
• Meaning:
Given any set of vectors (say two), what is the set of points can
you reach in this coordinate system? In 𝑅𝑅2 if no constraints are given,
the two standard basis vectors will produce a span equivalent to a 2D
plane sheet which is infinite. In reality though, often there are
constraints.
Illustration of Span
• You're given a list of vectors, and told you can only play with these vectors.
• See all possibilities you can make with them. The set of all things you can make is the
span of those given vectors.
• That the span is a subspace (subset) is nice reduces search space for one
• it's always good to have objects that are closed under certain operations, and
subspaces are just that: closed under vector addition and scalar multiplication.
• This isn't true for most generic sets of vectors, but definitely true for the span of a set
of vectors. So spans have nice properties.
Special case when given vectors line up
Terminology Alert !
All such vectors 𝑣𝑣� are called linearly dependent
on the previous two vectors 𝑥𝑥� and 𝑦𝑦�
Terminology Alert !
All such vectors 𝑣𝑣� are called linearly independent of the
previous two vectors 𝑥𝑥� and 𝑦𝑦�
If a vector is not the span and it expands the span of the previous two
vectors (adds a dimension), this kind of third vector is called as linearly
independent w.r.t the previous two vectors (because I cannot ignore
this third vector)
Linear Transformations
• x (linear transformation) y
• Meaning
2. the grid lines of the vector space are parallel and evenly
spaced across either side of the transformation
Matrices
• First column of the matrix M where the first basis vector will land
after transformation
• Second column of the matrix M where the second basis vector will
land after transformation
• Interpretation1
• Matrices can be transformation of basis vectors
Matrices
• Apart from interpreting matrices as linear transformations there is
another very important aspect
Det A = 0 if the transformation squishes the vectors onto a line or a point (in 2D) or a region with no volume
𝑥𝑥 = 𝐴𝐴−1 𝑣𝑣
−1
𝐴𝐴 𝐴𝐴 = 𝐼𝐼
Suppose you know the output 𝑣𝑣� in a system and know how the system
behaves specified by A. However, there are some uncertainties. Playing
transformation in reverse with 𝐴𝐴−1 and 𝑣𝑣� , one can get an approximate
idea of the values of the features next time
Rank of a matrix
• Solutions are harder to exist when the transformation squishes points onto
a lower dimension
• Set of vectors that land on the origin (zero vectors) Null space
𝐴𝐴𝐴𝐴 = 𝑣𝑣 ⇒ 𝐴𝐴𝐴𝐴 = 0
When v happens to be a 0 vector 00 , the null space gives you all
possible solutions of the equation.
Dot products
Dot product of two vectors (𝑣𝑣. � =
� 𝑤𝑤)
If V is on left of W (counter-
clock rotation)
area is negative
𝑎𝑎1 𝑐𝑐1
𝐷𝐷𝑦𝑦 𝑎𝑎2 𝑐𝑐2
y= = 𝑎𝑎1 𝑏𝑏1 ,D≠0
𝐷𝐷
𝑎𝑎2 𝑏𝑏2
Change of Basis
• A vector sitting in a 2D space can be
described with coordinates. We can think
each of the numbers as a scalar that
stretches or squishes vectors.
Mike’s Our
coordinate coordinate
Eigenvector and Eigenvalue
• Let A be a square matrix. Then a
nonzero vector 𝑣𝑣⃗ is an
eigenvector of A if there exists a
scalar 𝜆𝜆 such that
A 𝑣𝑣⃗ = 𝜆𝜆 𝑣𝑣⃗
Check out Linear algebra materials by Prof. Zico Kolter for mathematical formulaes and proofs
https://www.cs.cmu.edu/~zkolter/course/15-884/linalg-review.pdf