
















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!

















Linear dimensionality reduction technique. Finds a new coordinate system capturing max amount of information (variance) using fewest dimensions possible. Constrained optimization problem.
Centering: subtract mean from each data point. This ensures the 1 st^ component describes shape of data
Orthogonality: every PC must be ⊥ (orthogonal) to all others to ensure no redundant info is captured.
Linearity: assumes data lies on flat manifold, if not it will overestimate n° dimensions required to represent it
Ordering: PC are ordered by descending variance.
No scale invariance: features with larger scales can dominate. If features are already in same units and their differences are significant, normalizing might lead to loss of information.
Let S be the covariance matrix of centered data
n =
xnxTn
Find vector u (direction of 1 st^ PC) s.t. variance of projected data is maximized. Projected variance is given by uT^ Su.
To prevent u from growing to ∞, constrain it to be a unit vector uT^ u = 1
To find max under a constraint, define Lagrangian multiplier :
L ( u, λ ) = uT^ Su − λ ( uT^ Su − 1)
Taking derivative wrt u and setting to zero:
∂L ∂u
= 2 Su − 2 λu = 0 ⇒ Su = λu
This is an eigenvalue problem:
Scree plot: graph showing magnitude of each eigenvalue in descending order
Elbow method: pt where eigenvalues stop dropping significantly. Dimensions after elbow = noise.
Explained variance ratio:
t =
∑ d ∑ Di^ λ^1 i λi
∑kept λ all λ Tells the amount of variance being preserved
Objective: reproduce distances from original ”ambient space” into lower-dimensional ”projected space.” Goal: the two sets of distance matrices should be ideally identical to avoid information loss. Stress: defined as error or difference between these two sets of distances, serving as a loss function.
3.0.1 2.2 Types of Multi-Dimensional Scaling (MDS) Classical MDS Uses a square loss in the distance space. Equivalent to PCA if Euclidean distances are used in both original and projected spaces.
Metric MDS Preserves relative importance of distances. Less sensitive to outliers than Classical MDS.
Non-metric MDS Focuses on the relative order (rank) of neighbors. Uses a function to transform distances. Allows fine-tuning for specific problem types (i.e changing map size to fit data).
Similarity: higher Distance: lower
values mean more similar
3.1.1 3.3 Conditions for a Metric Distance Non-negativity: d ( x, y ) ≥ 0 ∀ x, y, and d ( x, y ) = 0 iff x = y. (For similarities, s ( x, x ) = 1).
Symmetry: d ( x, y ) = d ( y, x )∀ x, y.
Triangle Inequality: d ( x, z ) ≤ d ( x, y ) + d ( y, z )∀ x, y, z. Critical condition.
3.1.2 3.1 Advantages
Non-numerical Data: Can map data without knowing exact coordinates. Visualization: Provides insights into data geometry and features. Pairwise Comparisons: (e.g., sequence alignment: count common letters to derive similarity).
3.2.1 4.1 Metric Distances
(| xi − yi | p ))(^1 /p ).
- p = 2: Euclidean (straight line). - p = 1: Manhattan (city block, sum of absolute differences, grid movement). - p = ∞: Chebyshev or Superior distance (max of absolute differences max (| xi − yi |))
3.2.2 4.2 Non-Metric Distances
3.2.3 4.3 Distances for Binary Features
Jaccard Similarity: Number of common features / Total number of features considered. Not a metric distance. Hamming Distance: Minimum number of changes needed to transform one data point into another. proper metric distance.
Idea: expand original space into a higher-dimensional feature space where data becomes linearly separable.
Transformation example: ( x 1 , x 2 ) −MAP−−→ ϕ
x 1 ϕ 1 ,^
x 2 ϕ 2 ,^
x^21 + x^22 ϕ 3
Result: points originally in the center would be near the origin of ϕ 3 while outer points would have a higher ϕ 3 value, making them linearly separable.
Sometimes data isn’t linearly separable or well represented in its original space. So, a feature map ϕ ( x ) is applied and sends each data point x into a higher dimensional feature space. Computing ϕ ( x ) explicitly can be very expensive/impossible, feature space could have ∞ dimensions.
Kernel function: Computes inner product without explicitly mapping x to ϕ ( x ). Operates directly on original inputs xi and xℓ^ mathematically giving the same result.
kiℓ = k ( xi, xℓ ) = ⟨ ϕi, ϕℓ ⟩
5.1.1 Types of kernels
Linear kiℓ = k ( xi, xℓ ) = xi, xℓ
⊤
Polynomial kiℓ = k ( xi^ − xℓ ) δ^ version 1 kiℓ = k ( xi^ − xℓ^ + 1) δ^ version 2 (More powerful)
Dimension expansion: the new feature space dimension can be significantly larger
Valid kernel for a function k ( i, l ) to be a valid kernel, resulting kernel matrix K must be: Symmetric: ki,l = kl,i Positive Semi-Definite: for any vector c:
i
l ciclki,l^ ≥^0. Satisfies Mercer’s theorem.
Mercer’s Theorem: if satisfied, there exists a feature map ϕ mapping data into a high-dimensional space such that kernel computes dot product in that space.
k ( i, l ) = ⟨ ϕ ( xi ) , ϕ ( xl )⟩
ϕ^ ˜ i^ = ϕ ( xi )^1 N
k =
ϕ ( xk )
kil = ⟨ ϕi, ϕℓ ⟩
k centered il = kil −
k
kik −
m
klm +
k,m
kkm
Uses diffusion distance (probabilistic approach penalizing travel through low-density regions, reflecting a more ”meaningful” distance on the manifold). Equivalent to MDS with diffusion distance.
Define Diffusion Kernel: Gaussian kernel k ( xi, xl ) = exp (−|| xi − xl ||^2 / (2 ∗ σ^2 )). σ : key hyperparameter, max distance for single jump between points, (scale of noise.)
Normalize Kernel: Apply diffusion normalization to transform it into a transition probability matrix. Represents probability of transitioning from one data point to another. Markov matrix (Markov chain process).
Spectral Decomposition: Analyze transition probability matrix.
Eigenvectors: representing new low-dimensional coordinates, similar to Kernel PCA. First eigenvector often corresponds to equilibrium population.
Stress (loss): function of sum of squared distance differences. Allows focusing on specific distances most important for reproduction, incorporating prior knowledge/biases.
Stress =
i
l ( wi^ ∗^ ( g ( δil )^ −^ g ( dil ))
wi Relative importance of point i. Can be set to 1 for all points if no specific importance is known. δil Distance between points i and l in the original highprojected low-dimensional space. dil g ( δ ) A complex function 1 − 2 ·
1 1+( δ/σ ) A
Stochastic Embedding: Reproduce prb of being neighbors, maximize similarity bwn these prbs in embedding (original data) and projected space.
6.2.1 4.1. t-Distributed Stochastic Neighbor Embedding (t-SNE)
Probabilities in Embedding Space: PL | I =
exp
− ∥ xI^ − xL ∥
2 2 σ I^2
K ̸ = I exp
− ∥ xI^ − xK^ ∥
2 2 σ I^2
Uses a Gaussian function of distances. σI is point-dependent (different for each point I).
Symmetrization: PIL =
N : total points
Perplexity: σI = 2(
L ( PL | I^ log^2 ( PL | I^ ))). Effective n° of nearest neighbors to preserve. Non-linear equation.
Loss function: Kullback-Leibler divergence KL ( P || Q ) =
I
L ( PIL^ log (^
PIL QIL ))^
PIL :embedding space prbs QIL :projected space prbs Minimize this function to find optimal projected coordinates y.
Probabilities in Projected Space ( QIL ):
QIL =
(1 + || yI − yL ||^2 )(−1) ∑ K ̸ = M (1 +^ || yK^ −^ yM^ || (^2) )(−1)) yI^ , yL^ Euclidean distances in projected space
6.2.2 4.2. UMAP (Uniform Manifold Approximation and Projection)
PIL definition: Uses a non-normalized exponential kernel PIL = exp
− max (0 , || xI σ^ − IxL ||− ρI^ )
Distances < ρI ≈ 0 (points are in same location), prevent excessive emphasis on very small distances.
σI determination: Found via a parameter k (number of neighbors of interest).
Symmetrization: PI | L = PI | L + PL | I − ( PI | L · PL | I )
QIL expression: designed for specific decay properties. QIL = (^) 1+ a ·|| yI^1 − yL || 2 b
Loss function: Uses cross-entropy like term explicitly penalizing not being neighbors when they should Loss =
IL PIL^ log^ ( PIL/QIL ) + (1^ −^ PIL )^ log^ (^1 − PIL/^1 − QIL )
Initialization: y coords initialized from graph Laplacian, ensure consistent results across runs, improve convergence.
VAEs introduce variational inference to autoencoders. Two main approaches to VAEs:
Regularization of latent space
VAE as a Generative Model
- Manifold hypothesis: Z lives in RM^ (much smaller dimension M), X lives in RD^ (much larger dimension D). - p(X|Z) acts as the decoder.
Probabilistic Decoder
Learning Objective and Variational Inference
p ( X | Z ) p ( Z ) dZ is intractable because the integral over the continuous latent space Z is unknown and hard to compute (due to high dimensionality and ”curse of dimensionality”).
q ( Z | X ) to place mass where p ( X | Z ) is high.
term acts as a regularization term, forcing q ( Z | X ) to be close to p ( Z ).
- Maximizing ELBO: implicitly maximize the log-likelihood and push q ( Z | X ) towards p(Z|X).
Amortized Variational Inference (The Encoder)
any given X.
The Reparameterization Trick
· This is the equivalent of the reconstruction error in standard AEs. · If p ( X | Z ) is Gaussian, this term simplifies to a mean squared error (MSE) like term.
chosen prior p(Z). · This is typically computed in closed form when both q and p are Gaussians.
- Relationship to Autoencoder Loss:
the VAE reconstruction term resembles a ”noisy version” of the autoencoder’s MSE loss.
regularization.
Challenges in VAEs
i q ( Z | Xi )).
- Problem: There can be a mismatch between the chosen prior p ( Z ) and the aggregated variational posterior.
single standard normal, there will be ”holes” in the prior’s high-density regions that are not covered by data samples.
- Consequence: If sampling from the prior, one might pick points that don’t correspond to any training data distribution, leading to unrealistic generations.
10.0.1 2.1. Parametric Methods Assume functional form for density and learn its parameters of this by fitting data. Requires less data for good estimates. Doesn’t need to learn functional form. If assumed functional form is wrong, method will not perform well or will have problems. Functional form assumption induces biases that cannot be fixed by adding more data.
10.0.2 2.2. Non-Parametric Methods
Make no assumption about the functional form of the density. Can adapt to complex densities. Need more data to achieve good estimates. Often involve hyperparameters that balance bias and variance.
Functional form: approximates the real density P ( X ) as a sum of K Gaussian functions:
ρ ( x ) = Σ i = 1 K^ [ πi · N ( x | μi, Σ i )]
πi : Weight for the i-th Gaussian component N ( x | μi, Σ i ) Gaussian function with mean μi and covariance Σ i
Parameters: model learns πi, μi, and Σ i for each of the K Gaussian components.
Assumptions: Number of components K is known (or needs to be inferred).
Normalization condition: sum of weights Σ iπi = 1 to ensure ρ ( x ) is a valid PDF.
Likelihood Function: For a dataset { x 1 , ..., xN }, likelihood is: L = πn = 1 N^ [ ρ ( xn )] Taking the logarithm: log ( L ) = Σ Nn =1 log (Σ Ki =1[ πi · N ( xn | μi, Σ i )]).
Optimization challenge: For K > 1 , likelihood function is analytically non-optimizable due to log of a sum.
Solution: EM algorithm. Iterative numerical method, finds parameters maximizing likelihood.
Initialization: Initialize parameters ( πi, μi, Σ i ) to some values.
Expectation: Compute posterior probability (responsibility) γ ( zni ) that data point xn was generated by i th Gaussian component
γ ( zni ) = πi · N ( xn | μi, Σ i ) Σ Kj =1 πj · N ( xn | μj , Σ j )
Maximization : Update the parameters using the computed responsibilities to maximize the likelihood
Effective n° points for component i: Ni = Σ n = 1 N^ γ ( zni ) New weights: πinew = Ni/N New means: μinew = Σ Nn =1[ γ ( zni ) · xn ] /Ni New covariances (1D): Σ^2 inew = Σ Nn =1[ γ ( zni ) · ( xn − μinew )^2 ] /Ni
10.2.1 5.1. Histograms
Ij P^ ( X ) dx.
Ij P^ ( X ) dx^ ≈^ P^ ( xj^ )^ ·^ h^ (where^ xj^ =^ center of^ Ij^ ).
ρ ( x ) dx ≈ Σ P ( xj ) · h = Σ( Nj / ( N · h )) · h = Σ Nj /N = N/N = 1.
Error Analysis (Variance):
Curse of Dimensionality: In HD, most bins will be empty or contain very few points, leading to huge errors and useless estimates.
Bias-Variance Trade-off according to bin width (h):
Small: Low Bias: Can capture local variations in the PDF. High Variance: Many bins with few counts, leading to noisy estimates.
Large: ▲ B: smooth out local variations, assume uniform density over wide regions (might be false). Low Variance: More counts per bin, leading to more stable estimates.
Optimal: Friedman-Diaconis Rule h ≈ 2 IQR √ (^3) N
IQR (Interquartile Range): x 75 th − x 25 th percentile. Assumes properties of the underlying distribution to estimate h.
Problem: Even with fixed h, starting pt for 1 st^ bin needs to be chosen, introducing another hyperparameter.
10.2.2 5.2. Parzen Windows Avoids the ”starting point” issue of histograms. A ”small rectangle” (window function) of a specific width h is placed at the center of each data point. Overall PDF is the sum of these rectangle functions.
Superposition: Where rectangles overlap, their contributions are summed.
10.2.3 5.3. Kernel Density Estimation (KDE)
Generalization of Parzen Windows: replaces ”rectangle” function with a kernel function that integrates to 1 (
K ( u ) du = 1).
PDF Estimate: ρ ( x ) = (^) N h^1 · Σ Nn =
K ( x − hx n )
] (^) h :Bandwidth (aka smoothing parameter) K :Kernel function (Uniform/Rectangle, Gaussian).
Key Differences from GMM: the bandwidth h is a hyperparameter, not learned from data. Visualization: Places a kernel function with width h on top of each data point and sums them up.
Bias-Variance Trade-off (Bandwidth h):
Large: Smoother estimate (low variance, high bias). May over-smooth and miss fine details.
Small: Less smooth estimate (high variance, low bias). Can capture local details but may be noisy.
Optimal: Silverman’s Rule: h ≈ 0_._ 9 · min(Σ data, IQR/ 1_._ 34) · N −^ (^15)
Cross-Validation: More robust
10.2.4 K-Nearest Neighbor (K-NN) Density Estimation
Can be derived from a likelihood function. Focuses on distances from a central point to its nearest neighbors. Assumes data points are randomly distributed (IID) according to a Poisson process. Volumes of spheres around the central point that enclose each successive nearest neighbor follow an exponential law. This holds for constant density.
Estimation Process:
Error / Variance:
Bias-Variance Trade-off in K-NN:
Centroid ( cL ): average coordinates of all data points belonging to a specific cluster L.
cL =
xi ∀ xi in cluster L Number of points in cluster L
Loss Function (Inertia): Measures intra-cluster dissimilarity (how compact clusters are around their centers). Loss =
(for k = 1 to K clusters)
(for each data point xi in cluster k ) (distance( xi, ck ))^2 Target: Find the partition that minimizes this loss.
Algorithm (K-Means): The problem of finding the global minimum of the loss is NP-hard; K-Means performs a local optimization.
Sensitive to Initialization: Can get trapped in local minima of the loss function. Solutions:
(^2) (favors points far from existing centers, ensuring better initial spread).
Choice of K (Number of Clusters): significant problem if goal is to identify real data partitions Solution: Scree Plot (Elbow Method)
Sensitive to Outliers: these can shift centroid (mean), distorting cluster definition/partition. Solution: K-Medoids:
Only Works in Euclidean Spaces: Solution: K-Medoids works with distances, allows use of non-Euclidean metrics.
Only works for convex clusters: For non-convex, centroid might fall within another cluster. Solution: geodesic distance
Process:
12.1.1 Distance as a Function of Assignations The Euclidean distance squared can be expanded: || ϕi − ϕj ||^2 = ϕi − ϕi + ϕj · ϕj − 2 ϕiϕj = kii^ + kjj^ − 2 kij
This can be related to kernel functions (K). By substituting K values, distance can be expressed as a function of assignations and kernel output. This allows iteration in a ”feature space” to perform k-means.
Contrast with K-means:
μip = 1).
Objective Function: L =
i
j μ
f ij || xi^ −^ cj^ || (^2) f: Fuzzification parameter.
Center Definition: cj =
i μ
f ij xi ∑ i μ
f ij
(weighted average of positions)
Algorithm: Similar to K-means.
Message passing algorithm (clustering based on data points communicating with each other iteratively). Determines exemplars (members of input set representative of clusters) Automatically defines # clusters (that consists of all elements sharing same exemplar).
14.2.1 Responsibility (R(i,k)) Represents the accumulated evidence that sample k should be the exemplar for sample i. Update Formula: R ( i, k ) = S ( i, k ) − max k ′ (^) ̸= k [ S ( i, k ′) + A ( i, k ′)] Initial step (when all A values are 0): R ( i, k ) = S ( i, k ) − max k ′ (^) ̸= k ( S ( i, k ′))
14.2.2 Availability (A(i,k))
Reflects the accumulated evidence that sample i would choose sample k as its exemplar. Update formula: If i ̸= k : A ( i, k ) = min(0 , R ( k, k ) +
i ′^ ̸= i,k max(0 , R ( i
′ , k ))) else ∑ i ′!= k max(0 , R ( i
′ , k ))
Define Similarities (S):
A point i is an exemplar if sum of its availability and responsibility is maximal for itself compared to all other points. i = arg max l ( Ail + Ril ). Points are then assigned to clusters using the exemplars.
Extreme hyperparameter dependence: results are highly sensitive to the chosen hyperparameters, especially Skk (the preference). Even small changes can drastically alter the clustering structure.
Preference for Convex Clusters: its standard similarity measure is typically defined based on Euclidean distance. This could potentially be mitigated by using different similarity measures (e.g., geodesic distance).
Transform data points into an undirected weighted graph G ( V, E ).
Choice of hyperparameters ( ε, k, σ ) is crucial and can dramatically alter the clustering results. Methods for obtaining W (can be combined,e.g., applying a similarity function only to k-NN connections).
Epsilon-ball graph: Connects vertices if they are within a given radius ε.
k-NN graph: Connects vertices to their k nearest neighbors. Requires symmetrization (e.g., Sij = Sji = 1 if i is a k-NN of j OR j is a k-NN of i ) since k-NN is not commutative.
Fully connected graphs (Clique): Every vertex is connected to every other vertex. Edge weights Sij are a function of the
distance dij between points i and j. Common function: Gaussian similarity Sij = e − d
(^2) ij/ 2 σ 2
A cut defines a partition ( C, C ′) in the graph.
i ∈ C,j ∈ C ′^ ( Sij^ ). Sums weights of edges connecting points in C to points in C’.
K-Way Cut: Generalization for K partitions ( C 1 , C 2 , ..., CK ).
m =1→ K ( cut ( Cm, C ′ m )).
Ratio Cut: Size Measure: | Cm | (# vertices in cluster Cm ). Loss Function: RatioCut( C 1 , ..., CK ) =
m =1→ K (cut( Cm, C ′ m ) / | Cm |). Minimizing this ensures that smaller clusters (with smaller | Cm | in the denominator) contribute more to the loss if their cut value is high, discouraging heavily unbalanced partitions.
Normalized Cut: Degree of a point i: Sum of weights of all connections from point i. di =
j =1→ N ( Sij^ ). Volume of a cluster: Sum of degrees of all points within cluster Cm. V ol ( Cm ) =
i ∈ Cm ( di ). Loss Function: N Cut ( C 1 , ..., CK ) =
m =1→ K ( cut ( Cm, C ′ m ) /V ol ( Cm )). This measure considers both the number of points and their connectivity within the cluster.
Weight: N x N symmetric matrix (N number of data points). Wij = Sij for i ̸= j. Wii = 0 (no self-loops).
Degree: N x N symmetric diagonal matrix. Dii = di (the degree of point i). Dij = 0 for i ̸= j.
Laplacian: L = D − W. Symmetric positive semi-definite. vT^ Lv = 12 ·
i,j ( Sij^ ( vi^ −^ vj^ )
(^2) ). Minimizing vT (^) Lv seeks vi values
that are similar for strongly connected nodes.
Discrete cluster indicator variables are relaxed to continuous, real-valued vectors. For K clusters, this involves an N x K matrix H of indicator vectors. Minimizing RatioCut (K clusters) ≡ minimizing T race ( HT^ LH ) subject to HT^ H = I (orthogonality constraint). Minimizing NCut (K clusters) ≡ minimizing T race ( HT^ LH ) subject to HT^ DH = I. Discrete optimization transformed into generalized eigenvalue/vector problem. Columns of H = eigenvectors.
Construct similarity matrix W and Laplacian L = D - W. Compute 1 st^ k eigenvectors of L corresponding to k smallest eigenvalues (exclude trivial ones associated to eigenvalue 0). Discretize: form N × k mx H where each column is one of the computed eigenvectors. Perform k-means clustering on rows of H to assign each data point to a cluster.
Construct Similarity Matrix W and Degree Matrix D. Compute the Symmetric Normalized Laplacian Lsym = D (−^ (^12) ) LD (−^ (^12) ) ( L = D − W ). Compute the first k eigenvectors of Lsym corresponding to the k smallest eigenvalues. Let these eigenvectors form the columns of an N x k matrix T. Discretize: Perform k-means clustering on the rows of T to assign each data point to a cluster.