edgepedia

技术与人造世界 / 计算技术与数字系统 / 人工智能与数据 / Algorithms and computational methods

综合 · Edgepedia阅读需 11 分钟

随机投影

阅读英文原文

随机投影是一种降维方法,它将高维数据乘以一个随机生成的矩阵,把每个点映射为低维向量,同时近似保持点与点之间的成对距离。该映射的形式为 f(x)=U⊤x/p f(x) = U^{\top} x / \sqrt{p} ,其中 U∈Rd×p U \in \mathbb{R}^{d \times p} 的元素独立同分布,均值为零、方差为一(例如 uij∼N(0,1) u_{ij} \sim N(0, 1) );矩阵来自某个分布,而不是从数据中学习得到。1 约翰逊–林登施特劳斯(Johnson–Lindenstrauss)引理保证:任意 n n 个点都存在一个到 k=O(log⁡n/ε2) k = O(\log n / \varepsilon^{2}) 维的映射,使所有成对平方距离保持在 1±ε 1 \pm \varepsilon 的因子范围内;而随机矩阵能以高概率实现这一点。2 由于矩阵在数据到来之前就已选定,该方法与数据无关(data-oblivious)。2

关键事实细节
产生什么一个线性草图 f(x)=U⊤x f(x) = U^{\top} x ,其中 U U 是随机的、与数据无关的矩阵 1
保证所有成对平方距离以高概率保持在 1±ε 1 \pm \varepsilon 以内 2 • 3
目标维度k=O(ε−2log⁡n) k = O(\varepsilon^{-2} \log n) ,与原始维度 d d 无关 2
常见构造高斯 N(0,1) N(0,1) 元素、拉德马赫(Rademacher)±1 \pm 1 元素、稀疏 {−1,0,+1} \{-1, 0, +1\} 元素(其中零占 2/3)4 • 5
106 10^{6} 个点的最小维度ε=0.5 \varepsilon = 0.5 时为 663 个分量,ε=0.1 \varepsilon = 0.1 时为 11,841 个,ε=0.01 \varepsilon = 0.01 时为 1,112,658 个 6
每个向量的成本稠密矩阵为 O(dk) O(dk) ;快速约翰逊–林登施特劳斯变换为 O(dlog⁡d+∣P∣) O(d \log d + |P|) 7
观察到的失真将 300 篇文档从 130,107 维投影到 300 维,平方距离的平均变化因子为 1.01(标准差 0.16)8

工作原理

该引理指出,对于欧几里得空间中的任意 n n 个点以及任意 ε∈(0,1) \varepsilon \in (0, 1) ,都存在一个到 Rk \mathbb{R}^{k} 的嵌入,其中 k=O(ε−2log⁡n) k = O(\varepsilon^{-2} \log n) ,使得对每一对点都有 (1−ε)∥xi−xj∥2≤∥f(xi)−f(xj)∥2≤(1+ε)∥xi−xj∥2 (1-\varepsilon)\|x_i - x_j\|^{2} \le \|f(x_i) - f(x_j)\|^{2} \le (1+\varepsilon)\|x_i - x_j\|^{2} ;随机构造的失败概率约为 δ=2e−(ε2−ε3)(p/4) \delta = 2e^{-(\varepsilon^{2} - \varepsilon^{3})(p/4)} 。1 • 9 目标维度取决于点的数量和精度,而不取决于原始维度。2

随机矩阵的证明分为三部分。第一,无偏性:对于元素独立同分布、零均值、单位方差的投影,有 E[∥ψ(x)∥2]=∥x∥2 \mathbb{E}[\|\psi(x)\|^{2}] = \|x\|^{2} ,因此距离平均而言是正确的。第二,集中性:单个平方距离偏离超过 ε \varepsilon 的概率呈指数衰减,例如对于次高斯元素(如均匀的 {−1,0,+1} \{-1, 0, +1\} 或 {−1,+1} \{-1, +1\} 变量),有 Pr⁡[∣∥ψ(x)∥2−∥x∥2∣/∥x∥2>ε]≤2exp⁡(−ε2m/64) \Pr[|\|\psi(x)\|^{2} - \|x\|^{2}|/\|x\|^{2} > \varepsilon] \le 2\exp(-\varepsilon^{2} m / 64) 。10 第三,对至多 n2 n^{2} 个点对取联合界,得到 m≥(64/ε2)log⁡(2n2/δ) m \ge (64/\varepsilon^{2})\log(2n^{2}/\delta) ,因此没有点对失败的概率至少为 1−δ 1 - \delta 。10 • 30 该引理在投影到 O(kε−2log⁡n) O(k\varepsilon^{-2}\log n) 维时也保持角度以及 k k 维角度。9

如何实现

高斯构造用独立同分布的 N(0,1) N(0,1) 元素填充 k×d k \times d 矩阵 M M ,并映射 A(x)=(1/k) M⋅x A(x) = (1/\sqrt{k})\,M \cdot x 。2 实践者的版本设定 m=O(ε−2log⁡(n/δ)) m = O(\varepsilon^{-2}\log(n/\delta)) ,生成 m m 个独立同分布的高斯向量,并输出 ψj(x)=⟨uj,x⟩⋅d/m \psi_j(x) = \langle u_j, x \rangle \cdot \sqrt{d/m} 。10 阿赫利奥普塔斯(Achlioptas)表明,元素可以从 {−1,0,+1} \{-1, 0, +1\} 中均匀抽取,而维度界本质上相同;零比任一非零值更可能出现的分布带来三倍加速,因为每个输出坐标只处理三分之一的属性。4 • 5 这类矩阵适合数据库环境,在这种环境中,嵌入简化为对属性的 k k 个随机划分做一次聚合。5

在 scikit-learn 中,GaussianRandomProjection 从 N(0,1/ncomponents) N(0, 1/n_{\text{components}}) 中抽取元素,SparseRandomProjection 使用元素 ±s/ncomponents \pm\sqrt{s/n_{\text{components}}} ,每个非零值的概率各为 1/(2s) 1/(2s) ,否则为 0,默认密度为 1/nfeatures 1/\sqrt{n_{\text{features}}} ,这是李平(Ping Li)及其同事推荐的;两者都支持通过伪逆进行逆变换。6 辅助函数 johnson_lindenstrauss_min_dim 根据样本数量和 ε \varepsilon 估计所需维度。6 由于该映射从不检查数据,因此可以事先固定。2

起源

该嵌入结果说明 n n 个点可以嵌入到 O(log⁡n/ε2) O(\log n/\varepsilon^{2}) 维中,且失真为 (1±ε) (1 \pm \varepsilon) 。4 弗兰克尔(Frankl)与前原(Maehara)于 1988 年在《组合理论杂志 B 辑》(Journal of Combinatorial Theory Series B)上简化了证明。11 达斯古普塔(Dasgupta)与古普塔(Gupta)于 2002 年在《随机结构与算法》(Random Structures and Algorithms)上给出了一个初等概率证明。12 高斯矩阵构造沿用至今。13 {−1,+1} \{-1, +1\} 构造最初没有性能分析,阿赫利奥普塔斯于 2003 年在《计算机与系统科学杂志》(Journal of Computer and System Sciences)上分析了对数据库友好的稀疏变体。5 马托乌谢克(Matoušek)于 2008 年在《随机结构与算法》上将该引理推广到次高斯元素。14 在应用方面,宾厄姆(Bingham)与曼尼拉(Mannila)于 2001 年在图像和文本数据上展示了随机投影。15

变体

若干类方法在密度、速度和鲁棒性之间权衡:

应用

局限与替代方案

主要替代方法是 PCA,而这两种方法优化不同的误差准则。随机投影约束所有成对距离的失真,而 PCA 最小化平均点的失真,因此它们的误差保证不能直接比较。23 • 24 成本差异很大:在 N×P N \times P 数据集上的经典 PCA 需要 O(NPmin⁡{N,P}) O(NP\min\{N, P\}) 次计算,而用随机投影将数据降到 K K 维在单次遍历中至多需要 O(NPK) O(NPK) 。23 在图像和文本数据上,随机投影保持向量相似性的效果大约与 PCA 相当,而计算成本显著更低。15 两者各自会在对方成功的地方失败。随机投影使扁长的(椭球形)高斯簇更接近球形,而 PCA 可能被簇内高方差方向误导并使簇塌缩;在一项实验中,对于 R100 \mathbb{R}^{100} 中由五个高斯分布组成的 0.5-分离混合模型,PCA 投影到 10 维时几乎所有簇都塌缩了,而随机投影保持了分离性。21 反过来,在有监督学习实验中,随机投影的预测表现不如 PCA,25 并且随机化 PCA 在多个数据集和分类器上的下游分类中产生了比随机投影更好的降维效果。23 一个实用的经验法则是:当 d>100,000 d > 100{,}000 且期望的 k>500 k > 500 时使用随机投影;否则 PCA 或 SVD 近似可能更合适。24

稀疏性是该方法本身的主要风险。稀疏投影矩阵通常会使稀疏向量产生失真;在极端情况下,如果矩阵和向量都非常稀疏,乘积可能为零,然而稀疏约翰逊–林登施特劳斯变换可以在每列只有 O(ε) 比例非零元素的矩阵下保持成对距离。7 • 31 用稀疏随机投影矩阵投影稀疏数据可能引入显著失真,损害下游精度;在稠密数据实验中,非常稀疏的投影表现不如高斯、阿赫利奥普塔斯、SRHT 和 CountSketch 投影,尽管它们在稠密 MNIST 上表现良好。19 当人类可视化很重要时,随机投影也不适用:重建图像在视觉上比 DCT 压缩图像更差。15 ℓ1 \ell_{1} 范数不合适;ℓ2 \ell_{2} 才是合适的范数。1 在低维数据上,该方法几乎没有意义,正如 scikit-learn 文档针对 64 特征的 digits 数据集所指出的。8

该界本质上是紧的:阿隆(Alon)表明,对于距离范围在 [1,1+ε2] [1, 1+\varepsilon^{2}] 的点集,O(log⁡n/ε2) O(\log n/\varepsilon^{2}) 维是必要的,4 而拉森(Larsen)与纳尔逊将这一点加强为:对于任何失真为 1+ε 1+\varepsilon 的线性映射,有 m=Ω(min⁡{n,ε−2lg⁡N}) m = \Omega(\min\{n, \varepsilon^{-2}\lg N\}) 。3 关于 JL 维度紧确界的拉森–纳尔逊猜想此后已被肯定解决:最优目标维度为 r≤C⋅min⁡{d, n−1, log⁡(2+ε2n)/ε2} r \le C \cdot \min\{d,\ n-1,\ \log(2+\varepsilon^{2}n)/\varepsilon^{2}\} ,可由一个线性映射达到,并与一个即使对非线性嵌入也成立的下界相匹配。26 在稀疏性方面,霍格斯高(Høgsgaard)及其同事在 d=o(n) d = o(n) 时实现了每列 s=O(ε−1(ln⁡n/ln⁡(1/ε)+ln⁡2/3n ln⁡1/3d)) s = O(\varepsilon^{-1}(\ln n/\ln(1/\varepsilon) + \ln^{2/3} n \, \ln^{1/3} d)) 个非零元素,改进了凯恩–纳尔逊的 s=O(ε−1ln⁡n) s = O(\varepsilon^{-1}\ln n) ,并将匹配下界加强为在 d≪n d \ll n 时也成立。27 非线性随机投影的理论,包括随机傅里叶特征、随机厨房水槽和极限学习机等随机特征方法,不如线性理论成熟。1 • 28 JL 距离保持与可用于推断的几何之间的差距,引理本身尚未量化:一个投影可以满足 JL 界,而当 log⁡n≪m≪d \log n \ll m \ll d 时,最近邻排名的平均肯德尔(Kendall)相关会消失。29

References

  1. Johnson-Lindenstrauss Lemma, Linear and Nonlinear Random Projections, Random Fourier Features, and Random Kitchen Sinks: Tutorial and Survey (Ghojogh et al., arXiv 2108.04172)
  2. Dimension Reduction and the JL Lemma (CMU 15-850 lecture notes)
  3. The Johnson-Lindenstrauss Lemma Is Optimal for Linear Dimensionality Reduction (Larsen & Nelson, ICALP 2016)
  4. An elementary proof of a theorem of Johnson and Lindenstrauss (Dasgupta & Gupta, Random Structures & Algorithms 22:60–65, 2002/2003)
  5. Database-friendly random projections: Johnson-Lindenstrauss with binary coins (Journal of Computer and System Sciences, 2003)
  6. 8.6. Random Projection, scikit-learn documentation
  7. Faster Dimension Reduction (Ailon & Chazelle, Communications of the ACM 53(2):97–104, 2010)
  8. The Johnson-Lindenstrauss bound for embedding with random projections (scikit-learn example)
  9. Dimension Reduction – The Johnson-Lindenstrauss (JL) Lemma (Sariel Har-Peled, book chapter)
  10. L13: Dimensionality Reduction: Johnson-Lindenstrauss Random Projections (Utah CS 6966, Jeff M. Phillips)
  11. The Johnson-Lindenstrauss lemma and the sphericity of some graphs (Journal of Combinatorial Theory Series B, 1988)
  12. Sanjoy Dasgupta, Anupam Gupta (2002). An elementary proof of a theorem of Johnson and Lindenstrauss. Random Structures and Algorithms.
  13. The Random Projection Method (Santosh S. Vempala, DIMACS vol. 65, chosen chapters)
  14. Jiří Matoušek (2008). On variants of the Johnson–Lindenstrauss lemma. Random Structures and Algorithms.
  15. Random projection in dimensionality reduction: applications to image and text data (Bingham & Mannila, KDD 2001)
  16. The Fast Johnson–Lindenstrauss Transform and Approximate Nearest Neighbors (Ailon & Chazelle, SIAM J. Computing 39(1):302–322, 2009; STOC 2006)
  17. Daniel M. Kane, Jelani Nelson (2014). Sparser Johnson-Lindenstrauss Transforms. Journal of the ACM.
  18. A Sparse Johnson-Lindenstrauss Transform Using Fast Hashing (ICALP 2023)
  19. Training neural networks on high-dimensional data using random projection (Pattern Analysis and Applications)
  20. Felix Krahmer, Rachel Ward (2011). New and Improved Johnson–Lindenstrauss Embeddings via the Restricted Isometry Property. SIAM Journal on Mathematical Analysis.
  21. Experiments with Random Projection (Dasgupta, UAI 2000)
  22. Simple, unified analysis of Johnson-Lindenstrauss with applications (arXiv 2402.10232, 2024)
  23. Projecting "better than randomly": How to reduce the dimensionality of very large datasets in a way that outperforms random projections (arXiv 1901.00630)
  24. Data Mining book chapter 16: Random Projections (Jeff M. Phillips)
  25. Experiments with random projections for machine learning (ACM DL record)
  26. Jain, Vishesh (2026). The Sharp Dimension Bound in the Johnson--Lindenstrauss Lemma. arXiv (Cornell University).
  27. Høgsgaard, Mikael Møller and colleagues (2023). Sparse Dimensionality Reduction Revisited. arXiv (Cornell University).
  28. Guang-Bin Huang, Qin-Yu Zhu, Chee-Kheong Siew (2006). Extreme learning machine: Theory and applications. Neurocomputing.
  29. Exact Limits of Random Projections for Preserving Geometry: Distance Recovery, Nearest-Neighbor Rankings, and Covariance Shape in Gaussian Models (arXiv preprint)
  30. stat.ethz.ch
  31. Sparser Johnson-Lindenstrauss Transforms

Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Sep 30, 2026

© 2026 Biostate AI。依据 Edgepedia Community License,注明出处即可免费使用。 嵌入参考卡片。

报告错误

随机投影

请至少选择一个原因。