implicit
implicit copied to clipboard
Error with recommend(): We have not yet implemented 1D sparse slices
I'm trying to follow the tutorial and use the recommend() method, I get this error:
In [60]: uis
Out[60]:
<1000x1000 sparse array of type '<class 'numpy.intc'>'
with 499261 stored elements in Compressed Sparse Row format>
In [61]: model.recommend( 0, uis[0] )
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-61-15a94506d8dd> in <module>
----> 1 model.recommend( 0, uis[0] )
C:\usr\Miniconda3\lib\site-packages\scipy\sparse\_index.py in __getitem__(self, key)
52 return self._get_intXint(row, col)
53 elif isinstance(col, slice):
---> 54 self._raise_on_1d_array_slice()
55 return self._get_intXslice(row, col)
56 elif col.ndim == 1:
C:\usr\Miniconda3\lib\site-packages\scipy\sparse\_index.py in _raise_on_1d_array_slice(self)
39 """
40 if self._is_array:
---> 41 raise NotImplementedError(
42 'We have not yet implemented 1D sparse slices; '
43 'please index using explicit indices, e.g. `x[:, [0]]`'
NotImplementedError: We have not yet implemented 1D sparse slices; please index using explicit indices, e.g. `x[:, [0]]`
In [66]: scipy.__version__
Out[66]: '1.9.1'
It looks to me like this error is coming from going uis[0] - rather than from code inside implicit.
I think this is because you are calling with a csr_array and implicit expects a csr_matrix instead. Can you try converting with uis = scipy.sparse.csr_matrix(uis) and trying again?
I see, thanks. Scipy manual at https://docs.scipy.org/doc/scipy/reference/sparse.html recommended using the new arrays instead of matrices, I assumed they were compatible.