6
我有两个csr_matrix
,uniFeature
和biFeature
。如何连接Python中的两个矩阵?
我想要一个新的矩阵Feature = [uniFeature, biFeature]
。但是,如果我以这种方式直接连接它们,那么表示矩阵Feature
是一个列表。我怎样才能实现矩阵连接,并仍然得到相同类型的矩阵,即csr_matrix
?
而且如果我这样做了连接后它不工作:Feature = csr_matrix(Feature)
它给人的错误:
Traceback (most recent call last):
File "yelpfilter.py", line 91, in <module>
Feature = csr_matrix(Feature)
File "c:\python27\lib\site-packages\scipy\sparse\compressed.py", line 66, in __init__
self._set_self(self.__class__(coo_matrix(arg1, dtype=dtype)))
File "c:\python27\lib\site-packages\scipy\sparse\coo.py", line 185, in __init__
self.row, self.col = M.nonzero()
TypeError: __nonzero__ should return bool or int, returned numpy.bool_
非常感谢!正是我需要的 –
我得到这个错误: TypeError:vstack()得到了一个意想不到的关键字参数“格式” – Moh
已解决:问题是: 而不是导入scipy.parse模块,我已经导入scipy – Moh