我正在尝试这样做:
features = csr_matrix(features)
哪里features
是 <class 'numpy.ndarray'>
看起来像这样:
[[51 1]
[49 2]
[47 2]
...
[2 6]
[20 2]
[16 1]]
但我收到以下错误:
TypeError: no supported conversion for types: (dtype('O'),)
这个错误是关于什么的,我该如何解决?
最佳答案
您可以重新定义您的 numpy 数组,明确指定 dtype
features = np.array(features, dtype=float)
关于python - 转换为稀疏矩阵 - TypeError : no supported conversion for types: (dtype ('0' ), ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57434284/