繁体   English   中英

如何基于较小的矩阵创建矩阵?

[英]How can I create a matrix based on smaller matrices?

我正在尝试以快速有效的方式创建一个基于1xN矩阵的矩阵,以便以后用作scikit-learn训练中的特征。 到目前为止,我一直在尝试的很多事情之一是:

np.matrix(list(func(text) for text in data_test.data))

这创建了一个矩阵矩阵,如下所示:

matrix([[ <1x188796 sparse matrix of type '<type 'numpy.float64'>'
    with 10921 stored elements in Compressed Sparse Row format>,
         <1x188796 sparse matrix of type '<type 'numpy.float64'>'
    with 17651 stored elements in Compressed Sparse Row format>,
         <1x188796 sparse matrix of type '<type 'numpy.float64'>'
    with 28180 stored elements in Compressed Sparse Row format>,...

显然,这不是我正在寻找的。 我怎样才能将它变成一个更合适的矩阵,如下:

<76002x108800 sparse matrix of type '<type 'numpy.float64'>'
with 807960 stored elements in Compressed Sparse Row format>

怎么样http://docs.scipy.org/doc/scipy-dev/reference/generated/scipy.sparse.vstack.html

如果这太慢了,请从这里开始快速路径: https//github.com/scipy/scipy/blob/master/scipy/sparse/construct.py#L396 (在未来的Scipy版本中, vstack本身会很​​快案件)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM