2
Most read
3
Most read
4
Most read
Ashoka bairwa
Page 1
CENTRAL UNIVERSITY OF HARYANA
Department of Computer Science & Engineering under SOET
MACHINE LEARNING LAB
Submitted by
Ashoka
Roll No:- 191890
Submitted to
Dr. Sangeeta
Assistant Professor
Central University of Haryana (SOET)
Ashoka bairwa
Page 2
PRACTICAL-1
Aim: Introduction about Principal Component Analysis (PCA) feature extraction.
Theory:
Principal Component Analysis, or PCA for short, is a method for reducing the dimensionality of
data.
It can be thought of as a projection method where data with m-columns (features) is projected into a
subspace with m or fewer columns, whilst retaining the essence of the original data.
The PCA method can be described and implemented using the tools of linear algebra.
Implementation:
PCA is an operation applied to a dataset, represented by an n x m matrix A that results in a projection
of A which we will call B. Let’s walk through the steps of this operation.
The first step is to calculate the mean values of each column.
Or
Next, we need to center the values in each column by subtracting the mean column value.
The next step is to calculate the covariance matrix of the centered matrix C.
Correlation is a normalized measure of the amount and direction (positive or negative) that two columns
change together. Covariance is a generalized and unnormalized version of correlation across multiple
columns. A covariance matrix is a calculation of covariance of a given matrix with covariance scores for
every column with every other column, including itself.
Ashoka bairwa
Page 3
Finally, we calculate the eigen decomposition of the covariance matrix V. This results in a list of eigenvalues
and a list of eigenvectors.
The eigenvectors represent the directions or components for the reduced subspace of B, whereas the
eigenvalues represent the magnitudes for the directions. For more on this topic, see the post:
Gentle Introduction to Eigen decomposition, Eigenvalues, and Eigenvectors for Machine Learning
The eigenvectors can be sorted by the eigenvalues in descending order to provide a ranking of the
components or axes of the new subspace for A.
If all eigenvalues have a similar value, then we know that the existing representation may already be
reasonably compressed or dense and that the projection may offer little. If there are eigenvalues close to
zero, they represent components or axes of B that may be discarded.
A total of m or less components must be selected to comprise the chosen subspace. Ideally, we would select
k eigenvectors, called principal components, that have the k largest eigenvalues.
Other matrix decomposition methods can be used such as Singular-Value Decomposition, or SVD. As such,
generally the values are referred to as singular values and the vectors of the subspace are referred to as
principal components.
Once chosen, data can be projected into the subspace via matrix multiplication.
Where A is the original data that we wish to project, B^T is the transpose of the chosen principal
components and P is the projection of A.
This is called the covariance method for calculating the PCA, although there are alternative ways to to
calculate it.
Ashoka bairwa
Page 4
Manually Calculate Principal Component Analysis
Ashoka bairwa
Page 5
Reusable Principal Component Analysis
➢ We can calculate a Principal Component Analysis on a dataset using the PCA() class in the
scikit-learn library. The benefit of this approach is that once the projection is calculated, it can
be applied to new data again and again quite easily.
➢ When creating the class, the number of components can be specified as a parameter.
➢ The class is first fit on a dataset by calling the fit() function, and then the original dataset or
other data can be projected into a subspace with the chosen number of dimensions by calling the
transform() function.
➢ Once fit, the eigenvalues and principal components can be accessed on the PCA class via the
explained_variance_ and components_ attributes.

More Related Content

PPTX
Principal Component Analysis in Machine learning.pptx
PDF
Mathematical Introduction to Principal Components Analysis
PPTX
Feature selection using PCA.pptx
PPTX
11 Principal Component Analysis Computer Graphics.pptx
PDF
Principal component analysis for dimesion reductions for finer data analysis
PDF
Pca ppt
PPTX
Dimensionality Reduction and feature extraction.pptx
PDF
Principal Components Analysis, Calculation and Visualization
Principal Component Analysis in Machine learning.pptx
Mathematical Introduction to Principal Components Analysis
Feature selection using PCA.pptx
11 Principal Component Analysis Computer Graphics.pptx
Principal component analysis for dimesion reductions for finer data analysis
Pca ppt
Dimensionality Reduction and feature extraction.pptx
Principal Components Analysis, Calculation and Visualization

Similar to Practical --1.pdf (20)

PDF
pca.pdf polymer nanoparticles and sensors
PPTX
Principal Component Analysis PCA
PPTX
Principal Component Analysis (PCA).pptx
PDF
Covariance.pdf
PPTX
Implement principal component analysis (PCA) in python from scratch
PPT
Lecture 12 Principal Component Analysis in Machine Learning.ppt
PPT
pca in machine learning pca in machine learning pca in machine learning pca i...
PPT
Principal Component Analysis (PCA):How to conduct PCA
DOCX
Principal Component Analysis
PPTX
PCA and SVD in brief
PPTX
pcappt-140121072949-phpapp01.pptx
PPTX
principle component analysis.pptx
PPT
PPT
The following ppt is about principal component analysis
PPTX
EDAB - Principal Components Analysis and Classification -Module - 5.pptx
PPTX
ML-Lec-18-NEW Dimensionality Reduction-PCA (1).pptx
PPTX
PPTX
Principal component analysis.pptx
PPTX
Principal component analysis.pptx
pca.pdf polymer nanoparticles and sensors
Principal Component Analysis PCA
Principal Component Analysis (PCA).pptx
Covariance.pdf
Implement principal component analysis (PCA) in python from scratch
Lecture 12 Principal Component Analysis in Machine Learning.ppt
pca in machine learning pca in machine learning pca in machine learning pca i...
Principal Component Analysis (PCA):How to conduct PCA
Principal Component Analysis
PCA and SVD in brief
pcappt-140121072949-phpapp01.pptx
principle component analysis.pptx
The following ppt is about principal component analysis
EDAB - Principal Components Analysis and Classification -Module - 5.pptx
ML-Lec-18-NEW Dimensionality Reduction-PCA (1).pptx
Principal component analysis.pptx
Principal component analysis.pptx
Ad

More from Central university of Haryana (20)

PDF
Practical --2..pdf
PDF
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
PDF
LittleBookOfRuby.pdf
PDF
all matlab_prog.pdf
DOCX
DOCX
Practical 111.docx
PDF
Matlab Practical--11.pdf
DOCX
Matlab Practical--11.docx
DOCX
Matlab Practical--9.docx
PDF
Matlab Practical-- 12.pdf
PDF
Matlab practical ---9.pdf
PDF
Matlab practical ---7.pdf
PDF
Matlab practical ---6.pdf
PDF
Matlab practical ---5.pdf
PDF
Matlab practical ---4.pdf
PDF
Matlab practical ---3.pdf
PDF
Matlab practical ---2.pdf
PDF
Matlab practical ---1.pdf
PDF
Matlab practical --8.pdf
Practical --2..pdf
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
LittleBookOfRuby.pdf
all matlab_prog.pdf
Practical 111.docx
Matlab Practical--11.pdf
Matlab Practical--11.docx
Matlab Practical--9.docx
Matlab Practical-- 12.pdf
Matlab practical ---9.pdf
Matlab practical ---7.pdf
Matlab practical ---6.pdf
Matlab practical ---5.pdf
Matlab practical ---4.pdf
Matlab practical ---3.pdf
Matlab practical ---2.pdf
Matlab practical ---1.pdf
Matlab practical --8.pdf
Ad

Recently uploaded (20)

PDF
Race Reva University – Shaping Future Leaders in Artificial Intelligence
PDF
Journal of Dental Science - UDMY (2021).pdf
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
semiconductor packaging in vlsi design fab
PDF
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
PDF
advance database management system book.pdf
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
Empowerment Technology for Senior High School Guide
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
PDF
International_Financial_Reporting_Standa.pdf
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PPTX
Introduction to pro and eukaryotes and differences.pptx
PPTX
Module on health assessment of CHN. pptx
Race Reva University – Shaping Future Leaders in Artificial Intelligence
Journal of Dental Science - UDMY (2021).pdf
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
semiconductor packaging in vlsi design fab
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
advance database management system book.pdf
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
Paper A Mock Exam 9_ Attempt review.pdf.
Empowerment Technology for Senior High School Guide
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
International_Financial_Reporting_Standa.pdf
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Environmental Education MCQ BD2EE - Share Source.pdf
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
Introduction to pro and eukaryotes and differences.pptx
Module on health assessment of CHN. pptx

Practical --1.pdf

  • 1. Ashoka bairwa Page 1 CENTRAL UNIVERSITY OF HARYANA Department of Computer Science & Engineering under SOET MACHINE LEARNING LAB Submitted by Ashoka Roll No:- 191890 Submitted to Dr. Sangeeta Assistant Professor Central University of Haryana (SOET)
  • 2. Ashoka bairwa Page 2 PRACTICAL-1 Aim: Introduction about Principal Component Analysis (PCA) feature extraction. Theory: Principal Component Analysis, or PCA for short, is a method for reducing the dimensionality of data. It can be thought of as a projection method where data with m-columns (features) is projected into a subspace with m or fewer columns, whilst retaining the essence of the original data. The PCA method can be described and implemented using the tools of linear algebra. Implementation: PCA is an operation applied to a dataset, represented by an n x m matrix A that results in a projection of A which we will call B. Let’s walk through the steps of this operation. The first step is to calculate the mean values of each column. Or Next, we need to center the values in each column by subtracting the mean column value. The next step is to calculate the covariance matrix of the centered matrix C. Correlation is a normalized measure of the amount and direction (positive or negative) that two columns change together. Covariance is a generalized and unnormalized version of correlation across multiple columns. A covariance matrix is a calculation of covariance of a given matrix with covariance scores for every column with every other column, including itself.
  • 3. Ashoka bairwa Page 3 Finally, we calculate the eigen decomposition of the covariance matrix V. This results in a list of eigenvalues and a list of eigenvectors. The eigenvectors represent the directions or components for the reduced subspace of B, whereas the eigenvalues represent the magnitudes for the directions. For more on this topic, see the post: Gentle Introduction to Eigen decomposition, Eigenvalues, and Eigenvectors for Machine Learning The eigenvectors can be sorted by the eigenvalues in descending order to provide a ranking of the components or axes of the new subspace for A. If all eigenvalues have a similar value, then we know that the existing representation may already be reasonably compressed or dense and that the projection may offer little. If there are eigenvalues close to zero, they represent components or axes of B that may be discarded. A total of m or less components must be selected to comprise the chosen subspace. Ideally, we would select k eigenvectors, called principal components, that have the k largest eigenvalues. Other matrix decomposition methods can be used such as Singular-Value Decomposition, or SVD. As such, generally the values are referred to as singular values and the vectors of the subspace are referred to as principal components. Once chosen, data can be projected into the subspace via matrix multiplication. Where A is the original data that we wish to project, B^T is the transpose of the chosen principal components and P is the projection of A. This is called the covariance method for calculating the PCA, although there are alternative ways to to calculate it.
  • 4. Ashoka bairwa Page 4 Manually Calculate Principal Component Analysis
  • 5. Ashoka bairwa Page 5 Reusable Principal Component Analysis ➢ We can calculate a Principal Component Analysis on a dataset using the PCA() class in the scikit-learn library. The benefit of this approach is that once the projection is calculated, it can be applied to new data again and again quite easily. ➢ When creating the class, the number of components can be specified as a parameter. ➢ The class is first fit on a dataset by calling the fit() function, and then the original dataset or other data can be projected into a subspace with the chosen number of dimensions by calling the transform() function. ➢ Once fit, the eigenvalues and principal components can be accessed on the PCA class via the explained_variance_ and components_ attributes.