【发布时间】:2014-10-08 23:34:14
【问题描述】:
很难用谷歌搜索或摆弄解释器来找出括号内的这个东西是什么。这是上下文中的代码:
from matplotlib.mlab import PCA as mlabPCA
mlab_pca = mlabPCA(all_samples.T)
print('PC axes in terms of the measurement axes'\
' scaled by the standard deviations:\n',\
mlab_pca.Wt)
plt.plot(mlab_pca.Y[0:20,0],mlab_pca.Y[0:20,1], 'o', markersize=7,\
color='blue', alpha=0.5, label='class1')
plt.plot(mlab_pca.Y[20:40,0], mlab_pca.Y[20:40,1], '^', markersize=7,\
color='red', alpha=0.5, label='class2')
plt.xlabel('x_values')
plt.ylabel('y_values')
plt.xlim([-4,4])
plt.ylim([-4,4])
plt.legend()
plt.title('Transformed samples with class labels from matplotlib.mlab.PCA()')
plt.show()
我试着制作一个像这样的二维数组
a = [[1,2],[1,2],[1,2],[1,2],[1,2]]
和评估
a[0:2,0]
但这并没有给我任何东西。谢谢!
代码取自“使用 matplotlib.mlab 库中的 PCA() 类”部分中的 http://sebastianraschka.com/Articles/2014_pca_step_by_step.html。
【问题讨论】: