sklearn TSNE 降维向量问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
armorsmith

sklearn TSNE 降维向量问题

  •  
  •   armorsmith Jul 6, 2017 4523 views
    This topic created in 3217 days ago, the information mentioned may be changed or developed.

    现在手里有 360w 个 200 维向量,存放在 np.array 里,想把这些向量降维到二维然后投影出来,观察聚类情况。 使用 TSNE 的时候,出现问题,会卡住,过一段时间自动 kill 掉,但是如果用低维小数据测试则可以正常运行。

    请问是不是数据太大,是否应该在训练时就调低向量维度?或者除 TSNE 外其他适合实现该数据降维的轮子。 环境为 python3.5,osx

    15 replies    2017-07-06 22:20:00 +08:00
    menc
        1
    menc  
       Jul 6, 2017
    想要没有性能问题和内存问题,请不要用 sklearn,效率极差。
    手写一个就好
    livc
        2
    livc  
       Jul 6, 2017
    一个向量一个向量降就可以了吧
    armorsmith
        3
    armorsmith  
    OP
       Jul 6, 2017
    @menc QAQ,这么残忍的么
    armorsmith
        4
    armorsmith  
    OP
       Jul 6, 2017
    @livc 现在的想法是一方面用 doc2vec 做句向量,一方面把 360w 个循环进行均值,取最后 3w 个左右结果,然后再做,目前的话切片之后跑个万条是没问题的
    Morriaty
        5
    Morriaty  
       Jul 6, 2017
    200 维这么整,是 w2v 的结果?

    没用过 tsne,输入可以是稀疏矩阵或者生成器吗
    EmdeBoas
        6
    EmdeBoas  
       Jul 6, 2017
    试试 pca 或者用 SPSS 做主成分分析...
    billgreen1
        7
    billgreen1  
       Jul 6, 2017
    换个大内存的机器跑吧
    armorsmith
        8
    armorsmith  
    OP
       Jul 6, 2017
    @EmdeBoas 好哒,这就去这就去
    armorsmith
        9
    armorsmith  
    OP
       Jul 6, 2017
    @Morriaty 是 word2vec,这个是抓取的部分社交网站用户的发言,之后做的向量化,输入是 np.array
    armorsmith
        10
    armorsmith  
    OP
       Jul 6, 2017
    @billgreen1 跑不动了....我选择向量加一加,数量级降下来再跑,应该还是对数据集有代表性的吧?
    RustingSword
        11
    RustingSword  
       Jul 6, 2017
    应该是内存扛不住了。
    不过就算能跑出来,360w 也没法看吧,可以采样一部分比较重要的词做降维,比如可以按 embedding 向量的范数排序,选最大的几千个先看看。
    另外如果要用 python 来搞,https://github.com/DmitryUlyanov/Multicore-TSNE 比 sklearn 的效率会高很多。
    armorsmith
        12
    armorsmith  
    OP
       Jul 6, 2017
    @RustingSword 好哒!谢谢大佬!很有用!
    ijustdo
        13
    ijustdo  
       Jul 6, 2017
    滑窗 归一 然后有中间步骤的话 记得每部 保存磁盘序列化对象
    成本最小的是加内存 妈的 昨天晚上刚跑了 8600w+

    我是每个 100w 然后结果再下一步 呵呵 然后多进程
    ruoyu0088
        14
    ruoyu0088  
       Jul 6, 2017
    TSNE 的文档,建议使用 PCA 或 TruncatedSVD 降维

    It is highly recommended to use another dimensionality reduction method (e.g. PCA for dense data or TruncatedSVD for sparse data) to reduce the number of dimensions to a reasonable amount (e.g. 50) if the number of features is very high.
    aaronzjw
        15
    aaronzjw  
       Jul 6, 2017
    估计 sklearn 吃不消的
    About     Help     Advertise     Blog     API     FAQ     Solana     4961 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 47ms UTC 04:01 PVG 12:01 LAX 21:01 JFK 00:01
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86