forked from supportingvector/VAEHRRP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPCA.py
43 lines (34 loc) · 1.19 KB
/
PCA.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np
from sklearn.decomposition import PCA
from matplotlib import pyplot as plt
z1=np.load('z1.npy')
pca = PCA(n_components=2)
pcaz1=pca.fit_transform(z1)
# PCA(copy=True, n_components=2, whiten=False)
print(pca.explained_variance_ratio_)
print(sum(pca.explained_variance_ratio_))
z2=np.load('z2.npy')
pca = PCA(n_components=2)
pcaz2=pca.fit_transform(z2)
# PCA(copy=True, n_components=2, whiten=False)
print(pca.explained_variance_ratio_)
print(sum(pca.explained_variance_ratio_))
z3=np.load('z3.npy')
pca = PCA(n_components=2)
pcaz3=pca.fit_transform(z3)
# PCA(copy=True, n_components=2, whiten=False)
print(pca.explained_variance_ratio_)
print(sum(pca.explained_variance_ratio_))
plt.scatter(pcaz1[:,0], pcaz1[:,1], s=10,marker='o',c='',edgecolors='y')
plt.scatter(pcaz2[:,0], pcaz2[:,1], s=20,marker='o',c='',edgecolors='r')
plt.scatter(pcaz3[:,0], pcaz3[:,1], s=20,c='b',marker='x')
#
plt.show()
#fig=plt.figure()
#ax=fig.add_subplot(111,projection='3d')
#ax.scatter(pcaz1[:,0], pcaz1[:,1],pcaz1[:,2],c='b')
#ax.scatter(pcaz1[:,0], pcaz1[:,1],pcaz1[:,2],c='r')
#ax.scatter(pcaz1[:,0], pcaz1[:,1],pcaz1[:,2],c='k')
#plt.show()