recbole.utils.case_study¶
- recbole.utils.case_study.full_sort_scores(uid_series, model, test_data, device=None)[source]¶
Calculate the scores of all items for each user in uid_series.
Note
The score of [pad] and history items will be set into -inf.
- Parameters
uid_series (numpy.ndarray or list) – User id series.
model (AbstractRecommender) – Model to predict.
test_data (FullSortEvalDataLoader) – The test_data of model.
device (torch.device, optional) – The device which model will run on. Defaults to
None
. Note:device=None
is equivalent todevice=torch.device('cpu')
.
- Returns
the scores of all items for each user in uid_series.
- Return type
torch.Tensor
- recbole.utils.case_study.full_sort_topk(uid_series, model, test_data, k, device=None)[source]¶
Calculate the top-k items’ scores and ids for each user in uid_series.
Note
The score of [pad] and history items will be set into -inf.
- Parameters
uid_series (numpy.ndarray) – User id series.
model (AbstractRecommender) – Model to predict.
test_data (FullSortEvalDataLoader) – The test_data of model.
k (int) – The top-k items.
device (torch.device, optional) – The device which model will run on. Defaults to
None
. Note:device=None
is equivalent todevice=torch.device('cpu')
.
- Returns
topk_scores (torch.Tensor): The scores of topk items.
topk_index (torch.Tensor): The index of topk items, which is also the internal ids of items.
- Return type
tuple