1、定义
2、API
ex_1
from sklearn.decomposition import PCA
def pca_demo():
'''
pca降维
'''
data = [[2,3,4,5],[6,3,0,8],[5,4,9,1]]
#实例化一个转换器类
# 4列,4个特征,降为两个特征
transfer = PCA(n_components=2) #或者传入0.95,即保留95%的特征
data_new = transfer.fit_transform(data)
print("data_new: \n", data_new)
return None