Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

您好,请问您论文中的T-sne图如何实现呢? #15

Open
Wt197012 opened this issue May 17, 2023 · 5 comments
Open

您好,请问您论文中的T-sne图如何实现呢? #15

Wt197012 opened this issue May 17, 2023 · 5 comments

Comments

@Wt197012
Copy link

想复现一些您的结果,但T-sne图像之前没接触过,能指导一下吗,谢谢!!

@Yunfan-Li
Copy link
Owner

我tSNE可视化用的是sklearn包 https://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html

@Wt197012
Copy link
Author

谢谢!请问是将输出的特征与标签放入制作还是用图像呢?谢谢您!

@liwei1101
Copy link

您好 请问可以开源一下您的t-Sne可视化代码吗?不是很会T-Sne

@Yunfan-Li
Copy link
Owner

您好,下面是tSNE可视化的代码,X和Y分别对应样本特征和标签,供参考

from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors


def tSNE(X, Y):
    colors = list(mcolors.TABLEAU_COLORS.keys())
    print('=======Performing TSNE=======')
    X_embedded = TSNE(n_components=2).fit_transform(X)
    plt.figure()
    N = X_embedded.shape[0]
    for i in range(N):
        label = Y[i].item()
        plt.scatter(X_embedded[i][0], X_embedded[i][1], color=mcolors.TABLEAU_COLORS[colors[label]], s=0.1)
    plt.savefig('tSNE.png')
    print('Finished')

@liwei1101
Copy link

您好,下面是tSNE可视化的代码,X和Y分别对应样本特征和标签,供参考

from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors


def tSNE(X, Y):
    colors = list(mcolors.TABLEAU_COLORS.keys())
    print('=======Performing TSNE=======')
    X_embedded = TSNE(n_components=2).fit_transform(X)
    plt.figure()
    N = X_embedded.shape[0]
    for i in range(N):
        label = Y[i].item()
        plt.scatter(X_embedded[i][0], X_embedded[i][1], color=mcolors.TABLEAU_COLORS[colors[label]], s=0.1)
    plt.savefig('tSNE.png')
    print('Finished')

好的!谢谢您

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants