def visualize_pca3D(X,y):
"""
Visualize the first three principal components
Keyword arguments:
X -- The feature vectors
y -- The target vector
"""
pca = PCA(n_components = 3)
principal_components = pca.fit_transform(X)
fig = pylab.figure()
ax = Axes3D(fig)
# azm=30
# ele=30
# ax.view_init(azim=azm,elev=ele)
palette = sea.color_palette()
ax.scatter(principal_components[y==0, 0], principal_components[y==0, 1], principal_components[y==0, 2], label="Paid", alpha=0.5,
edgecolor='#262626', c=palette[1], linewidth=0.15)
ax.scatter(principal_components[y==1, 0], principal_components[y==1, 1], principal_components[y==1, 2],label="Default", alpha=0.5,
edgecolor='#262626''', c=palette[2], linewidth=0.15)
ax.legend()
plt.show()
visualization.py 文件源码
python
阅读 36
收藏 0
点赞 0
评论 0
评论列表
文章目录