• edited by
1 flag 197 views
0 0 votes

Answer the same questions for the following dataset:

$$\begin{bmatrix} 1 & 1 \\ 1.5 & 1.5 \\ -2 & 2 \\ 4 & -4 \\ 6 & -6  \\ 2 & 2 \end{bmatrix}$$

  1. What are the first $v_1$ and second $v_2$ principal component vector?
  2. If we use only the first principal component to compress the dataset, what will the representation of each point be?
  3. Will this representation be lossy, or perfectly preserve the data?
 
  1. $v_1 = \frac{1}{\sqrt 2}[1 \\\ -1]^T$
  2. $v_2 = \frac{1}{\sqrt 2}[1 \\\ 1]^T$
  3. $[0 \\\ \\\ 0 \\\ \\\\ -2\sqrt 2 \\\ \\\ 4\sqrt 2 \\\ \\\ 6\sqrt 2 \\\ \\\ 0]^T$
  4. True, representation will be lossy, or perfectly preserve the data.
 
  • 🚩 Edit necessary | 👮 Laplance_Demon | 💬 “Qusetions Does't Specfiy to use feature matrix as it is (No mean Centreing assumption so these vectors are not accurate )”

1 Answer

0 0 votes
Here is the step-by-step calculation of the standard, mean-centered PCA for this dataset.
 

1. Calculate the Feature Means

First, we find the exact mean of the $x$ and $y$ columns from the 6 data points in the image:
 
  • $\mu_x$: $(1 + 1.5 - 2 + 4 + 6 + 2) / 6 = 12.5 / 6 \approx \mathbf{2.083}$
  • $\mu_y$: $(1 + 1.5 + 2 - 4 - 6 + 2) / 6 = -3.5 / 6 \approx \mathbf{-0.583}$

2. Compute the Centered Covariance Matrix ($\Sigma_{centered}$)

Instead of subtracting the mean from every single point manually, we can use the variance shift formula $\sum (x-\mu)^2 = \sum x^2 - n\mu^2$.
 
Using the uncentered sums calculated previously ($\sum x^2 = 63.25$, $\sum y^2 = 63.25$, $\sum xy = -48.75$):
 
  • $\Sigma_{xx}$: $63.25 - 6(2.083)^2 = 63.25 - 26.041 \approx \mathbf{37.208}$
  • $\Sigma_{yy}$: $63.25 - 6(-0.583)^2 = 63.25 - 2.041 \approx \mathbf{61.208}$
  • $\Sigma_{xy}$: $-48.75 - 6(2.083)(-0.583) = -48.75 - (-7.291) \approx \mathbf{-41.458}$
This gives us the true, mean-centered scatter matrix:
 
$$\Sigma_{centered} = \begin{bmatrix} 37.208 & -41.458 \\ -41.458 & 61.208 \end{bmatrix}$$

3. Find the Eigenvalues ($\lambda$)

We solve the characteristic equation $\det(\Sigma_{centered} - \lambda I) = 0$:
 
$$(37.208 - \lambda)(61.208 - \lambda) - (-41.458)^2 = 0$$
$$\lambda^2 - 98.416\lambda + (2277.427 - 1718.766) = 0$$
$$\lambda^2 - 98.416\lambda + 558.661 = 0$$
Applying the quadratic formula yields the new variances (eigenvalues) for the principal components:
 
  • $\lambda_1 \approx 92.368$
  • $\lambda_2 \approx 6.048$

4. Find the Eigenvectors ($v_1, v_2$)

To find the first principal component $v_1$, substitute $\lambda_1 = 92.368$ into $(\Sigma_{centered} - \lambda I)v = 0$:
 
$$\begin{bmatrix} 37.208 - 92.368 & -41.458 \\ -41.458 & 61.208 - 92.368 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$
$$-55.16x - 41.458y = 0 \implies y \approx -1.3305x$$
Normalizing the vector $[1, -1.3305]^T$ to unit length (dividing by its magnitude $\sqrt{1^2 + (-1.3305)^2} \approx 1.664$) yields:
$v_1 = \begin{bmatrix} 0.601 \\ -0.799 \end{bmatrix}$
 
To find the second principal component $v_2$, substitute $\lambda_2 = 6.048$:
 
$$\begin{bmatrix} 37.208 - 6.048 & -41.458 \\ -41.458 & 61.208 - 6.048 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$
$$31.16x - 41.458y = 0 \implies y \approx 0.7516x$$
Normalizing the vector $[1, 0.7516]^T$ to unit length (dividing by its magnitude $\approx 1.251$) yields:
$v_2 = \begin{bmatrix} 0.799 \\ 0.601 \end{bmatrix}$
 
By properly mean-centering the data, the eigenvectors $[0.601, -0.799]^T$ and $[0.799, 0.601]^T$ are slightly rotated from the uncentered eigenvectors of $[\frac{1}{\sqrt{2}}, -\frac{1}{\sqrt{2}}]^T$ ($\approx [0.707, -0.707]^T$). This shift occurs because the true center of mass $(2.083, -0.583)$ is not at the origin, meaning the axis of maximum variance has to tilt slightly to pass directly through the physical center of the cluster rather than forcing its way through $(0,0)$.
Answer:
Position:
Show:

Related questions

1 1 vote
0 0 answers
164
164 views
GO Classes asked Mar 31, 2025
164 views
Suppose a d-dimensional dataset is reduced to $\mathbb{R}^3$ with PCA. Suppose the covariance matrix of the new dataset is computed. Which of the below could possibly be ...
1 1 vote
1 1 answer
236
236 views
GO Classes asked Mar 31, 2025
236 views
Data points in the 2-d space: $(-1, -1), (0,0), (1,1)$What is the first principal component?If we project the original data points into the 1-d subspace by the principal ...
0 0 votes
0 0 answers
130
130 views
GO Classes asked Mar 31, 2025
130 views
Consider a centered design matrix $X \in \mathbb{R}^{n \times d}$, where $X_i \in \mathbb{R}^d$ is the $i$-th sample point (a column vector) and $X_i^{\top}$ is the $i$-t...
0 0 votes
0 0 answers
155
155 views
GO Classes asked Mar 31, 2025
155 views
In each plot below, the data is projected onto two (unit-length) principal component vectors. We say that a plot is "valid" if the $x$-coordinate (written as "PC1") would...