Reputation: 5117
I am trying to do this:
features = csr_matrix(features)
where features
is a <class 'numpy.ndarray'>
and looks like that:
[[51 1]
[49 2]
[47 2]
...
[2 6]
[20 2]
[16 1]]
but I get the following error:
TypeError: no supported conversion for types: (dtype('O'),)
What is this error about and how can I fix it?
Upvotes: 8
Views: 8266
Reputation: 59274
You may redefine your numpy array specifying the dtype
explicitly
features = np.array(features, dtype=float)
Upvotes: 9
Reputation: 537
Do this:
csr_matrix(features.astype(np.float))
If this has an error, then you have things that aren't numbers in your features.
Upvotes: 2