PCA分析方法有降噪功能,在压缩、手写体识别等场景应用,已经成为机器学习的一个必备工具。

import numpy as np
import matplotlib.pyplot as plt
#-----------------------------------------------------------------
X=np.empty((150,2))
X[:,0]=np.random.uniform(0.,150.,size=150)
X[:,1]=0.8*X[:,0]+5.+np.random.normal(0,5,size=150)
#-----------------------------------------------------------------
from sklearn.decomposition import PCA
def ReadReductionofcomponents(X):
    pca=PCA(n_components=1)
    pca.fit(X)
    x_reduction =pca.transform(X)
    x_restore=pca.inverse_transform(x_reduction)
    plt.scatter(X[:,0],X[:,1])
    plt.scatter(x_restore[:,0],x_restore[:,1])
    plt.show()
#--------------------------------------------
def ReadReductionofRatio(X):
    pca=PCA(0.96)
    pca.fit(X)
    x_reduction=pca.transform(X)
    x_restore=pca.inverse_transform(x_reduction)
    plt.scatter(X[:,0],X[:,1])
    plt.scatter(x_restore[:,0],x_restore[:,1])
    plt.show()
ReadReductionofcomponents(X)
ReadReductionofRatio(X)

Python-PCA降噪效果实例


Python-PCA降噪效果实例

Python-PCA降噪效果实例Python-PCA降噪效果实例



相关文章:

  • 2021-11-24
  • 2021-04-13
  • 2021-04-05
  • 2021-09-30
  • 2021-11-10
  • 2021-11-16
  • 2021-06-23
猜你喜欢
  • 2021-11-02
  • 2022-02-08
  • 2021-12-02
  • 2021-11-30
  • 2022-12-23
  • 2021-11-13
  • 2021-09-21
相关资源
相似解决方案