βˆ‘GateAndNet
PlannerSign Up
INTERMEDIATEFrequently Tested 4 min read 2 views

PCA Eigen-Directions, K-Means/DBSCAN Clustering & Neural Net Backpropagation

Covariance matrix eigenvectors & proportion of variance explained in PCA, K-Means Lloyd objective vs DBSCAN density reachability, MLP Softmax Cross-Entropy gradient, and CNN output shapes.

1. Principal Component Analysis (PCA)

Center data Xc=Xβˆ’1ΞΌTX_c = X - \mathbf{1}\mu^T. Maximizing projected variance u1TΞ£u1u_1^T \Sigma u_1 subject to βˆ₯u1βˆ₯22=1\|u_1\|_2^2 = 1 via Lagrange multiplier L(u1,Ξ»)=u1TΞ£u1βˆ’Ξ»(u1Tu1βˆ’1)L(u_1, \lambda) = u_1^T \Sigma u_1 - \lambda(u_1^T u_1 - 1) gives:

βˆ‡u1L=2Ξ£u1βˆ’2Ξ»u1=0β€…β€ŠβŸΉβ€…β€ŠΞ£u1=Ξ»u1\nabla_{u_1} L = 2\Sigma u_1 - 2\lambda u_1 = 0 \implies \Sigma u_1 = \lambda u_1
  1. The kk-th principal component direction uku_k is the unit eigenvector corresponding to the kk-th largest eigenvalue Ξ»k\lambda_k of Ξ£\Sigma (equivalently, right singular vector vkv_k of Xc=USVTX_c = U S V^T with Ξ»k=sk2/n\lambda_k = s_k^2 / n).
  2. Principal components are mutually orthogonal (uiTuj=0u_i^T u_j = 0 for i≠ji \neq j) and uncorrelated in projected space.
  3. Minimizing mean squared reconstruction error 1nβˆ₯Xcβˆ’XcUkUkTβˆ₯F2\frac{1}{n}\|X_c - X_c U_k U_k^T\|_F^2 yields the exact same top-kk eigenvectors (discarded error =βˆ‘j=k+1dΞ»j= \sum_{j=k+1}^d \lambda_j)!

2. Clustering: K-Means vs Hierarchical vs DBSCAN

AlgorithmCluster ShapeRequires KK Upfront?Handles Noise / Outliers?Time Complexity
K-Means (Lloyd’s)Convex / Spherical (Voronoi)βœ… Yes❌ Sensitive to outliersO(tβ‹…Kβ‹…nβ‹…d)\mathcal{O}(t \cdot K \cdot n \cdot d)
Agglomerative HierarchicalArbitrary (Single-Link) / Compact (Complete)❌ Dendrogram cut⚠️ Single-link chains on noiseO(n2log⁑n)\mathcal{O}(n^2 \log n)
DBSCAN (Ο΅,MinPts\epsilon, \text{MinPts})Arbitrary non-convex shapes❌ Noβœ… Labels sparse points as NoiseO(nlog⁑n)\mathcal{O}(n \log n) (spatial index)

3. Neural Networks, Activations & Backpropagation

  • Sigmoid Οƒ(z)=11+eβˆ’z\sigma(z) = \frac{1}{1 + e^{-z}}: Derivative Οƒβ€²(z)=Οƒ(z)(1βˆ’Οƒ(z))≀0.25\sigma'(z) = \sigma(z)(1 - \sigma(z)) \le \mathbf{0.25} (at z=0z=0). Multiplying ≀0.25\le 0.25 across LL layers causes vanishing gradients!
  • ReLU max⁑(0,z)\max(0, z): Derivative is 11 for z>0z > 0 (no saturation for positive activations!), 00 for z<0z < 0 (Dying ReLU if learning rate is too high β†’\to fixed by Leaky ReLU / GELU).
  • Softmax + Cross-Entropy Clean Gradient: For logits z∈RKz \in \mathbb{R}^K, probabilities y^c=ezcβˆ‘jezj\hat{y}_c = \frac{e^{z_c}}{\sum_j e^{z_j}}, and one-hot target yy:
βˆ‚LCEβˆ‚z=y^βˆ’y\frac{\partial \mathcal{L}_{\text{CE}}}{\partial z} = \hat{y} - y
Key Formulas Summary
PCA Proportion of Variance Explained (Top k Principal Components)
Ξ£=1nXcTXc,PVE(k)=βˆ‘i=1kΞ»iβˆ‘j=1dΞ»j\Sigma = \frac{1}{n} X_c^T X_c, \qquad \text{PVE}(k) = \frac{\sum_{i=1}^{k} \lambda_i}{\sum_{j=1}^{d} \lambda_j}
Note: lambda_1 >= lambda_2 >= ... >= lambda_d >= 0 are eigenvalues of sample covariance matrix Sigma
CNN Feature Map Spatial Output Dimension
O=⌊Wβˆ’K+2PSβŒ‹+1,Params=(Khβ‹…Kwβ‹…Cin+1)β‹…CoutO = \left\lfloor \frac{W - K + 2P}{S} \right\rfloor + 1, \qquad \text{Params} = (K_h \cdot K_w \cdot C_{\text{in}} + 1) \cdot C_{\text{out}}
Note: +1 per filter accounts for bias (omit +1 if followed immediately by BatchNorm with bias=False)
#Machine Learning#PCA#K-Means#DBSCAN#Neural Networks#Backpropagation#CNN

Practice Questions on This Chapter (3)

Q1GATE DA MLMCQEASY
+2M β€’ -0.67

The sample covariance matrix Ξ£\Sigma of a 44-dimensional centered dataset has eigenvalues {12,5,2,1}\{12, 5, 2, 1\}. What percentage of total variance is preserved by projecting onto the first two Principal Components?

⚑ Click an option above to verify instantly
Q2GATE DA Deep LearningMCQMEDIUM
+2M β€’ -0.67

A 2D Convolutional layer takes an input volume of size 32Γ—32Γ—332 \times 32 \times 3 and applies 1616 filters of spatial size 5Γ—55 \times 5 with stride S=1S = 1, padding P=2P = 2, and one bias parameter per filter. What is the output shape and total trainable parameter count?

⚑ Click an option above to verify instantly
Q3GATE DA ClusteringMCQEASY
+1M β€’ -0.33

Which clustering algorithm can discover non-convex concentric ring clusters AND explicitly identify isolated noise / outlier points without pre-specifying the number of clusters KK?

⚑ Click an option above to verify instantly
Previous TopicDecision Trees (Entropy vs Gini), Random Forests & Gradient Boosting (XGBoost)Next Topic N-Gram Language Models, Laplace/Kneser-Ney Smoothing & Perplexity