根据规则' safe'无法将dtype(' float64')中的数组数据投射到dtype(' int64')

时间:2018-04-16 05:48:54

标签: python python-3.x data-analysis pythonplotter

def plot_pca_scatter3D(pca_values, x, y):
for name, label in [('1', 0), ('2', 1), ('3', 2), ('4', 3)]:
    ax.text3D(pca_values[y == label, 0].mean(),
              pca_values[y == label, 1].mean() + 1.5,
              pca_values[y == label, 2].mean(), name,
              horizontalalignment='center',
              bbox=dict(alpha=.5, edgecolor='w', facecolor='w'))
# Reorder the labels to have colors matching the cluster results
y = np.choose(y, [1, 2, 0]).astype(np.float)
ax.scatter(pca_values[:, 0], pca_values[:, 1], pca_values[:, 2], c=y, cmap=plt.cm.spectral,
           edgecolor='k')

ax.w_xaxis.set_ticklabels([])
ax.w_yaxis.set_ticklabels([])
ax.w_zaxis.set_ticklabels([])

plt.show()

这是我的情节分散功能。但是当我尝试执行它时。

from sklearn.decomposition import PCA
pca = PCA(n_components=300)
X_pca = pca.fit_transform(X)
plot_pca_scatter3D(X_pca, X, Y)

我收到此错误消息 根据规则' safe' ,无法将dtype(' float64')中的数组数据投射到dtype(' int64')

My datatypes:
X_pca (float 64) Size (944,300)
Y (Series object of pandas.core.series module) Size (944,)
X (dataFrame) Size (944,600)

怎么办?

0 个答案:

没有答案