Pas*_*ten 27 python numpy scipy sparse-matrix
使用SciPy/Numpy在Python中连接稀疏矩阵的最有效方法是什么?
我在这里使用了以下内容:
>>> np.hstack((X, X2))
array([ <49998x70000 sparse matrix of type '<class 'numpy.float64'>'
with 1135520 stored elements in Compressed Sparse Row format>,
<49998x70000 sparse matrix of type '<class 'numpy.int64'>'
with 1135520 stored elements in Compressed Sparse Row format>],
dtype=object)
Run Code Online (Sandbox Code Playgroud)
我想在回归中使用两个预测变量,但目前的格式显然不是我想要的.是否有可能获得以下内容:
<49998x1400000 sparse matrix of type '<class 'numpy.float64'>'
with 2271040 stored elements in Compressed Sparse Row format>
Run Code Online (Sandbox Code Playgroud)
它太大而无法转换为深层格式.
Sau*_*tro 50
你可以使用scipy.sparse.hstack:
from scipy.sparse import hstack
hstack((X, X2))
Run Code Online (Sandbox Code Playgroud)
使用numpy.hstack将创建一个包含两个稀疏矩阵对象的数组.
| 归档时间: |
|
| 查看次数: |
19661 次 |
| 最近记录: |