内容简介:[TOC]$X:n \times p$协方差矩阵: $\Sigma=Cov(X,X)\geq 0$.$\Gamma =e^T\Sigma e$ 正定矩阵对角化
PCA
[TOC]
一般原理
记号
$X:n \times p$协方差矩阵: $\Sigma=Cov(X,X)\geq 0$.
$\Gamma =e^T\Sigma e$ 正定矩阵对角化
$\Sigma = e\Gamma e^T=\sum_i\lambda_ie_ie_i^T.$ 谱分解形式
主成分 $i$-PC: $Y_i=Xe_i$. PCs: $Y=Xe$. ($e$: 特征向量/负载)
PC 定义
$\max Var Y_i, Y_i=Xl_i$,
$|l_i|=1, Cov(Y_i, Y_k)=0$
定理
(1) 的解是$\Gamma =e^T\Sigma e$ (正定矩阵对角化)
证明. (略)
百分比定义(contribution)
特征值:
$\lambda_i=Var(Y_i)=e_i^T\Sigma e_i$
百分比,累计百分比
$\frac{\lambda_k}{\sum_i\lambda_i}$,
$\frac{\sum_{i\leq m}\lambda_i}{\sum_i\lambda_i}$.
相关系数矩阵*
相关系数矩阵:即标准化
相关系数矩阵: $\rho=corr(X,X)\geq 0$. $\rho =e^T\Sigma e$.
百分比: $\frac{\lambda_i}{p},\frac{\sum_i\lambda_i}{p}$.
注 特征值和百分比会受标准化影响
样本PCA, Y估计
PCA算法
- 观察值$x\sim X$
- 计算样本协方差$\hat{S}=Cov(x,x)$
-
计算$\hat{e}, \Gamma =\hat{e}^T \hat{S} \hat{e}$,作为$e$的估计,变换得到$\hat{Y}=x\hat{e}$,以及
百分比估计
$\frac{\hat{\lambda}_k}{\sum_i\hat{\lambda}_i}$,
$\frac{\sum_{i\leq m}\hat{\lambda}_i}{\sum_i\hat{\lambda}_i}$.
Python 实现
# implement with scikit-learn import numpy as np from sklearn.decomposition import PCA X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]]) pca = PCA(n_components=2) pca.fit(X) PCA(copy=True, iterated_power='auto', n_components=2, random_state=None, svd_solver='auto', tol=0.0, whiten=False) print(pca.explained_variance_ratio_) # lambda_i / sum_i lambda_i [0.9924... 0.0075...] print(pca.singular_values_) # sigma_i (sqrt lambda_i) [6.30061... 0.54980...] pca.components_ # the pcs (sorted by lambda_i)
# data: n X p - array # not standardized, not normalized # data: Variables in columns, observations in rows from statsmodels.multivariate.pca import PCA pc = PCA(data, ncomp=p, standardize=False, normalize=False) # Y=Xe # pc.loadings: e^ # pc.factors: Y^ # pc.factors == data (demean) * pc.loadings # pc.coeff = pc.loadings ^ -1 # principle of matrix analysis: U S V' = D U, s, V = LA.svd(np.cov(data.T), full_matrices=True) # U == V PC = data @ V.T # V.T == loadings # eigenvals for lambda_i
PCA 变种
IPCA
用于大数据的PCA
ipca = IncrementalPCA(n_components=n_components, batch_size=10)
KPCA
kpca = KernelPCA(kernel="rbf", fit_inverse_transform=True, gamma=10)
SPCA
提取稀疏成分
transformer = SparsePCA(n_components=5,normalize_components=True,random_state=0)
后记
PCA的关键是估计协方差矩阵$\hat{S}$,其余是 Algebraic.
- 样本协方差估计
- 利用$X$参数分布,给出更好的无偏估计
文献
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 【每日笔记】【Go学习笔记】2019-01-04 Codis笔记
- 【每日笔记】【Go学习笔记】2019-01-02 Codis笔记
- 【每日笔记】【Go学习笔记】2019-01-07 Codis笔记
- Golang学习笔记-调度器学习
- Vue学习笔记(二)------axios学习
- 算法/NLP/深度学习/机器学习面试笔记
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Iterative Methods for Sparse Linear Systems, Second Edition
Yousef Saad / Society for Industrial and Applied Mathematics / 2003-04-30 / USD 102.00
Tremendous progress has been made in the scientific and engineering disciplines regarding the use of iterative methods for linear systems. The size and complexity of linear and nonlinear systems arisi......一起来看看 《Iterative Methods for Sparse Linear Systems, Second Edition》 这本书的介绍吧!