Skip to content

Commit

Permalink
Add exportation to scipy csr
Browse files Browse the repository at this point in the history
  • Loading branch information
shuix007 authored Nov 8, 2019
1 parent 8b21eae commit ba9f0a4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions python-package/SLIM/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,18 +549,17 @@ def predict(self, data, nrcmds=10, outfile=None, negitems=None, nnegs=0, returns
'The users in the negative items should be the same with the input matrix.'

slim_negitems = np.full(data.nUsers * nnegs, -1, dtype=np.int32)
nusers = 0

newitems = 0
for key, value in negitems.items():
assert len(value) == nnegs, \
'The number of negative items should match nngs.'
for i in range(nnegs):
try:
slim_negitems[nusers * nnegs + i] = self.item2id[value[i]]
slim_negitems[data.user2id[key] * nnegs + i] = self.item2id[value[i]]
except:
newitems += 1
nusers += 1


if newitems > 0:
print('%d negative items not in the training set.' % (newitems))

Expand Down Expand Up @@ -802,4 +801,4 @@ def _get_slim(self):
array_1d_int32_t, # indices
array_1d_float32_t # data
]
)
)

0 comments on commit ba9f0a4

Please sign in to comment.