Tôi có hai số csr_matrix
, uniFeature
và biFeature
.Làm thế nào để nối hai ma trận trong Python?
Tôi muốn có ma trận mới Feature = [uniFeature, biFeature]
. Nhưng nếu tôi trực tiếp nối chúng theo cách này, có một lỗi nói rằng ma trận Feature
là một danh sách. Làm thế nào tôi có thể đạt được sự nối ma trận và vẫn nhận được cùng một loại ma trận, tức là một csr_matrix
?
Và nó không hoạt động nếu tôi làm điều này sau khi nối: Feature = csr_matrix(Feature)
Nó cung cấp cho các lỗi:
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_
Cảm ơn rất nhiều! Chính xác những gì tôi cần –
Tôi nhận được lỗi này: LoạiError: vstack() đã nhận được đối số từ khóa không mong muốn 'format' – Moh
GIẢI PHÁP: Vấn đề là: Thay vì nhập mô-đun scipy.parse, tôi đã nhập scipy – Moh