0% found this document useful (0 votes)
9 views4 pages

EX NO:06 Simulate Dimensionality Reduction Using Pca On A Dataset Date

The document outlines a procedure to simulate dimensionality reduction using Principal Component Analysis (PCA) on a dataset, specifically the Iris Flower dataset. It includes software requirements, a step-by-step procedure for implementation in MATLAB, and a program code to perform PCA. Additionally, it mentions the importance of standardization and provides a marks allocation scheme for assessment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

EX NO:06 Simulate Dimensionality Reduction Using Pca On A Dataset Date

The document outlines a procedure to simulate dimensionality reduction using Principal Component Analysis (PCA) on a dataset, specifically the Iris Flower dataset. It includes software requirements, a step-by-step procedure for implementation in MATLAB, and a program code to perform PCA. Additionally, it mentions the importance of standardization and provides a marks allocation scheme for assessment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EX NO:06

SIMULATE DIMENSIONALITY REDUCTION USING PCA


DATE:
ON A DATASET

AIM:
To simulate dimensionality reduction using the PCA (Principal Component Analysis)
method on a given dataset

SOFTWARE REQUIRED:

• MATLAB
• Open Source Tools

PROCEDURE:

1. Click on the MATLAB Icon on the desktop.

2. Click on the ‘FILE’ Menu on the menu bar.


3. Click on NEW M-File from the File menu.
4. Save the file in the directory.
5. Click on DEBUG from the Menu bar and click Run.
6. Open the command window\ Figure window for the output

THEORY:

Principal Component Analysis (PCA) is a dimensionality reduction technique


used to transform high-dimensional data into a lower-dimensional space while preserving
maximum variance. It works by computing principal components, which are new orthogonal
axes obtained from the eigenvectors of the covariance matrix. The first principal component
captures the highest variance, followed by subsequent components with decreasing variance.
Standardization of data is crucial to ensure fair weighting of all features. It is widely used in
pattern recognition, image compression, and exploratory data analysis.
PROGRAM:
data = readtable('Iris_Flower_Data.xlsx');
X = table2array(data(:, 1:4)); Y = data.Species;
mu = mean(X); sigma = std(X);
sigma(sigma == 0) = 1;
X = (X - mu) ./ sigma;
covMatrix = cov(X);
[eigVectors, eigValuesMatrix] = eig(covMatrix);
eigValues = diag(eigValuesMatrix);
[~, sortIdx] = sort(eigValues, 'descend');
eigVectors = eigVectors(:, sortIdx);
eigValues = eigValues(sortIdx);
X_reduced = X * eigVectors(:, 1:2);
Y_numeric = zeros(size(Y));
Y_numeric(strcmp(Y, 'setosa')) = 1;
Y_numeric(strcmp(Y, 'versicolor')) = 2;
Y_numeric(strcmp(Y, 'virginica')) = 3;
figure;
colors = {'r', 'g', 'b'};markers = {'o', 's', 'd'};
labels = {'Setosa', 'Versicolor', 'Virginica'};
for i = 1:3
idx = Y_numeric == i;
plot(X_reduced(idx,1), X_reduced(idx,2), markers{i}, ...
'Color', colors{i}, 'DisplayName', labels{i});
end
xlabel('Principal Component 1');
ylabel('Principal Component 2');
title('PCA on Iris Dataset (Manual, No Toolbox)');
legend('Location', 'best');
explained = 100 * eigValues / sum(eigValues);
disp('Variance Explained by Each Principal Component:');
disp(explained);
RESULT:

CORE COMPETENCY:

MARKS ALLOCATION:

Details Marks Marks Awarded


Allotted
BOOPATHI V DHARANESH P
(73772213110) (73772213116)

Preparation 20

Conducting 20

Calculation / Graphs 15

Results 10

Basic understanding (Core 15


competency learned)

Viva 10

Record 10

Total 100
`

Signature of faculty
FLOWCHART:

You might also like