Skip to content

Commit a8887dc

Browse files
committed
Docu for ALS algorithm by implicit. Referred to the original implementation for credits.
1 parent 72beacc commit a8887dc

File tree

4 files changed

+95
-5
lines changed

4 files changed

+95
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.. automodule:: recbole.model.general_recommender.als
2+
:members:
3+
:undoc-members:
4+
:show-inheritance:
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
ALS(External algorithm library)
2+
===========
3+
4+
Introduction
5+
---------------------
6+
7+
`[ALS (implicit)] <https://benfred.github.io/implicit/api/models/cpu/als.html>`_
8+
9+
**ALS (AlternatingLeastSquares)** by implicit is a Recommendation Model based on the algorithm proposed by Koren in `Collaborative Filtering for Implicit Feedback Datasets <http://yifanhu.net/PUB/cf.pdf>`_.
10+
It furthermore leverages the finding out of `Applications of the Conjugate Gradient Method for Implicit Feedback Collaborative Filtering <https://dl.acm.org/doi/pdf/10.1145/2043932.2043987>`_ for performance optimization.
11+
`Implicit <https://benfred.github.io/implicit/index.html>`_ provides several models for implicit feedback recommendations.
12+
13+
`[paper] <http://yifanhu.net/PUB/cf.pdf>`_
14+
15+
**Title:** Collaborative Filtering for Implicit Feedback Datasets
16+
17+
**Authors:** Hu, Yifan and Koren, Yehuda and Volinsky, Chris
18+
19+
**Abstract:** A common task of recommender systems is to improve
20+
customer experience through personalized recommendations based on prior implicit feedback. These systems passively track different sorts of user behavior, such as purchase history, watching habits and browsing activity, in order to model user preferences. Unlike the much more extensively researched explicit feedback, we do not have any
21+
direct input from the users regarding their preferences. In
22+
particular, we lack substantial evidence on which products
23+
consumer dislike. In this work we identify unique properties of implicit feedback datasets. We propose treating the
24+
data as indication of positive and negative preference associated with vastly varying confidence levels. This leads to a
25+
factor model which is especially tailored for implicit feedback recommenders. We also suggest a scalable optimization procedure, which scales linearly with the data size. The
26+
algorithm is used successfully within a recommender system
27+
for television shows. It compares favorably with well tuned
28+
implementations of other known methods. In addition, we
29+
offer a novel way to give explanations to recommendations
30+
given by this factor model.
31+
32+
Running with RecBole
33+
-------------------------
34+
35+
**Model Hyper-Parameters:**
36+
37+
- ``embedding_size (int)`` : The number of latent factors to compute. Defaults to ``64``.
38+
- ``regularization (float)`` : The regularization factor to use. Defaults to ``0.01``.
39+
- ``alpha (float)`` : The weight to give to positive examples. Defaults to ``1.0``.
40+
41+
Please refer to [Implicit Python package](https://benfred.github.io/implicit/index.html) for more details.
42+
43+
**A Running Example:**
44+
45+
Write the following code to a python file, such as `run.py`
46+
47+
.. code:: python
48+
49+
from recbole.quick_start import run_recbole
50+
51+
run_recbole(model='ALS', dataset='ml-100k')
52+
53+
And then:
54+
55+
.. code:: bash
56+
57+
python run.py
58+
59+
Tuning Hyper Parameters
60+
-------------------------
61+
62+
If you want to use ``HyperTuning`` to tune hyper parameters of this model, you can copy the following settings and name it as ``hyper.test``.
63+
64+
.. code:: bash
65+
66+
regularization choice [0.01, 0.03, 0.05, 0.1]
67+
embedding_size choice [32, 64, 96, 128, 256]
68+
alpha choice [0.5, 0.7, 1.0, 1.3, 1.5]
69+
70+
Note that we just provide these hyper parameter ranges for reference only, and we can not guarantee that they are the optimal range of this model.
71+
72+
Then, with the source code of RecBole (you can download it from GitHub), you can run the ``run_hyper.py`` to tuning:
73+
74+
.. code:: bash
75+
76+
python run_hyper.py --model=[model_name] --dataset=[dataset_name] --config_files=[config_files_path] --params_file=hyper.test
77+
78+
For more details about Parameter Tuning, refer to :doc:`../../../user_guide/usage/parameter_tuning`.
79+
80+
81+
If you want to change parameters, dataset or evaluation settings, take a look at
82+
83+
- :doc:`../../../user_guide/config_settings`
84+
- :doc:`../../../user_guide/data_intro`
85+
- :doc:`../../../user_guide/train_eval_intro`
86+
- :doc:`../../../user_guide/usage`

recbole/model/general_recommender/als.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ def __init__(self, config, dataset):
4545
factors=self.embedding_size,
4646
regularization=self.regularization,
4747
alpha=self.alpha,
48-
iterations=1, # iterations are done by the trainer via epochs
48+
iterations=1, # iterations are done by the ALSTrainer via 'epochs'
4949
use_cg=True,
5050
calculate_training_loss=True,
51-
num_threads=24,
51+
num_threads=0,
5252
random_state=42
5353
)
5454

recbole/properties/model/ALS.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
regularization: 0.01
2-
embedding_size: 64
3-
alpha: 1.0
1+
regularization: 0.01 # The number of latent factors to compute
2+
embedding_size: 64 # The regularization factor to use
3+
alpha: 1.0 # The weight to give to positive examples.

0 commit comments

Comments
 (0)