我正在尝试获取数据索引并在PCA之后使用它?

im试图使用pca绘制3d图,但是在我获得具有标签“ -1”的数据的索引之前,尝试与标签“ 1”进行比较。但我收到此错误

import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
from mpl_toolkits.mplot3d import Axes3D
pca = PCA(n_components=3)  # Reduce to k=3 dimensions
scaler = StandardScaler()
#normalize the metrics
X = scaler.fit_transform(df_data[to_model_columns])
X_reduce = pca.fit_transform(X)
fig = plt.figure()
ax = fig.add_subplot(111,projection='3d')
ax.set_zlabel("x_composite_3")
# Plot the compressed data points
ax.scatter(X_reduce[:,0],X_reduce[:,1],2],s=4,lw=1,label="inliers",c="green")
# Plot x's for the ground truth outliers
ax.scatter(X_reduce[outlier_index,X_reduce[outlier_index,lw=2,s=60,marker="x",c="red",label="outliers")
#ax.legend()
plt.show()
yonghuzhuxiao 回答:我正在尝试获取数据索引并在PCA之后使用它?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2916409.html

大家都在问