From b69a235151b6ee12d36ec675daa90c016447ccee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=AA=20Trung=20Ho=C3=A0ng?= Date: Sat, 30 Dec 2023 14:00:13 +0700 Subject: [PATCH] Fix Session Popular model (#575) --- README.md | 1 + cornac/models/spop/recom_spop.py | 2 +- docs/source/api_ref/models.rst | 5 +++++ examples/README.md | 6 ++++++ examples/spop_yoochoose.py | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 221cd804..bff1c841 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/cornac/models/spop/recom_spop.py b/cornac/models/spop/recom_spop.py index 50f1795d..1910c607 100644 --- a/cornac/models/spop/recom_spop.py +++ b/cornac/models/spop/recom_spop.py @@ -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 diff --git a/docs/source/api_ref/models.rst b/docs/source/api_ref/models.rst index bbbc6a1a..91b760ef 100644 --- a/docs/source/api_ref/models.rst +++ b/docs/source/api_ref/models.rst @@ -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 diff --git a/examples/README.md b/examples/README.md index e40c9e3e..c5d298ae 100644 --- a/examples/README.md +++ b/examples/README.md @@ -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. diff --git a/examples/spop_yoochoose.py b/examples/spop_yoochoose.py index ef87d9e2..eb4f785f 100644 --- a/examples/spop_yoochoose.py +++ b/examples/spop_yoochoose.py @@ -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