-
Notifications
You must be signed in to change notification settings - Fork 1
/
12. PCA.html
509 lines (438 loc) · 24.9 KB
/
12. PCA.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Principal Component Analysis — Data Science Notes</title>
<link href="_static/css/theme.css" rel="stylesheet">
<link href="_static/css/index.ff1ffe594081f20da1ef19478df9384b.css" rel="stylesheet">
<link rel="stylesheet"
href="_static/vendor/fontawesome/5.13.0/css/all.min.css">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-book-theme.css?digest=c3fdc42140077d1ad13ad2f1588a4309" />
<link rel="stylesheet" type="text/css" href="_static/togglebutton.css" />
<link rel="stylesheet" type="text/css" href="_static/copybutton.css" />
<link rel="stylesheet" type="text/css" href="_static/mystnb.css" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-thebe.css" />
<link rel="stylesheet" type="text/css" href="_static/panels-main.c949a650a448cc0ae9fd3441c0e17fb0.css" />
<link rel="stylesheet" type="text/css" href="_static/panels-variables.06eb56fa6e07937060861dad626602ad.css" />
<link rel="preload" as="script" href="_static/js/index.be7d3bbb2ef33a8344ce.js">
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/togglebutton.js"></script>
<script src="_static/clipboard.min.js"></script>
<script src="_static/copybutton.js"></script>
<script>var togglebuttonSelector = '.toggle, .admonition.dropdown, .tag_hide_input div.cell_input, .tag_hide-input div.cell_input, .tag_hide_output div.cell_output, .tag_hide-output div.cell_output, .tag_hide_cell.cell, .tag_hide-cell.cell';</script>
<script src="_static/sphinx-book-theme.12a9622fbb08dcb3a2a40b2c02b83a57.js"></script>
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script>window.MathJax = {"options": {"processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script>
<script async="async" src="https://unpkg.com/[email protected]/lib/index.js"></script>
<script>
const thebe_selector = ".thebe"
const thebe_selector_input = "pre"
const thebe_selector_output = ".output"
</script>
<script async="async" src="_static/sphinx-thebe.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Acknowledgement" href="About%20the%20Authors.html" />
<link rel="prev" title="Imbalanced Dataset" href="11.%20Imbalanced%20Dataset.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="None">
<!-- Google Analytics -->
</head>
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="80">
<div class="container-fluid" id="banner"></div>
<div class="container-xl">
<div class="row">
<div class="col-12 col-md-3 bd-sidebar site-navigation show" id="site-navigation">
<div class="navbar-brand-box">
<a class="navbar-brand text-wrap" href="index.html">
<!-- `logo` is deprecated in Sphinx 4.0, so remove this when we stop supporting 3 -->
<img src="_static/logo.svg" class="logo" alt="logo">
<h1 class="site-logo" id="site-title">Data Science Notes</h1>
</a>
</div><form class="bd-search d-flex align-items-center" action="search.html" method="get">
<i class="icon fas fa-search"></i>
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search this book..." aria-label="Search this book..." autocomplete="off" >
</form><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
<div class="bd-toc-item active">
<ul class="nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="intro.html">
Introduction
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
Machine Learning
</span>
</p>
<ul class="current nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="1.1%20Introduction%20to%20Numpy.html">
Numpy
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="1.2%20Introduction%20to%20Matplotlib.html">
Matplotlib: Visualization with Python
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="1.3%20Introduction%20to%20Pandas.html">
Pandas
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="2.%20KNN.html">
K - Nearest Neighbour
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="3.1%20Linear%20Regression.html">
Linear Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="3.2%20Multi-Variate%20Regression.html">
Multi Variable Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="3.3%20MLE%20-%20Linear%20Regression.html">
MLE - Linear Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="3.4%20GLM%20-%20Linear%20Regression.html">
Generalised linear model-Linear Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="4.%20Gradient%20Descent.html">
Gradient Descent
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="5.1%20%20Logistic%20Regression.html">
Logistic Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="5.2%20Maximum%20Likelihood%20Estimation%20and%20Implementation.html">
Logistic Regression MLE & Implementation
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="6.%20Decision%20Trees.html">
Decision Tree Algorithm
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="7.%20Ensemble.html">
Ensemble Learning
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="9.1%20Naive%20Bayes.html">
Naive Bayes Algorithm
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="9.2%20Multinomial%20Naive%20Bayes.html">
Multinomial Naive Bayes
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="11.%20Imbalanced%20Dataset.html">
Imbalanced Dataset
</a>
</li>
<li class="toctree-l1 current active">
<a class="current reference internal" href="#">
Principal Component Analysis
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
About
</span>
</p>
<ul class="nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="About%20the%20Authors.html">
Acknowledgement
</a>
</li>
</ul>
</div>
</nav> <!-- To handle the deprecated key -->
<div class="navbar_extra_footer">
Powered by <a href="https://jupyterbook.org">Jupyter Book</a>
</div>
</div>
<main class="col py-md-3 pl-md-4 bd-content overflow-auto" role="main">
<div class="topbar container-xl fixed-top">
<div class="topbar-contents row">
<div class="col-12 col-md-3 bd-topbar-whitespace site-navigation show"></div>
<div class="col pl-md-4 topbar-main">
<button id="navbar-toggler" class="navbar-toggler ml-0" type="button" data-toggle="collapse"
data-toggle="tooltip" data-placement="bottom" data-target=".site-navigation" aria-controls="navbar-menu"
aria-expanded="true" aria-label="Toggle navigation" aria-controls="site-navigation"
title="Toggle navigation" data-toggle="tooltip" data-placement="left">
<i class="fas fa-bars"></i>
<i class="fas fa-arrow-left"></i>
<i class="fas fa-arrow-up"></i>
</button>
<div class="dropdown-buttons-trigger">
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn" aria-label="Download this page"><i
class="fas fa-download"></i></button>
<div class="dropdown-buttons">
<!-- ipynb file if we had a myst markdown file -->
<!-- Download raw file -->
<a class="dropdown-buttons" href="_sources/12. PCA.ipynb"><button type="button"
class="btn btn-secondary topbarbtn" title="Download source file" data-toggle="tooltip"
data-placement="left">.ipynb</button></a>
<!-- Download PDF via print -->
<button type="button" id="download-print" class="btn btn-secondary topbarbtn" title="Print to PDF"
onClick="window.print()" data-toggle="tooltip" data-placement="left">.pdf</button>
</div>
</div>
<!-- Source interaction buttons -->
<!-- Full screen (wrap in <a> to have style consistency -->
<a class="full-screen-button"><button type="button" class="btn btn-secondary topbarbtn" data-toggle="tooltip"
data-placement="bottom" onclick="toggleFullScreen()" aria-label="Fullscreen mode"
title="Fullscreen mode"><i
class="fas fa-expand"></i></button></a>
<!-- Launch buttons -->
<div class="dropdown-buttons-trigger">
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn"
aria-label="Launch interactive content"><i class="fas fa-rocket"></i></button>
<div class="dropdown-buttons">
<a class="binder-button" href="https://mybinder.org/v2/gh/executablebooks/jupyter-book/master?urlpath=tree/12. PCA.ipynb"><button type="button"
class="btn btn-secondary topbarbtn" title="Launch Binder" data-toggle="tooltip"
data-placement="left"><img class="binder-button-logo"
src="_static/images/logo_binder.svg"
alt="Interact on binder">Binder</button></a>
</div>
</div>
</div>
<!-- Table of contents -->
<div class="d-none d-md-block col-md-2 bd-toc show">
<div class="tocsection onthispage pt-5 pb-3">
<i class="fas fa-list"></i> Contents
</div>
<nav id="bd-toc-nav" aria-label="Page">
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#introduction">
Introduction
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#finding-the-dimensions">
Finding The Dimensions
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#conclusion">
Conclusion
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#further-readings">
Further Readings
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div id="main-content" class="row">
<div class="col-12 col-md-9 pl-md-3 pr-md-0">
<div>
<section class="tex2jax_ignore mathjax_ignore" id="principal-component-analysis">
<h1>Principal Component Analysis<a class="headerlink" href="#principal-component-analysis" title="Permalink to this headline">¶</a></h1>
<p>Up until now we studied many algorithms and techniques in all these data is the most important aspect, but in some cases a data with lot’s of feature can be harmful for our model and decrease it’s peformance as our model will be learning and evaluating a lot of feature that does not give any kind of <a class="reference external" href="http://information.To">information.To</a> treat such cases we use <strong>Dimensionality Reduction</strong> methods.PCA(Principal Component Analysis) is one of the techniques to do so.</p>
<section id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>(PCA) is one of the oldest and most widely used. Its idea is simple—reduce the dimensionality of a dataset, while preserving as much ‘variability’ (i.e. statistical information) as possible.This means that <strong>‘preserving as much variability as possible’</strong> translates into finding new variables that are linear functions of those in the original dataset, that successively maximize variance and that are uncorrelated with each other.</p>
<p><img alt="image.png" src="_images/pca1.png" /></p>
<p>More variablity translates to the more information thus in we are reducing the dimension by creating new ones that has maximum information possible from the real dataset.We take the projection of the all the point onto our new dimension the take those values for making our model.</p>
</section>
<section id="finding-the-dimensions">
<h2>Finding The Dimensions<a class="headerlink" href="#finding-the-dimensions" title="Permalink to this headline">¶</a></h2>
<p>In this we will find the dimension of maximum variance in a dataset so the number of dimensions gets reduced and it can be used making the model.<br />
Let us assume a random unit vector say vector <span class="math notranslate nohighlight">\(\vec{V}\)</span> assuming it as our vector of maximum <a class="reference external" href="http://variance.As">variance.As</a>, we have said that <span class="math notranslate nohighlight">\(\vec{v}\)</span> is a unit vector,</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\therefore V^{T}V=1\)</span></p>
</div></blockquote>
<p>To find the projection of Data Vector say <span class="math notranslate nohighlight">\(\vec{X_i}\)</span> on <span class="math notranslate nohighlight">\(\vec{V}\)</span> we will take the dot product of them.</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\vec{X_i}.\vec{V}\)</span></p>
</div></blockquote>
<p>Which is equal to-</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(|\vec{X_i}|.|\vec{V}|.cos(\theta)\)</span></p>
</div></blockquote>
<blockquote>
<div><p>Where,</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(|\vec{X_i}|\)</span> is the magnitude of <span class="math notranslate nohighlight">\(X_i\)</span></p>
</div></blockquote>
</div></blockquote>
<blockquote>
<div><blockquote>
<div><p><span class="math notranslate nohighlight">\(|\vec{V}|\)</span> is the magnitude of <span class="math notranslate nohighlight">\(V\)</span> and,</p>
</div></blockquote>
</div></blockquote>
<blockquote>
<div><blockquote>
<div><p><span class="math notranslate nohighlight">\(\theta\)</span> is the angle between them.</p>
</div></blockquote>
</div></blockquote>
<p>For Now we are only need the direction of <span class="math notranslate nohighlight">\(\vec{V}\)</span> thus, dividing above equation by magnitude of <span class="math notranslate nohighlight">\(\vec{V}\)</span>-</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\large{\dfrac{\vec{X_i}.\vec{V}}{|\vec{V}|}=|\vec{X_i}|.cos(\theta)}\)</span></p>
</div></blockquote>
<p>Now,As We know that we have to maximise the variance of the data along the direction of our component.Assuming there are n such data points-></p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\sigma^2=\dfrac{1}{n-1}\times\sum_{i=0}^n(X_i-\bar{X})^2\)</span></p>
</div></blockquote>
<p>Here <span class="math notranslate nohighlight">\(\bar{X}\)</span> is the mean of all the data points.</p>
<p>We know that with pre-processing of the data we can bring the mean of the data to 0 it will help us in the <a class="reference external" href="http://calculations.So">calculations.So</a>, Assuming <span class="math notranslate nohighlight">\(\bar{X}=0\)</span>.</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\therefore \sigma^2=\frac{1}{n-1}\times\sum_{i=0}^n X_i^2\)</span></p>
</div></blockquote>
<p>As we all know X_i is a data point containing value of many features in it in a vector form thus <span class="math notranslate nohighlight">\(X_i^2\)</span> acn be written as <span class="math notranslate nohighlight">\(X_i^TX_i\)</span> Therefore new equation will be-</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\therefore \sigma^2=\frac{1}{n-1}\times\sum_{i=0}^n X_i^TX_i\)</span></p>
</div></blockquote>
<p>As now we have got the equation of the variance of the data now we need to maximise it in the direction on the <span class="math notranslate nohighlight">\(\vec{V}\)</span>,Which means to take the projection of X on V which is the dot product of X and V.</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\frac{1}{n-1}\times\sum_{i=0}^n(X_i.\vec{V})^T.(X_i.\vec{V}) ----- Maximise\)</span></p>
</div></blockquote>
<p>As <span class="math notranslate nohighlight">\(\frac{1}{n-1}\)</span> is constant we can ignore it and we can use matrix representation of X to simplify the things.</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\((X\vec{V})^T.(X\vec{V}) ----- Maximise\)</span></p>
</div></blockquote>
<p>So,we have to maximise the above equation but as discussed above we took <span class="math notranslate nohighlight">\(\vec{V}\)</span> as a unit vector and determined that <span class="math notranslate nohighlight">\(V^{T}V=1\)</span></p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\therefore\)</span> <strong>maxmise</strong><span class="math notranslate nohighlight">\((X.\vec{V})^T.(X.\vec{V})\)</span> Given the condition <span class="math notranslate nohighlight">\(V^{T}V=1\)</span>.</p>
</div></blockquote>
<hr class="docutils" />
<p>To maximise or minimise a equation with a condition given is called <strong>constrained optimization</strong> for which we take help of <strong>lagarange multiplier</strong> to read and learn about lagrange multiplier you can refer to the following link - <a class="reference external" href="https://en.wikipedia.org/wiki/Lagrange_multiplier">https://en.wikipedia.org/wiki/Lagrange_multiplier</a> or refer to these series of videos for more indepth understanding and application it - <a class="reference external" href="https://shorturl.at/dmqsE">https://shorturl.at/dmqsE</a></p>
<hr class="docutils" />
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\therefore\large{\frac{\partial}{\partial V}(XV)^T.(XV)-\lambda\times\frac{\partial}{\partial v}(V^TV-1)=0}\)</span></p>
</div></blockquote>
<p><strong>It can be also written as-</strong></p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\large{\dfrac{\partial}{\partial V}(V^TX^TXV-\lambda\times V^TV + \lambda)=0}------1\)</span></p>
</div></blockquote>
<p>Let’s diffrentiate the the above two term with respect to V.</p>
<p><strong>For the first term</strong> <span class="math notranslate nohighlight">\((V^TX^TXV)\)</span> it can be written as <span class="math notranslate nohighlight">\(V^TAV\)</span> where <span class="math notranslate nohighlight">\(A=XX^T\)</span> we have already seen the diffrentiation of the term like this before. i.e. <span class="math notranslate nohighlight">\((A+A^T)V\)</span></p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\therefore \frac{\partial}{\partial V}(V^TX^TXV)=(X^TX+(X^TX)^T)\)</span></p>
</div></blockquote>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(= (X^TX +X^TX)V\)</span></p>
</div></blockquote>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(= 2\times X^TXV\)</span></p>
</div></blockquote>
<p><strong>Now for the second term</strong> <span class="math notranslate nohighlight">\(V^TV\)</span> we have also seen the diffrentiation of this kind before</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(\therefore \frac{\partial}{\partial v} \lambda\times (V^TV)=\lambda\times 2V\)</span></p>
</div></blockquote>
<p>Putting the values from above two equation in the <span class="math notranslate nohighlight">\(1\)</span> equation:-</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(2\times X^TXV-2\times\lambda\times V=0\)</span></p>
</div></blockquote>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(X^TXV=\lambda\times V\)</span></p>
</div></blockquote>
<p>we earlier stated that <span class="math notranslate nohighlight">\(X^TX=A\)</span> putting this in the equation.</p>
<blockquote>
<div><p><span class="math notranslate nohighlight">\(A\vec{V}=\lambda\times \vec{V}\)</span></p>
</div></blockquote>
<p>Above equation os similar to that of <strong>Eigen vectors</strong> where <span class="math notranslate nohighlight">\(A\)</span> corresponds to the <strong>transformation matrix</strong>,<span class="math notranslate nohighlight">\(\vec{V}\)</span> is the <strong>eigen vector</strong> and the <span class="math notranslate nohighlight">\(\lambda\)</span> corresponds to the <strong>Eigen value</strong>.<br />
You can read about the eigen vector and values from here - <a class="reference external" href="https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors">https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors</a></p>
</section>
<section id="conclusion">
<h2>Conclusion<a class="headerlink" href="#conclusion" title="Permalink to this headline">¶</a></h2>
<p>Eventually we were trying to find the <span class="math notranslate nohighlight">\(\vec{V}\)</span> for maximum variance and by conclusion derived above, we can say that if we have data <span class="math notranslate nohighlight">\(X\)</span> and <span class="math notranslate nohighlight">\(\bar{X}=0\)</span> i.e. mean of the data is zero, Then the direction of the maximum variance will be its eigen vectors and length of variance will be the eigen value.</p>
<p>A transformation can have multiple eigen vector but the Maximum variance will be along the eiegen vaector having highest value and direction having second highest variance will be alomg eigen vector with second highest eigen value and so on.<br />
Thus, we can choose the number of dimension we want in our data after performing the dimensionality reduction by PCA with taking that number of eigen vectors.This will reduce the dimension as well as preserve most of the information(variance) of the orignal data.</p>
<p>You can refer to the following link for the coding implimentation of PCA - <a class="reference external" href="https://scikit-learn.org/stable/auto_examples/decomposition/plot_pca_iris.html">https://scikit-learn.org/stable/auto_examples/decomposition/plot_pca_iris.html</a></p>
</section>
<section id="further-readings">
<h2>Further Readings<a class="headerlink" href="#further-readings" title="Permalink to this headline">¶</a></h2>
<p><a class="reference external" href="https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors">https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors</a></p>
<p><a class="reference external" href="https://scikit-learn.org/stable/auto_examples/decomposition/plot_pca_iris.html">https://scikit-learn.org/stable/auto_examples/decomposition/plot_pca_iris.html</a></p>
<p><a class="reference external" href="https://en.wikipedia.org/wiki/Lagrange_multiplier">https://en.wikipedia.org/wiki/Lagrange_multiplier</a></p>
</section>
</section>
<script type="text/x-thebe-config">
{
requestKernel: true,
binderOptions: {
repo: "binder-examples/jupyter-stacks-datascience",
ref: "master",
},
codeMirrorConfig: {
theme: "abcdef",
mode: "python"
},
kernelOptions: {
kernelName: "python3",
path: "./."
},
predefinedOutput: true
}
</script>
<script>kernelName = 'python3'</script>
</div>
<!-- Previous / next buttons -->
<div class='prev-next-area'>
<a class='left-prev' id="prev-link" href="11.%20Imbalanced%20Dataset.html" title="previous page">
<i class="fas fa-angle-left"></i>
<div class="prev-next-info">
<p class="prev-next-subtitle">previous</p>
<p class="prev-next-title">Imbalanced Dataset</p>
</div>
</a>
<a class='right-next' id="next-link" href="About%20the%20Authors.html" title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">Acknowledgement</p>
</div>
<i class="fas fa-angle-right"></i>
</a>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p>
By Coding Blocks Pvt Ltd<br/>
© Copyright 2021.<br/>
</p>
</div>
</footer>
</main>
</div>
</div>
<script src="_static/js/index.be7d3bbb2ef33a8344ce.js"></script>
</body>
</html>