Skip to content

Commit

Permalink
Fix Session Popular model (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
lthoang authored Dec 30, 2023
1 parent eabdd2d commit b69a235
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ The recommender models supported by Cornac are listed below. Why don't you join
| | [Most Popular (MostPop)](cornac/models/most_pop), [paper](https://arxiv.org/ftp/arxiv/papers/1205/1205.2618.pdf) | N/A | [bpr_netflix.py](examples/bpr_netflix.py)
| | [Non-negative Matrix Factorization (NMF)](cornac/models/nmf), [paper](http://papers.nips.cc/paper/1861-algorithms-for-non-negative-matrix-factorization.pdf) | N/A | [nmf_exp.py](examples/nmf_example.py)
| | [Probabilistic Matrix Factorization (PMF)](cornac/models/pmf), [paper](https://papers.nips.cc/paper/3208-probabilistic-matrix-factorization.pdf) | N/A | [pmf_ratio.py](examples/pmf_ratio.py)
| | [Session Popular (SPop)](cornac/models/spop), [paper](https://arxiv.org/pdf/1511.06939.pdf) | N/A | [spop_yoochoose.py](examples/spop_yoochoose.py)
| | [Singular Value Decomposition (SVD)](cornac/models/svd), [paper](https://people.engr.tamu.edu/huangrh/Spring16/papers_course/matrix_factorization.pdf) | N/A | [svd_exp.py](examples/svd_example.py)
| | [Social Recommendation using PMF (SoRec)](cornac/models/sorec), [paper](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.304.2464&rep=rep1&type=pdf) | N/A | [sorec_filmtrust.py](examples/sorec_filmtrust.py)
| | [User K-Nearest-Neighbors (UserKNN)](cornac/models/knn), [paper](https://arxiv.org/pdf/1301.7363.pdf) | N/A | [knn_movielens.py](examples/knn_movielens.py)
Expand Down
2 changes: 1 addition & 1 deletion cornac/models/spop/recom_spop.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def fit(self, train_set, val_set=None):
return self

def score(self, user_idx, history_items, **kwargs):
item_scores = np.ones(self.total_items, dtype=np.float32)
item_scores = np.zeros(self.total_items, dtype=np.float32)
max_item_freq = max(self.item_freq.values()) if len(self.item_freq) > 0 else 1
for iid, freq in self.item_freq.items():
item_scores[iid] = freq / max_item_freq
Expand Down
5 changes: 5 additions & 0 deletions docs/source/api_ref/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ Probabilitic Matrix Factorization (PMF)
.. automodule:: cornac.models.pmf.recom_pmf
:members:

Session Popular (SPop)
----------------------
.. automodule:: cornac.models.spop.recom_spop
:members:

Singular Value Decomposition (SVD)
----------------------------------
.. automodule:: cornac.models.svd.recom_svd
Expand Down
6 changes: 6 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@

----

## Next-Item Algorithms

[spop_yoochoose.py](spop_yoochoose.py) - Next-item recommendation based on item popularity.

----

## Next-Basket Algorithms

[gp_top_tafeng.py](gp_top_tafeng.py) - Next-basket recommendation model that merely uses item top frequency.
Expand Down
2 changes: 1 addition & 1 deletion examples/spop_yoochoose.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""Example of a next-basket recommendation model that merely uses item top frequency"""
"""Example of a next-item recommendation model based on item popularity"""

import cornac
from cornac.datasets import yoochoose
Expand Down

0 comments on commit b69a235

Please sign in to comment.