









Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!










Author Marc'Antonio Lopez AI & Data Analytics student at Polytechnic University of Turin
Dimensionality reduction transforms data from a high-dimensional feature space ( n dimensions) into a new, lower-dimensional space ( m dimensions), where m is significantly smaller than n ( m << n ). Essentially, it reduces the number of variables or features representing the data.
Here's a conceptual overview of this transformation:
High-Dimensional Data (n features)
Dimensionality Reduction Process
Lower-Dimensional Data (m features)
This process serves several important purposes:
Compress Information : It significantly reduces data storage and processing time, leading to more efficient algorithms and better memory usage. Remove Unwanted Variability (Noise) : By focusing on significant data patterns, it helps filter out irrelevant details and noise, thus cleaning the data. Simplify Classification : It mitigates the "curse of high dimensionality" (sparse data, model overfitting), resulting in simpler, more robust classification models. Data Visualization : It allows complex, high-dimensional data to be projected into understandable 2D or 3D spaces, enabling visual inspection of inherent data structure and relationships.
Goal Objective Method
Compress Information
To retain the maximum amount of essential information while significantly reducing the output data size.
Principal Component Analysis (PCA) : This method identifies and preserves the directions in the data that show the greatest variance (spread).
Improve Classification
To retain the information that best discriminates (separates) between different classes or categories.
Supervised techniques like Linear Discriminant Analysis (LDA) : These methods aim to maximize the separation between distinct classes in the data.
Data Visualization
To create clear 2D or 3D representations that accurately preserve the relationships between data samples.
PCA or t-distributed Stochastic Neighbor Embedding (t-SNE) : These methods are designed to maintain the proximity of original data samples when projected into lower dimensions, making their relationships visually apparent.
Reconstruction
Decomposes into Decomposes into
Matrix A (n x n, symmetric)
V (n x n) Orthogonal matrix Columns are eigenvectors
Σ (n x n) Diagonal matrix Elements are eigenvalues
Transpose of V^ Vᵀ^ (n x n)^ Multiply
Multiply
Singular Value Decomposition (SVD) is a more general matrix decomposition applicable to any rectangular n x m matrix A , taking the form:.
SVD's components are:
U : An n x n orthogonal matrix whose columns are the eigenvectors of AA ᵀ. V : An m x m orthogonal matrix whose columns are the eigenvectors of A ᵀ A. Σ (Sigma): An (^) n x m rectangular diagonal matrix containing (^) A 's non-negative singular values , conventionally listed in decreasing order.
Here's a diagram illustrating the SVD process:
Reconstruction
SVD Decomposition
Matrix A (n x m)
U (n x n) Orthogonal Eigenvectors of AAᵀ
Σ (n x m) Diagonal Singular Values
Vᵀ (m x m) Orthogonal (Eigenvectors of AᵀA)ᵀ
Multiply
Multiply
A = UΣVᵀ
The structure of the (^) Σ matrix in SVD adapts based on the dimensions of the input matrix (^) A :
Case 1: n > m (Tall Matrix) : When the number of rows ( n ) is greater than the number of columns ( (^) m ), the (^) Σ matrix will be padded with additional rows of zeros.
SVD for A (n x m) where n < m
=
Structure of Σ (n rows, m columns) σ₁ σ₂ ... σₙ
0 0 ... 0 (m-n columns of zeros)
A n x m
U n x n
Σ n x m
VT m x m
V m x m
To project a data point (^) x onto a direction defined by a unit vector (^) u ( ):
Here's a diagram illustrating the projection process:
Projection onto a Direction
Project onto u
Reconstruct in original space
Original Point (x)
Scalar Projection (y = uᵀx)
Reconstructed Point (x̂ = y * u)
Direction (u) ||u||=
To project a data point (^) x onto an (^) m -dimensional subspace defined by orthonormal basis vectors :
Non-Zero-Mean Data : Importance of Centering : PCA axes always pass through the origin. Applying PCA to non- centered data may cause the first principal component to capture overall data location rather than internal spread. Always center data by subtracting the mean before PCA. This ensures principal components truly represent directions of maximum variance within the data's inherent structure. Interpreting PCA as Preserving Variance : Directions of Highest Variance : PCA identifies and preserves directions of maximal data variability (spread). Covariance Ellipse : In a data cloud, the axes of its descriptive ellipse align with principal directions (eigenvectors). Their lengths are proportional to standard deviation (square root of eigenvalues) in those directions. Decorrelation : Projecting data onto Uᵀ (eigenvector transpose) rotates it, aligning principal directions with coordinate axes. This beneficially makes new features (principal components) uncorrelated. How to Select (^) m (Number of Components) : Two primary methods exist for selecting m (number of components): i. Cross-Validation (for Supervised Tasks) : When PCA preprocesses supervised learning (e.g., classification), determine optimal m via cross-validation by testing values and selecting m yielding best classifier performance on a separate validation set. ii. Retaining a Percentage of Variance : A common heuristic selects the smallest (^) m retaining a target percentage ( t , e.g., 0.95) of total data variance. This is calculated as: , where σᵢ are descending-sorted eigenvalues. PCA for Large Feature Spaces : Computing the full covariance matrix C is computationally expensive and memory-intensive for datasets with many features. To address this, alternative methods include:
Truncated Singular Value Decomposition (SVD) : This method efficiently computes only the top m singular values and corresponding vectors (directly related to principal components), rather than all. Probabilistic PCA : A PCA variant formulated within a probabilistic framework, offering more robustness and missing data handling in certain scenarios.
The MNIST dataset is a classic machine learning benchmark, with these properties:
Property Description
Task Classification of handwritten digits
Classes Digits 0, 1, ..., 9 (a total of 10 classes)
Image Shape 28x28 pixels (images are normalized and centered)
Image Type Gray-scale
Training Samples 60,000 images (approximately 6,000 for each digit)
Test Samples 10,000 images
MNIST Reconstruction with PCA : When PCA is applied to 28x28 (784-dimensional) MNIST images: 50-dimensional PCA (784 to 50 features) yields very clear digit reconstructions, showing essential information retention despite significant reduction. 10-dimensional PCA (to 10 features) produces blurrier but recognizable digits, highlighting PCA's ability for significant information compression while preserving key visual characteristics. PCA as Pre-processing for a Simple Classifier (Euclidean Distance) : A simple Euclidean distance classifier was tested on MNIST, with and without PCA preprocessing. Error rates are shown below:
Dimensions ( (^) m ) PCA Error Rate PCA+LDA Error Rate
Full (w/o PCA) 18.0% -
100 18.1% - 50 18.2% -
Fisher's LDA aims to find a projection vector w maximizing a ratio that compares between-class variability to within-class variability for projected data.
The criterion to maximize is:
Between-Class Variability ( ) : Quantifies class mean separation after projection onto w. is the between-class scatter matrix , essentially the covariance of class means. Within-Class Variability ( ) : Quantifies data spread within each class after projection onto w. is the within-class scatter matrix , a weighted average of individual class covariance matrices.
Maximizing this ratio ensures well-separated classes that remain internally compact in the projected space.
Maximizing Fisher's criterion leads to a generalized eigenvalue problem :
The optimal projection vector w (or vectors, for multiclass) is the eigenvector of corresponding to the largest eigenvalue. This defines the best class-separation direction.
Binary Case (two classes) : The optimal direction w is directly proportional to , where and are the class mean vectors.
Once the optimal projection w is found, a new test sample x_t can be classified by:
For problems with more than two classes, LDA extends its approach to find multiple discriminant directions.
Multiple Discriminant Directions : LDA finds m discriminant directions, which are the eigenvectors of corresponding to the m largest eigenvalues. These form the columns of transformation matrix W. Maximum Number of Directions : LDA can find at most C - 1 meaningful discriminant directions, where C is the total number of classes (e.g., 9 for MNIST's 10 classes). Transformed Points : Original data points x are transformed into the new lower-dimensional space by multiplying with the transpose of W :.
Assumptions : If violated, LDA's performance might degrade. Assumes data within each class is approximately Gaussian-distributed (bell-curve shape). Assumes all classes share similar covariance structures (i.e., roughly equal scatter matrices). Singular S_W (Within-Class Scatter Matrix) : A common challenge occurs if the within-class scatter matrix is singular (non-invertible). This can happen if: Features greatly outnumber samples in some classes. Features are perfectly correlated. Class data lies on a lower-dimensional subspace than total feature space. If is singular, its inverse ( ) cannot be computed, which is required for the generalized eigenvalue problem. PCA+LDA (A Common Solution) : To overcome singular or improve robustness, a common strategy is to first apply PCA as a preprocessing step. Process : a. Apply PCA to original data to reduce dimensionality to (^) k (where (^) k < samples/features) and decorrelate features. This ensures a non-singular covariance matrix. b. Then, apply LDA to the PCA-transformed data to find discriminant directions. Example (MNIST) : The MNIST table shows PCA+LDA with m=9 (9 discriminant dimensions) resulted in a 12.2% error rate, a substantial improvement over PCA alone (25.5%) at the same dimensionality. This demonstrates how combining both methods' strengths improves classification.