LLE (Locally Linear Embedding)

Dimensionality Reduction & Anomaly Detection DS practice problem on Onlearn.

Difficulty: hard.

Topics: Understanding Non-Linear Dimensionality Reduction via Locally Linear Embedding, Barycentric Weight Matrix, Local Reconstruction Error, K-Nearest Neighbors (k-NN) Graph, Alignment Matrix (Cost Matrix), Smallest Eigenvector Analysis, Unsupervised Learning, Manifold Learning, Linear Algebra, Optimization Theory, Computational Geometry, Dimensionality Reduction, Nearest Neighbor Search, Eigenvalue Decomposition, Constraint Optimization, Graph-based Learning.

Implement the Locally Linear Embedding (LLE) algorithm from scratch. Given a dataset X (N samples, D features), the target dimension d, and the number of neighbors k, return the d dimensional embedding Y. Assume the input is a numpy array.