t-sne降维:(例,降为2维)
from sklearn.manifold import TSNE
input_vector = [[1,2,3...], [3,4,5....],....]
tsne = TSNE(n_components=2)
tsne.fit_transform(input_vector)
2d_vector = tsne.embedding_
可以画出低维散点图:
import matplotlib.pyplot as plt
x = map(lambda xy: xy[0], 2d_vector)
y = map(lambda xy: xy[1], 2d_vector)
c = map(lambda x: 1 if(x[0] > 1) else 0, result_vec)
plt.scatter(x, y,s=1, c=c)
plt.show()
image.png
网友评论