SlideShare a Scribd company logo
A Presentation on PCA & SVD
PRESENTED BY
MSc. student, N. I. MD. ASHAFUDDULA
STUDENT ID: 18204016
Outlines
Feature Reduction
Why Dimension Reduction?
Application of SVD & PCA
Recent Works
Keywords & Terms
PCA
SVD
Implementation of PCA & SVD
Result Comparison (SVD/PCA vs Original Data)
Conclusion
10/20/2020 A PRESENTATION ON PCA & SVD 2
Feature Reduction
10/20/2020 A PRESENTATION ON PCA & SVD 3
 Dimensionality reduction refers to
techniques for reducing the number of input
variables in training data.
[6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
Feature Reduction
When dealing with high dimensional data, it is often useful to reduce the dimensionality by
projecting the data to a lower dimensional subspace which captures the “essence” of the data.
10/20/2020 A PRESENTATION ON PCA & SVD 4
Record F1 F2 F3 F4 F5
1 1 1 1 0 0
2 2 2 2 0 0
3 3 3 3 0 0
4 4 4 4 0 0
5 0 2 0 4 4
6 0 0 0 5 5
7 0 1 0 2 2
Record F1 F2
1 1.72 -0.22
2 5.15 -0.67
3 5.87 -0.89
4 8.58 -1.12
5 1.91 5.62
6 0.90 6.95
7 0.95 2.81
Table: 5D input (Original data) Table: 2D input (Reduced Dim)
Dim. Reduction
(PCA/SVD)
Why Dimension Reduction?
To compress data
To remove redundant features
To use less Computation & Disk space
To Speed up learning algorithm
To Increase system performance
To visualize data
10/20/2020 A PRESENTATION ON PCA & SVD 5
Application of SVD & PCA
Fingerprint Recognition
Recommendation System
Image Classification
Computer vision
Dimension Reduction
Analysis Input variables
And many more.
10/20/2020 A PRESENTATION ON PCA & SVD 6
Recent Works
[1] A Machine Learning Approach to Detect Self-Care Problems of Children with Physical and
Motor Disability. (2018)
[2] Likelihood Prediction of Diabetes at Early Stage Using Data Mining Techniques. (2020)
[3] Improving detection of Melanoma and Naevus with deep neural networks. (2020)
[4] Dimension reduction of image deep feature using PCA. (2019)
[5] Analysis of Dimensionality Reduction Techniques on Big Data. (2020)
[6] Image Classification base on PCA of Multi-view Deep Representation. (2019)
10/20/2020 A PRESENTATION ON PCA & SVD 7
Recent Works (Result Comparison)
Work Original Input
Features
Reduced
Features
Method Without
Feature Reduction
With
Feature Reduction
[1] 205 53 PCA, KNN Acuu: 81.43% Accu: 84.29%
[2] 15 To Analyze PCA, RF - Accu: 97.4%
[3] 2 Dataset - PCA, CNN - Accu: 96.8%
[4] 3727 887 PCA Accu: 88.3% Accu: 91.3%
[5] 36 26 PCA, RF Acuu: 98.59% Acuu: 98.3%
(Performane of Other
Metrices was better)
[6] Multiple Image - PCA,
Proposed
- Accu: 85.33±0.47
10/20/2020 A PRESENTATION ON PCA & SVD 8
Keywords & Terms
Variance
Eigen vector
Eigen values
Orthogonal
Orthonormal
Co-variance
Correlation
10/20/2020 A PRESENTATION ON PCA & SVD 9
Keywords & Terms
Variance:
Variance (σ2) in statistics is a measurement of the spread between numbers in a data set. That
is, it measures how far each number in the set is from the mean and therefore from every other
number in the set.
Formula:
Where: xi = the ith data point
= the mean of all data points
n = the number of data points
10/20/2020 A PRESENTATION ON PCA & SVD 10
Keywords & Terms
Eigenvector & Values:
Eigenvectors and values exist in pairs: every Eigenvector has a
corresponding Eigenvalue.
An Eigenvector is a direction, in the example the Eigenvector is
the direction of the line (vertical, horizontal, 45 degrees etc.) .
An Eigenvalue is a number, telling us how much Variance there
is in the data in that direction.
In the example the Eigenvalue is a number telling us how
spread out the data is on the line.
The Eigenvector with the highest Eigenvalue is therefore the
Principal Component.
10/20/2020 A PRESENTATION ON PCA & SVD 11
[1] https://georgemdallas.wordpress.com/2013/10/30/principal-component-analysis-4-dummies-eigenvectors-eigenvalues-and-dimension-reduction/
Fig. (a)
Fig. (b)
Keywords & Terms
Eigenvector & Values:
If we take Age and Height of students, there are 2
variables, it’s a 2-D data set, therefore there are 2
eigenvectors/values.
Similarly If take Age, height, Class of students there
are 3 variables, 3-D data set, so 3
eigenvectors/values.
The Eigenvectors have to be able to span the whole
x-y area, in order to do this (most effectively), the
two directions need to be orthogonal (i.e. 90
degrees) to one another.
10/20/2020 A PRESENTATION ON PCA & SVD 12
[1] https://georgemdallas.wordpress.com/2013/10/30/principal-component-analysis-4-dummies-eigenvectors-eigenvalues-and-dimension-reduction/
Fig. (c)
Fig. (d)
Fig. (e)
Keywords & Terms
Eigenvector & Values:
The Eigenvectors gives us much more useful axis to
frame the data in. So, We can now re-frame the data
in these new dimensions.
These directions are where there is most variation
found, and that is where there is more information.
Another way we can say, No variation of data
means No information. In this case the Eigenvalue
for that dimension would equal Zero, because there
is no variations.
10/20/2020 A PRESENTATION ON PCA & SVD 13
[1] https://georgemdallas.wordpress.com/2013/10/30/principal-component-analysis-4-dummies-eigenvectors-eigenvalues-and-dimension-reduction/
Fig. (f)
Keywords & Terms
Orthogonal:
Two vectors are Orthogonal if they are perpendicular to each other. (i.e. the dot product of the
two vectors is 0)
In Matrix, A square matrix with real numbers or elements is said to be an orthogonal matrix, if
its transpose is equal to its inverse matrix or
when the product of a square matrix and its transpose gives an identity matrix, then the square
matrix is known as an orthogonal matrix.
if, AT = A-1 is satisfied, then, A AT = I
Orthonormal:
A set of vectors is orthonormal if it is an orthogonal set having the property that every vector is
a unit vector (a vector of magnitude 1).
10/20/2020 A PRESENTATION ON PCA & SVD 14
[2] https://byjus.com/maths/orthogonal-matrix/#:~:text=If%20m%3Dn%2C%20which%20means,3%20rows%20and%203%20columns.
Keywords & Terms
Co-Variance & Correlation:
Both the terms measure the relationship and the dependency between two variables, suppose
(x,y).
“Covariance” indicates the direction of the linear relationship between variables.
“Correlation” on the other hand measures both the strength and direction of the linear
relationship between two variables.
10/20/2020 A PRESENTATION ON PCA & SVD 15
[3] https://towardsdatascience.com/let-us-understand-the-correlation-matrix-and-covariance-matrix-d42e6b643c22
[4] https://www.youtube.com/watch?v=xZ_z8KWkhXE
PCA
PCA stands for Principal Component Analysis.
PCA finds the principal components of data.
PCA finds the directions where there is the most variance, the directions where the data is
most spread out.
10/20/2020 A PRESENTATION ON PCA & SVD 16
Fig(h). PCA-2
[5] https://dataconomy.com/2016/01/understanding-dimensionality-reduction/
Fig(g). PCA-1
PCA (Cont’d)
10/20/2020 A PRESENTATION ON PCA & SVD 17
[6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
Fig(i). PCA (2D to 1D)
 Dimension Reduction tries to find a Line or Plane in which
most of the data lies and project onto that line So that
Every projected data to the line is smallest.
2D to 1D
X1 ∈R2 -> Z1 ∈R1
X1 ∈R2 -> Z1 ∈R1
………………..
Xm ∈R2 -> Zm ∈R1
Zi = =Z1
i
Xi
PCA (Cont’d)
10/20/2020 A PRESENTATION ON PCA & SVD 18
[6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
Fig(j). PCA (3D to 2D)
3D to 2D
X1 ∈R3 -> Z1 ∈R2
X1 ∈R3 -> Z1 ∈R2
………………..
Xm ∈R3 -> Zm ∈R2
Zi = =
Z1
i
Zi
2
Xi
Yi
PCA (Cont’d)
10/20/2020 A PRESENTATION ON PCA & SVD 19
Wrong-Right projection line
The projection of every point on the Magenta
line (Fig) is huge and also greater than the Red
line.
So this is wrong line.
Fig(L). PCA (Wrong-Right projection line)
[6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
Implementation of PCA
Algorithm:
1. Collect dataset
2. Preprocessing data (Feature Scaling/ Mean Normalization)
μj = (1/m)* 𝑖=1
𝑚
𝑥𝑖
𝑗
Replace each xi
j with (xj - μj).
We scale data to have comparable range values. E.g if we have x1 and x2 features of data where,
x1 = Size of house
x2 = no. of bedroom
10/20/2020 A PRESENTATION ON PCA & SVD 20
[6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
Where, j = Dimension no. [1,2,3,…]
m = total no. of point on that dimension
Implementation of PCA (Cont’d)
Algorithm (Reduced N Dim to K Dim):
3. Compute “Co-variance matrix”
Sigma, ∑ = (1/m)* 𝑖=1
𝑛
𝑥𝑖 𝑥𝑖 𝑇 [Here, xi (n*1) matrix]
In code, Sigma, ∑ = (1/m) * XT*X
4. Computer “Eigen Vectors” of matrix Sigma.
[U,S,V] = svd(Sigma) or U = eig(Sigma)
5. U is a (n*n) matrix. Where to reduce in K dim we need to choose K column from U matrix that is
(n*k) matrix.
Ureduce = [:, 1:k]
6. Znew_space = UT
reduce * Xinput_set
10/20/2020 A PRESENTATION ON PCA & SVD 21
[6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
Implementation of PCA (Cont’d)
Algorithm (Choose ‘K’ the no. of Principle Component):
PCA minimizes average projection Error.
Eq 1. Avg. projection Error = (1/m) * 𝑖=1
𝑚
(𝑥 𝑖
−𝑥 𝑖
𝑎𝑝𝑝𝑟𝑜𝑥)2
Eq 2. Total variation in the data = (1/m) * 𝑖=1
𝑚
(𝑥 𝑖)2
Now, we choose K to be smallest value so that,
𝐸𝑞.1
𝐸𝑞.2
≤ 0.01 1%
So, that we can maintain 99% variance or our desired variance.
10/20/2020 A PRESENTATION ON PCA & SVD 22
[6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
Is it Efficient
or not ?
Implementation of PCA (Cont’d)
Algorithm (Choose ‘K’ the no. of Principle Component):
Previous method was not Efficient to choose ‘K’
Compute, [U,S,V] = svd(sigma)
Where, S is a (r*r) diagonal matrix.
Now, for given ‘K’ we need to check if, 𝑖=1
𝑘
𝑆 𝑖𝑖
𝑖=1
𝑛
𝑆 𝑖𝑖 ≥ 0.99 99% 𝑣𝑎𝑟𝑖𝑎𝑛𝑐𝑒 𝑟𝑒𝑡𝑎𝑖𝑛𝑒𝑑
10/20/2020 A PRESENTATION ON PCA & SVD 23
[6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
Implementation of PCA (code)
Input:
Dataset = np.array(
[[1, 1, 1, 0, 0],
[3, 3, 3, 0, 0],
[4, 4, 4, 0, 0],
[5, 5, 5, 0, 0],
[0, 2, 0, 4, 4],
[0, 0, 0, 5, 5],
[0, 1, 0, 2, 2]])
10/20/2020 A PRESENTATION ON PCA & SVD 24
Output: (Reduced Dim.)
[[ 0.06153582 1.4876476 ] [-1.41476273 0.32780438] [-2.152912 -0.25211723] [-2.89106128 -0.83203884] [
2.01452609 -0.69985245] [ 2.9755685 -0.71530184] [ 1.40710559 0.68385838]]
Shape: (7, 2)
SVD
SVD stands for Singular Value Decomposition
SVD is specific way to reduce features
SVD is nothing more than decomposing vectors onto orthogonal axes
10/20/2020 A PRESENTATION ON PCA & SVD 25
Implementation of SVD
10/20/2020 A PRESENTATION ON PCA & SVD 26
Singular Value Decomposition:
Am×n = Um×m ∑m×n VT
n×n
Where, Am×n = input Matrix
Um×m = Orthogonal Matrix
∑m×n = Diagonal Matrix
VT
n×n = Orthogonal Matrix
Fig (M). SVD computation
[7] https://en.wikipedia.org/wiki/Singular_value_decomposition#/media/File:Singular_value_decomposition_visualisation.svg
Implementation of SVD (Cont’d)
10/20/2020 A PRESENTATION ON PCA & SVD 27
Singular Value Decomposition Dimension reduced to ‘k’ Dimension:
Am×n = Um×m ∑m×n VT
n×n
To find reduced dim of A matrix ‘n’ dimension to ‘k’ dimension,
Zreduced = U[:,1:k] * ∑[1:k,1:k]
Implementation of SVD -1
10/20/2020 A PRESENTATION ON PCA & SVD 28
Input:
Dataset = np.array(
[[1, 1, 1, 0, 0],
[3, 3, 3, 0, 0],
[4, 4, 4, 0, 0],
[5, 5, 5, 0, 0],
[0, 2, 0, 4, 4],
[0, 0, 0, 5, 5],
[0, 1, 0, 2, 2]])
Output: (Reduced Dim.)
Short Hand SVD (7*2):
[[-1.71737671 -0.22451218]
[-5.15213013 -0.67353654]
[-6.86950685 -0.89804872]
[-8.58688356 -1.12256089]
[-1.9067881 5.62055093] [-
0.90133537 6.9537622 ] [-
0.95339405 2.81027546]]
Implementation of SVD-2
10/20/2020 A PRESENTATION ON PCA & SVD 29
Input:
Dataset = np.array(
[[1, 1, 1, 0, 0],
[3, 3, 3, 0, 0],
[4, 4, 4, 0, 0],
[5, 5, 5, 0, 0],
[0, 2, 0, 4, 4],
[0, 0, 0, 5, 5],
[0, 1, 0, 2, 2]])
Output: (Reduced Dim.)
[[ 1.71737671 -0.22451218] [ 5.15213013 -0.67353654] [ 6.86950685 -0.89804872] [ 8.58688356 -1.12256089] [
1.9067881 5.62055093] [ 0.90133537 6.9537622 ] [ 0.95339405 2.81027546]]
Shape: (7, 2)
Result Comparison (SVD/PCA vs Original Data)
KNN SVM DT ELM SGD CNN
Original 72.86 62.86 72.86 64.29 58.57 71.43
With PCA 87.14 84.29 75.71 72.86 77.14 100
SVD 72.86 62.86 81.43 65.71 61.43 100
72.86
62.86
72.86
64.29
58.57
71.43
87.14 84.29
75.71 72.86 77.14
100
72.86
62.86
81.43
65.71 61.43
100
0
20
40
60
80
100
120
ACCURACY
ML & DNN ALGORITHM
ML & CNN Algorithm Results comparison
Original With PCA SVD
10/20/2020 A PRESENTATION ON PCA & SVD 30
Disadvantages of Dimensionality Reduction
It may lead to some amount of data loss.
PCA tends to find linear correlations between variables, which is sometimes undesirable.
PCA fails in cases where mean and covariance are not enough to define datasets.
We may not know how many principal components to keep- in practice, some thumb rules
are applied.
10/20/2020 A PRESENTATION ON PCA & SVD 31
10/20/2020 A PRESENTATION ON PCA & SVD 32
THE END

More Related Content

PPTX
Dimensionality Reduction in Machine Learning
ODP
Dimensionality Reduction
PPTX
Dimensionality Reduction | Machine Learning | CloudxLab
PPTX
Dimension reduction techniques[Feature Selection]
PPTX
Dimension Reduction Introduction & PCA.pptx
PPTX
Lect5 principal component analysis
PPTX
Dimensionality Reduction and feature extraction.pptx
PPTX
Dimensionality Reduction in Machine Learning
Dimensionality Reduction
Dimensionality Reduction | Machine Learning | CloudxLab
Dimension reduction techniques[Feature Selection]
Dimension Reduction Introduction & PCA.pptx
Lect5 principal component analysis
Dimensionality Reduction and feature extraction.pptx

What's hot (20)

PPTX
Dimensionality reduction: SVD and its applications
PPTX
PPT
Image compression using singular value decomposition
PDF
4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...
PDF
Principal Component Analysis
PPSX
PDF
5. Linear Algebra for Machine Learning: Singular Value Decomposition and Prin...
PDF
PCA (Principal component analysis)
PDF
Singular Value Decompostion (SVD)
PPTX
Activation function
PPT
SVD sath.ppt
PDF
Lecture 6-computer vision features descriptors matching
PPT
Fuzzy Set Theory
PPTX
Convolutional Neural Networks
PPTX
PDF
3. Linear Algebra for Machine Learning: Factorization and Linear Transformations
PDF
L7 fuzzy relations
PPTX
Fuzzy Set
PPTX
Activation function
PPT
Bayseian decision theory
Dimensionality reduction: SVD and its applications
Image compression using singular value decomposition
4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...
Principal Component Analysis
5. Linear Algebra for Machine Learning: Singular Value Decomposition and Prin...
PCA (Principal component analysis)
Singular Value Decompostion (SVD)
Activation function
SVD sath.ppt
Lecture 6-computer vision features descriptors matching
Fuzzy Set Theory
Convolutional Neural Networks
3. Linear Algebra for Machine Learning: Factorization and Linear Transformations
L7 fuzzy relations
Fuzzy Set
Activation function
Bayseian decision theory
Ad

Similar to PCA and SVD in brief (20)

PPTX
ML-Lec-18-NEW Dimensionality Reduction-PCA (1).pptx
PPTX
pcappt-140121072949-phpapp01.pptx
PDF
5 DimensionalityReduction.pdf
PPTX
PCA Final.pptx
PDF
overviewPCA
PDF
pca.pdf polymer nanoparticles and sensors
PPTX
DimensionalityReduction.pptx
PPTX
Feature selection using PCA.pptx
PDF
Mathematical Introduction to Principal Components Analysis
PDF
Covariance.pdf
PPTX
EDAB - Principal Components Analysis and Classification -Module - 5.pptx
PDF
PPTX
Principal Component Analysis PCA
PPTX
PCA_csep546.pptx
PPTX
principle component analysis pca - machine learning - unsupervised learning
PPTX
PCA_csep546.pptx
PDF
Introduction to pca v2
PDF
Pca ppt
PPT
Lecture1 dosen mengabdi untuk negeri _jps.ppt
ML-Lec-18-NEW Dimensionality Reduction-PCA (1).pptx
pcappt-140121072949-phpapp01.pptx
5 DimensionalityReduction.pdf
PCA Final.pptx
overviewPCA
pca.pdf polymer nanoparticles and sensors
DimensionalityReduction.pptx
Feature selection using PCA.pptx
Mathematical Introduction to Principal Components Analysis
Covariance.pdf
EDAB - Principal Components Analysis and Classification -Module - 5.pptx
Principal Component Analysis PCA
PCA_csep546.pptx
principle component analysis pca - machine learning - unsupervised learning
PCA_csep546.pptx
Introduction to pca v2
Pca ppt
Lecture1 dosen mengabdi untuk negeri _jps.ppt
Ad

Recently uploaded (20)

PDF
composite construction of structures.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Geodesy 1.pptx...............................................
DOCX
573137875-Attendance-Management-System-original
PPTX
web development for engineering and engineering
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Current and future trends in Computer Vision.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
OOP with Java - Java Introduction (Basics)
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
composite construction of structures.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Geodesy 1.pptx...............................................
573137875-Attendance-Management-System-original
web development for engineering and engineering
Safety Seminar civil to be ensured for safe working.
Internet of Things (IOT) - A guide to understanding
Current and future trends in Computer Vision.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
OOP with Java - Java Introduction (Basics)
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
bas. eng. economics group 4 presentation 1.pptx
CH1 Production IntroductoryConcepts.pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT

PCA and SVD in brief

  • 1. A Presentation on PCA & SVD PRESENTED BY MSc. student, N. I. MD. ASHAFUDDULA STUDENT ID: 18204016
  • 2. Outlines Feature Reduction Why Dimension Reduction? Application of SVD & PCA Recent Works Keywords & Terms PCA SVD Implementation of PCA & SVD Result Comparison (SVD/PCA vs Original Data) Conclusion 10/20/2020 A PRESENTATION ON PCA & SVD 2
  • 3. Feature Reduction 10/20/2020 A PRESENTATION ON PCA & SVD 3  Dimensionality reduction refers to techniques for reducing the number of input variables in training data. [6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
  • 4. Feature Reduction When dealing with high dimensional data, it is often useful to reduce the dimensionality by projecting the data to a lower dimensional subspace which captures the “essence” of the data. 10/20/2020 A PRESENTATION ON PCA & SVD 4 Record F1 F2 F3 F4 F5 1 1 1 1 0 0 2 2 2 2 0 0 3 3 3 3 0 0 4 4 4 4 0 0 5 0 2 0 4 4 6 0 0 0 5 5 7 0 1 0 2 2 Record F1 F2 1 1.72 -0.22 2 5.15 -0.67 3 5.87 -0.89 4 8.58 -1.12 5 1.91 5.62 6 0.90 6.95 7 0.95 2.81 Table: 5D input (Original data) Table: 2D input (Reduced Dim) Dim. Reduction (PCA/SVD)
  • 5. Why Dimension Reduction? To compress data To remove redundant features To use less Computation & Disk space To Speed up learning algorithm To Increase system performance To visualize data 10/20/2020 A PRESENTATION ON PCA & SVD 5
  • 6. Application of SVD & PCA Fingerprint Recognition Recommendation System Image Classification Computer vision Dimension Reduction Analysis Input variables And many more. 10/20/2020 A PRESENTATION ON PCA & SVD 6
  • 7. Recent Works [1] A Machine Learning Approach to Detect Self-Care Problems of Children with Physical and Motor Disability. (2018) [2] Likelihood Prediction of Diabetes at Early Stage Using Data Mining Techniques. (2020) [3] Improving detection of Melanoma and Naevus with deep neural networks. (2020) [4] Dimension reduction of image deep feature using PCA. (2019) [5] Analysis of Dimensionality Reduction Techniques on Big Data. (2020) [6] Image Classification base on PCA of Multi-view Deep Representation. (2019) 10/20/2020 A PRESENTATION ON PCA & SVD 7
  • 8. Recent Works (Result Comparison) Work Original Input Features Reduced Features Method Without Feature Reduction With Feature Reduction [1] 205 53 PCA, KNN Acuu: 81.43% Accu: 84.29% [2] 15 To Analyze PCA, RF - Accu: 97.4% [3] 2 Dataset - PCA, CNN - Accu: 96.8% [4] 3727 887 PCA Accu: 88.3% Accu: 91.3% [5] 36 26 PCA, RF Acuu: 98.59% Acuu: 98.3% (Performane of Other Metrices was better) [6] Multiple Image - PCA, Proposed - Accu: 85.33±0.47 10/20/2020 A PRESENTATION ON PCA & SVD 8
  • 9. Keywords & Terms Variance Eigen vector Eigen values Orthogonal Orthonormal Co-variance Correlation 10/20/2020 A PRESENTATION ON PCA & SVD 9
  • 10. Keywords & Terms Variance: Variance (σ2) in statistics is a measurement of the spread between numbers in a data set. That is, it measures how far each number in the set is from the mean and therefore from every other number in the set. Formula: Where: xi = the ith data point = the mean of all data points n = the number of data points 10/20/2020 A PRESENTATION ON PCA & SVD 10
  • 11. Keywords & Terms Eigenvector & Values: Eigenvectors and values exist in pairs: every Eigenvector has a corresponding Eigenvalue. An Eigenvector is a direction, in the example the Eigenvector is the direction of the line (vertical, horizontal, 45 degrees etc.) . An Eigenvalue is a number, telling us how much Variance there is in the data in that direction. In the example the Eigenvalue is a number telling us how spread out the data is on the line. The Eigenvector with the highest Eigenvalue is therefore the Principal Component. 10/20/2020 A PRESENTATION ON PCA & SVD 11 [1] https://georgemdallas.wordpress.com/2013/10/30/principal-component-analysis-4-dummies-eigenvectors-eigenvalues-and-dimension-reduction/ Fig. (a) Fig. (b)
  • 12. Keywords & Terms Eigenvector & Values: If we take Age and Height of students, there are 2 variables, it’s a 2-D data set, therefore there are 2 eigenvectors/values. Similarly If take Age, height, Class of students there are 3 variables, 3-D data set, so 3 eigenvectors/values. The Eigenvectors have to be able to span the whole x-y area, in order to do this (most effectively), the two directions need to be orthogonal (i.e. 90 degrees) to one another. 10/20/2020 A PRESENTATION ON PCA & SVD 12 [1] https://georgemdallas.wordpress.com/2013/10/30/principal-component-analysis-4-dummies-eigenvectors-eigenvalues-and-dimension-reduction/ Fig. (c) Fig. (d) Fig. (e)
  • 13. Keywords & Terms Eigenvector & Values: The Eigenvectors gives us much more useful axis to frame the data in. So, We can now re-frame the data in these new dimensions. These directions are where there is most variation found, and that is where there is more information. Another way we can say, No variation of data means No information. In this case the Eigenvalue for that dimension would equal Zero, because there is no variations. 10/20/2020 A PRESENTATION ON PCA & SVD 13 [1] https://georgemdallas.wordpress.com/2013/10/30/principal-component-analysis-4-dummies-eigenvectors-eigenvalues-and-dimension-reduction/ Fig. (f)
  • 14. Keywords & Terms Orthogonal: Two vectors are Orthogonal if they are perpendicular to each other. (i.e. the dot product of the two vectors is 0) In Matrix, A square matrix with real numbers or elements is said to be an orthogonal matrix, if its transpose is equal to its inverse matrix or when the product of a square matrix and its transpose gives an identity matrix, then the square matrix is known as an orthogonal matrix. if, AT = A-1 is satisfied, then, A AT = I Orthonormal: A set of vectors is orthonormal if it is an orthogonal set having the property that every vector is a unit vector (a vector of magnitude 1). 10/20/2020 A PRESENTATION ON PCA & SVD 14 [2] https://byjus.com/maths/orthogonal-matrix/#:~:text=If%20m%3Dn%2C%20which%20means,3%20rows%20and%203%20columns.
  • 15. Keywords & Terms Co-Variance & Correlation: Both the terms measure the relationship and the dependency between two variables, suppose (x,y). “Covariance” indicates the direction of the linear relationship between variables. “Correlation” on the other hand measures both the strength and direction of the linear relationship between two variables. 10/20/2020 A PRESENTATION ON PCA & SVD 15 [3] https://towardsdatascience.com/let-us-understand-the-correlation-matrix-and-covariance-matrix-d42e6b643c22 [4] https://www.youtube.com/watch?v=xZ_z8KWkhXE
  • 16. PCA PCA stands for Principal Component Analysis. PCA finds the principal components of data. PCA finds the directions where there is the most variance, the directions where the data is most spread out. 10/20/2020 A PRESENTATION ON PCA & SVD 16 Fig(h). PCA-2 [5] https://dataconomy.com/2016/01/understanding-dimensionality-reduction/ Fig(g). PCA-1
  • 17. PCA (Cont’d) 10/20/2020 A PRESENTATION ON PCA & SVD 17 [6] Coursera Machine Learning (PCA & Feature| Dimension Reduction) Fig(i). PCA (2D to 1D)  Dimension Reduction tries to find a Line or Plane in which most of the data lies and project onto that line So that Every projected data to the line is smallest. 2D to 1D X1 ∈R2 -> Z1 ∈R1 X1 ∈R2 -> Z1 ∈R1 ……………….. Xm ∈R2 -> Zm ∈R1 Zi = =Z1 i Xi
  • 18. PCA (Cont’d) 10/20/2020 A PRESENTATION ON PCA & SVD 18 [6] Coursera Machine Learning (PCA & Feature| Dimension Reduction) Fig(j). PCA (3D to 2D) 3D to 2D X1 ∈R3 -> Z1 ∈R2 X1 ∈R3 -> Z1 ∈R2 ……………….. Xm ∈R3 -> Zm ∈R2 Zi = = Z1 i Zi 2 Xi Yi
  • 19. PCA (Cont’d) 10/20/2020 A PRESENTATION ON PCA & SVD 19 Wrong-Right projection line The projection of every point on the Magenta line (Fig) is huge and also greater than the Red line. So this is wrong line. Fig(L). PCA (Wrong-Right projection line) [6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
  • 20. Implementation of PCA Algorithm: 1. Collect dataset 2. Preprocessing data (Feature Scaling/ Mean Normalization) μj = (1/m)* 𝑖=1 𝑚 𝑥𝑖 𝑗 Replace each xi j with (xj - μj). We scale data to have comparable range values. E.g if we have x1 and x2 features of data where, x1 = Size of house x2 = no. of bedroom 10/20/2020 A PRESENTATION ON PCA & SVD 20 [6] Coursera Machine Learning (PCA & Feature| Dimension Reduction) Where, j = Dimension no. [1,2,3,…] m = total no. of point on that dimension
  • 21. Implementation of PCA (Cont’d) Algorithm (Reduced N Dim to K Dim): 3. Compute “Co-variance matrix” Sigma, ∑ = (1/m)* 𝑖=1 𝑛 𝑥𝑖 𝑥𝑖 𝑇 [Here, xi (n*1) matrix] In code, Sigma, ∑ = (1/m) * XT*X 4. Computer “Eigen Vectors” of matrix Sigma. [U,S,V] = svd(Sigma) or U = eig(Sigma) 5. U is a (n*n) matrix. Where to reduce in K dim we need to choose K column from U matrix that is (n*k) matrix. Ureduce = [:, 1:k] 6. Znew_space = UT reduce * Xinput_set 10/20/2020 A PRESENTATION ON PCA & SVD 21 [6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
  • 22. Implementation of PCA (Cont’d) Algorithm (Choose ‘K’ the no. of Principle Component): PCA minimizes average projection Error. Eq 1. Avg. projection Error = (1/m) * 𝑖=1 𝑚 (𝑥 𝑖 −𝑥 𝑖 𝑎𝑝𝑝𝑟𝑜𝑥)2 Eq 2. Total variation in the data = (1/m) * 𝑖=1 𝑚 (𝑥 𝑖)2 Now, we choose K to be smallest value so that, 𝐸𝑞.1 𝐸𝑞.2 ≤ 0.01 1% So, that we can maintain 99% variance or our desired variance. 10/20/2020 A PRESENTATION ON PCA & SVD 22 [6] Coursera Machine Learning (PCA & Feature| Dimension Reduction) Is it Efficient or not ?
  • 23. Implementation of PCA (Cont’d) Algorithm (Choose ‘K’ the no. of Principle Component): Previous method was not Efficient to choose ‘K’ Compute, [U,S,V] = svd(sigma) Where, S is a (r*r) diagonal matrix. Now, for given ‘K’ we need to check if, 𝑖=1 𝑘 𝑆 𝑖𝑖 𝑖=1 𝑛 𝑆 𝑖𝑖 ≥ 0.99 99% 𝑣𝑎𝑟𝑖𝑎𝑛𝑐𝑒 𝑟𝑒𝑡𝑎𝑖𝑛𝑒𝑑 10/20/2020 A PRESENTATION ON PCA & SVD 23 [6] Coursera Machine Learning (PCA & Feature| Dimension Reduction)
  • 24. Implementation of PCA (code) Input: Dataset = np.array( [[1, 1, 1, 0, 0], [3, 3, 3, 0, 0], [4, 4, 4, 0, 0], [5, 5, 5, 0, 0], [0, 2, 0, 4, 4], [0, 0, 0, 5, 5], [0, 1, 0, 2, 2]]) 10/20/2020 A PRESENTATION ON PCA & SVD 24 Output: (Reduced Dim.) [[ 0.06153582 1.4876476 ] [-1.41476273 0.32780438] [-2.152912 -0.25211723] [-2.89106128 -0.83203884] [ 2.01452609 -0.69985245] [ 2.9755685 -0.71530184] [ 1.40710559 0.68385838]] Shape: (7, 2)
  • 25. SVD SVD stands for Singular Value Decomposition SVD is specific way to reduce features SVD is nothing more than decomposing vectors onto orthogonal axes 10/20/2020 A PRESENTATION ON PCA & SVD 25
  • 26. Implementation of SVD 10/20/2020 A PRESENTATION ON PCA & SVD 26 Singular Value Decomposition: Am×n = Um×m ∑m×n VT n×n Where, Am×n = input Matrix Um×m = Orthogonal Matrix ∑m×n = Diagonal Matrix VT n×n = Orthogonal Matrix Fig (M). SVD computation [7] https://en.wikipedia.org/wiki/Singular_value_decomposition#/media/File:Singular_value_decomposition_visualisation.svg
  • 27. Implementation of SVD (Cont’d) 10/20/2020 A PRESENTATION ON PCA & SVD 27 Singular Value Decomposition Dimension reduced to ‘k’ Dimension: Am×n = Um×m ∑m×n VT n×n To find reduced dim of A matrix ‘n’ dimension to ‘k’ dimension, Zreduced = U[:,1:k] * ∑[1:k,1:k]
  • 28. Implementation of SVD -1 10/20/2020 A PRESENTATION ON PCA & SVD 28 Input: Dataset = np.array( [[1, 1, 1, 0, 0], [3, 3, 3, 0, 0], [4, 4, 4, 0, 0], [5, 5, 5, 0, 0], [0, 2, 0, 4, 4], [0, 0, 0, 5, 5], [0, 1, 0, 2, 2]]) Output: (Reduced Dim.) Short Hand SVD (7*2): [[-1.71737671 -0.22451218] [-5.15213013 -0.67353654] [-6.86950685 -0.89804872] [-8.58688356 -1.12256089] [-1.9067881 5.62055093] [- 0.90133537 6.9537622 ] [- 0.95339405 2.81027546]]
  • 29. Implementation of SVD-2 10/20/2020 A PRESENTATION ON PCA & SVD 29 Input: Dataset = np.array( [[1, 1, 1, 0, 0], [3, 3, 3, 0, 0], [4, 4, 4, 0, 0], [5, 5, 5, 0, 0], [0, 2, 0, 4, 4], [0, 0, 0, 5, 5], [0, 1, 0, 2, 2]]) Output: (Reduced Dim.) [[ 1.71737671 -0.22451218] [ 5.15213013 -0.67353654] [ 6.86950685 -0.89804872] [ 8.58688356 -1.12256089] [ 1.9067881 5.62055093] [ 0.90133537 6.9537622 ] [ 0.95339405 2.81027546]] Shape: (7, 2)
  • 30. Result Comparison (SVD/PCA vs Original Data) KNN SVM DT ELM SGD CNN Original 72.86 62.86 72.86 64.29 58.57 71.43 With PCA 87.14 84.29 75.71 72.86 77.14 100 SVD 72.86 62.86 81.43 65.71 61.43 100 72.86 62.86 72.86 64.29 58.57 71.43 87.14 84.29 75.71 72.86 77.14 100 72.86 62.86 81.43 65.71 61.43 100 0 20 40 60 80 100 120 ACCURACY ML & DNN ALGORITHM ML & CNN Algorithm Results comparison Original With PCA SVD 10/20/2020 A PRESENTATION ON PCA & SVD 30
  • 31. Disadvantages of Dimensionality Reduction It may lead to some amount of data loss. PCA tends to find linear correlations between variables, which is sometimes undesirable. PCA fails in cases where mean and covariance are not enough to define datasets. We may not know how many principal components to keep- in practice, some thumb rules are applied. 10/20/2020 A PRESENTATION ON PCA & SVD 31
  • 32. 10/20/2020 A PRESENTATION ON PCA & SVD 32 THE END