img_preprocess.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:CKME136 作者: asterix135 项目源码 文件源码
def visualize_data(data, labels):
    pca = RandomizedPCA(n_components=2)
    reshaped = pca.fit_transform(data)
    df = pd.DataFrame({'x': reshaped[:,0], 'y': reshaped[:, 1],
                       'label': np.where(labels == 1, 'Positive',
                                         np.where(labels == 0, 'Neutral',
                                                  'Negative'))})
    colors = ['yellow', 'red', 'blue']
    for label, color in zip(df['label'].unique(), colors):
        mask = df['label'] == label
        plt.scatter(df[mask]['x'], df[mask]['y'], c=color, label=label)
    plt.legend()
    plt.title('PCA Decomposition of Image Data')
    plt.xlabel('PCA 1')
    plt.ylabel('PCA 2')
    plt.show()
    # plt.savefig('PCA_plot.png')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号