11 - Principal Component Analysis and Autoencoders
Class: CSCE-421
Notes:
We will use linear algebra only!
Matrix times Vector - 2 Ways
/CSCE-421/Ex2/Visual%20Aids/image-43.png)
At first, you learn (Mv1). But when you get used to viewing it as (Mv2), you can understand
Notes:
- If you need to know anything about linear algebra, this is the most important thing to know, matrix and vector multiplication!
The Art of Linear Algebra - Vector times matrix - 2 Ways
/CSCE-421/Ex2/Visual%20Aids/image-44.png)
A row vector
/CSCE-421/Ex2/Visual%20Aids/image-45.png)
The product
Notes:
- Vector matrix multiplication is the linear combination of the rows
Matrix times Matrix - 4 ways
/CSCE-421/Ex2/Visual%20Aids/image-46.png)
Notes:
- MM1 is a natural way, but turns out it is not the most used
- It is typycal row by column approach
- The most important view is MM4
- You take a column vector and multiply it by a column vector, what do you get? a matrix
- You do this for every column and every row and then add the matrices together (they will be of the same size)
- This is kind of like an outer product.
- What can you learn from this approach?
- You take the first column on matrix A, then you take the first row B, you multiply them together to get a matrix
- The only thing that matters is the cross balance
- This doesn't tell you that if you permute the columns, the matrix will be the same
- But if you permute both the columns and row, then your matrices will be the same
- What about MM2?
- You take each column and multiply it with a matrix, a linear combination of columns with the matrix (Matrix - vector multiplication).
- MM3 is just the row way of doing MM2?
Practical Patterns
/CSCE-421/Ex2/Visual%20Aids/image-47.png)
Burn this into your memories and you can see ...
Notes:
- P1: Linear combination of the columns on A.
- P2: Is the same thing but the diagonal matrix is on the left.
- Note this one is not a linear combination, you are just multiplying the numbers from the diagonal matrix * the rows in matrix B
/CSCE-421/Ex2/Visual%20Aids/image-48.png)
Notes:
- How to interpret P4?
- We can do step by step
- First we use P1' (columns * diagonal) And then you multiply that column matrix to the row matrix
- In practice what is the result? How do I interpret this?
- You still look at the matrix from P1' as a column matrix but with each column multiplied with a number, then we need to multiply each column with each row of the row matrix.
- We can do step by step
- Why are we talking about this?
- Later on, what we will do is to have a matrix, but we will decompose this matrix into products of matrices, with the one on the center being a diagonal matrix.
- The reason why we view linear algebra this way, is that if you docompose in this way, you can view this decomposition as an outer product (P4)
- The size of this matrix is the same size as the original matrix, but each column are linearly dependent so the rank of this matrix is 1.
- Is a sequence of rank 1 matrices summed together.
- The size of this matrix is the same size as the original matrix, but each column are linearly dependent so the rank of this matrix is 1.
- There is something that is easy but most people do not know.
- In most of these decomposition, they require the diagonal elements to be in non-increasing order?, why is this a requirement?
- Because the order of the matrices does not matter, you can always rearrange in sorted order.
- If the diagonal terms are not in sorted order, you can always rearrange the terms of the sum of matrices at the end
- Other thing is that the result is nonnegative?
- Because if they are negative, you can just flip the sign of the outside.
- You can always split the sign by multiplying a column or a row times a -1
- You either leave the sign in the column or in the row, but not in both
- We always assume that the diagonal terms are always non-negative and in sorted order?
Orthogonal Matrices
(1) An orthogonal matrix is a square matrix whose columns and rows are orthogonal unit vectors, i.e., orthonormal vectors. That is, if a matrix
(2) It leads to
(3) For an orthogonal
(4) Furthermore, suppose
Notes:
- Certain matrices are called orthogonal matrices, these matrices are square matrices (equal number of rows and columns)
- If you have a square matrix, it is orthogonal if all columns are orthogonal to each other
- If you take any different columns and you compute the inner product, the inner product is 0.
- Each column needs to be normalized with each row?
- Each column is normalized to have a unit ... then the rows will automatically satisfy the orthogonal requirement
- The requirement is intuitively translated into
- Remember Identity matrix (I) is all elements 0 except by the diagonal elements which are 1.
: are rows, and are columns, its product tells you the columns are normalized : tells you the rows are normalized
- If a matrix is orthogonal the inverse is simply the transpose of that matrix!
- There is something else that is important to talk about:
- If I have an orthogonal matrix
(view it as columns) - it has to be a square matrix - Somehow we will split this into 2 matrices:
, of course and are no longer squared matrices - They are not orthogonal matrices anymore, but they are vey important
- In general when we talk about
, it is a matrix with orthonormal columns. - All the columns are orthonormal to each other and each column is also normalized
- In this case we would have:
- Rows are no longer orthogonal and normalized!
- Rows are no longer orthogonal and normalized!
- If I have an orthogonal matrix
Notes:
- We know that:
- How do I write this in terms of
and ? - You multiply the first part together, and then you multiply the second part together and sum them
- There is an interesting property here (FYIO):
- These two matrices added together equals the Identity matrix
- For these two matrices the sum of the diagonal elements of these matrices is also the Identity matrix
- What would be the rank of these two matrices?
- Is there an upper bound? Yes, the upper-bound is 1.
- The diagonal elements are nonnegative, each of them have to be smaller or equal to 1.
- Note this is not required for this class.
- These two matrices added together equals the Identity matrix
Eigen-Decomposition
(1) A square
where
(2) Note that only diagonalizable matrices can be factorized in this way.
(3) If
Notes:
- Definition of eigenvalues & eigenvectoes?
- Matrix has to be a squared matrix
- If you have squared matrix
(n * n) - The eigen values and eigen vectors are:
- note eigen values and eigen vectors are paired to each other.
- We just want it to be a matrix = a matrix
- We want to have a matrix
so that each of its columns can be paired as eigenvectors: - Then we have another matrix, which is a diagonal matrix:
& \lambda_2 & \
& & \lambda_3
\end{array}\right]$$- If you want to multiply each number times the columns, the diagonal matrix has to be on the right and the column matrix on the left:
- If you want to multiply each number times the columns, the diagonal matrix has to be on the right and the column matrix on the left:
- Note that when doing
, we are multiplying the first column of the matrix S times , and so on. - we can represent this a
- We then can say:
- We are just equaling each column to each other on - we can represent this a
- You can assume
is non-singular. and therefore you are able to do: - This happens since
? - If all columns are orthogonal to each other, they are not linear independent
- (orthogonal means they have 90 degree angle), this is a stronger condition
- This happens since
- S is a symmetric matrix, and in that case
will be an orthogonal matrix (non-singular). Where the inverse becomes the transpose.
Question:
- Look at:$$
\boldsymbol{S}=\boldsymbol{Q} \boldsymbol{\Lambda} \boldsymbol{Q}^T .- Then we know the matrix i the middle is a diagonal matrix with eigenvalues
- Since
is symmetric, we can be sure that all the eigenvalues are real numbers (but they still can be + or -) - The dilemma is that:
- somehow in this decomposition, we can somehow manage to make them positive?
- No, because then we will affect transpose
- Why can't you make these to be non-negative?
- Because
and will be the same value, so multiplying them will become the square
- Because
- You are kind of flipping two times
- Therefore you cannot make the eigenvalues (the diagonal elements of the middle matrix) to always be positive.
- Note this is different in singular value decomposition, where
and are different matrices.
- Note this is different in singular value decomposition, where
- somehow in this decomposition, we can somehow manage to make them positive?