### SVD的一些理解

PCA一章結束后，書中介紹了SVD，中文名為奇異值分解，全稱singular value decomposition，是一種針對矩陣分解的方法。

“we can see it as a method for transforming correlated variables into a set of uncorrelated ones that better expose the various relationships among the original data items. At the same time, SVD is a method for identifying and ordering the dimensions along which data points exhibit the most variation. This ties in to the third way of viewing SVD, which is that once we have identi ed where the most variation is, it's possible to nd the best approximation of the original data points using fewer dimensions. Hence, SVD can be seen as a method for data reduction”

SVD的應用場景有很多，這里不具體的去展開，這里以圖片中的應用來直觀的解釋SVD。

PS：python代碼片段：

`from PIL import Imageimport numpy as npop=Image.open('./a.jpg').convert('L')img=np.array(op)img=img[:-30,:660]s,sigm,v=np.linalg.svd(img)print s.shape,sigm.shape,v.shapeDem=[1,2,5,10,20,50,70,100,200,500,600,660]for D in Dem:    dlg=np.diag(sigm[0:D]) #選取D個奇異值    pic_data=np.dot(s[:,0:D],dlg) #重新構造矩陣    pic_data=np.dot(pic_data,v[0:D,:])    #print type(pic_data[1][1])    im=Image.fromarray(pic_data.astype(np.uint8)) #將數據保存到圖片    filename='%s-D.jpg'%(D)    im.save(filename)`

#### 注意！

© 2014-2022 ITdaan.com 联系我们：