生活随笔
收集整理的這篇文章主要介紹了
TSNE画图
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
TSNE畫圖
2D圖
from sklearn
.manifold
import TSNE
import matplotlib
.pyplot
as plt
import numpy
as np
h
= np
.random
.randn
(10, 6)
tsne
= TSNE
(n_components
=2, init
='pca', random_state
=0)
result_2D
= tsne
.fit_transform
(h
)
s1
, s2
= result_2D
[:5, :], result_2D
[5:, :]
fig
= plt
.figure
()
t1
= plt
.scatter
(s1
[:, 0], s1
[:, 1], marker
='x', c
='r', s
=20)
t2
= plt
.scatter
(s2
[:, 0], s2
[:, 1], marker
='o', c
='b', s
=20)
plt
.xlabel
('X')
plt
.ylabel
('Y')
plt
.legend
((t1
, t2
), ('pos', 'neg'))
plt
.show
()
總結
以上是生活随笔為你收集整理的TSNE画图的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。