Python 如何基于较小的矩阵创建矩阵?
我正试图以一种快速有效的方式创建一个基于1xN矩阵的矩阵,以便以后在scikit学习培训中用作功能。到目前为止,我一直在尝试的许多事情之一是:Python 如何基于较小的矩阵创建矩阵?,python,numpy,scipy,scikit-learn,Python,Numpy,Scipy,Scikit Learn,我正试图以一种快速有效的方式创建一个基于1xN矩阵的矩阵,以便以后在scikit学习培训中用作功能。到目前为止,我一直在尝试的许多事情之一是: np.matrix(list(func(text) for text in data_test.data)) 它创建了一个矩阵矩阵,如下所示: matrix([[ <1x188796 sparse matrix of type '<type 'numpy.float64'>' with 10921 stored element
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>
怎么样
如果速度太慢,请从这里开始走捷径:(在未来的Scipy版本中,
vstack
本身在这种情况下会很快)。什么是func,它返回什么?@而且,它是一个自定义函数,返回“1x188796类型的稀疏矩阵”。我想将这些矩阵合并成一个大矩阵。