03-pca-projection reduces dimensionality by finding directions of maximum variance — a single global linear transformation applied identically everywhere. This works well when the data genuinely lies near a linear subspace, but many real datasets have structure PCA can't see: clusters that curve, spiral, or fold through high-dimensional space in ways no single set of straight-line directions captures.
Implement gaussian_affinities(input, sigma), which converts pairwise distances into a row-normalized similarity distribution — the core building block t-SNE uses to describe "how likely is point j to be point i's neighbor" before it ever attempts any low-dimensional placement. Reuse 01-knn's pairwise_distances.
input: shape (n_samples, n_features). Returns shape (n_samples, n_samples).1 (a genuine probability distribution per point).0 — a point is never its own neighbor.sigma controls how sharply affinity falls off with distance.Open one at a time. Each gives away a little more than the last.
exp(-distance^2 / (2*sigma^2)) is a Gaussian kernel: small distance gives a value near 1, large distance decays toward 0. Compute this on the full pairwise distance matrix at once.
Zero the diagonal before normalizing each row — otherwise p[i,i] (distance 0 to itself, always the largest possible similarity) would dominate the row and crowd out every real neighbor relationship.
No results yet
Run your code to check it against the examples, or submit to run every test.