Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何基于较小的矩阵创建矩阵?_Python_Numpy_Scipy_Scikit Learn - Fatal编程技术网

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

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

我正试图以一种快速有效的方式创建一个基于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 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类型的稀疏矩阵”。我想将这些矩阵合并成一个大矩阵。