推薦システムの実行
パッケージのインストール
(recsys_full) offline$ pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124
# PyTorch2.6以上の場合、RecBoleのコードの修正が必要になる。
# ...(3分程度)...
(recsys_full) offline$ pip install ray
(recsys_full) offline$ pip install pyarrow
(recsys_full) offline$ pip install kmeans_pytorch
(recsys_full) offline$ pip install recbole
(recsys_full) offline$ pip freeze
...(略)...
absl-py==2.2.1
aiosignal==1.3.2
attrs==25.3.0
click==8.1.8
colorama==0.4.4
colorlog==4.7.2
filelock==3.13.1
frozenlist==1.5.0
fsspec==2024.6.1
grpcio==1.71.0
Jinja2==3.1.4
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
kmeans-pytorch==0.3
Markdown==3.7
MarkupSafe==2.1.5
mpmath==1.3.0
msgpack==1.1.0
narwhals==1.33.0
networkx==3.3
nvidia-cublas-cu12==12.4.5.8
nvidia-cuda-cupti-cu12==12.4.127
nvidia-cuda-nvrtc-cu12==12.4.127
nvidia-cuda-runtime-cu12==12.4.127
nvidia-cudnn-cu12==9.1.0.70
nvidia-cufft-cu12==11.2.1.3
nvidia-curand-cu12==10.3.5.147
nvidia-cusolver-cu12==11.6.1.9
nvidia-cusparse-cu12==12.3.1.170
nvidia-nccl-cu12==2.21.5
nvidia-nvjitlink-cu12==12.4.127
nvidia-nvtx-cu12==12.4.127
plotly==6.0.1
protobuf==6.30.2
pyarrow==19.0.1
PyYAML==6.0.2
ray==2.44.1
recbole==1.2.0
referencing==0.36.2
rpds-py==0.24.0
setuptools==70.2.0
sympy==1.13.1
tabulate==0.9.0
tensorboard==2.19.0
tensorboard-data-server==0.7.2
texttable==1.7.0
thop==0.1.1.post2209072238
torch==2.5.1+cu124
torchaudio==2.5.1+cu124
torchvision==0.20.1+cu124
triton==3.1.0
typing_extensions==4.12.2
Werkzeug==3.1.3
...(略)...
VSCodeの起動
(recsys_full) offline$ code .
推薦処理プログラムの準備
- 下記ファイルをダウンロードし、
offline/src/
ディレクトリに移動する。- recsyslab / recsys-full / src / offline / src /
recommenders/__init__.py
recommenders/base_recommender.py
recommenders/bpr_recommender.py
recommenders/movies_movies_recommender.py
recommenders/pupularity_recommender.py
utils/__init__.py
utils/dataset.py
utils/recommend_result.py
config.yaml
offline.ini
update.py
- recsyslab / recsys-full / src / offline / src /
(recsys_full) offline$ tree src/
src/
├── config.yaml # <-
├── keygen.py
├── ml2rdb.py
├── offline.ini # <-
├── recommenders # <-
│ ├── __init__.py # <-
│ ├── base_recommender.py # <-
│ ├── bpr_recommender.py # <-
│ ├── movies_movies_recommender.py # <-
│ └── popularity_recommender.py # <-
├── update.py # <-
├── user2encrypt.py
└── utils # <-
├── __init__.py # <-
├── dataset.py # <-
└── recommend_result.py # <-
3 directories, 14 files
推薦システムの実行
(recsys_full) offline$ cd src/
(recsys_full) offline/src$ python update.py --ini offline.ini
processing Dataset.to_rating_matrix: 100%|█████████████████████| 100836/100836 [00:02<00:00, 48964.62it/s]
processing Dataset.to_movies_movies_similarity_matrix: 100%|██████████| 9742/9742 [19:58<00:00, 8.13it/s]
processing PopularityRecommender.recommend: 100%|████████████████████████| 20/20 [00:00<00:00, 302.71it/s]
processing MoviesMoviesRecommender.recommend: 100%|█████████████████| 9742/9742 [00:02<00:00, 3700.48it/s]
processing BPRRecommender.recommend: 100%|█████████████████████████████| 611/611 [00:02<00:00, 215.14it/s]
elapsed_time:1355.972[sec]
# ...(25分程度)...
結果の確認
(recsys_full) offline/src$ cd ../
(recsys_full) offline$ tree data/
data/
├── genres.csv
├── ml-latest-small
│ ├── README.txt
│ ├── links.csv
│ ├── movies.csv
│ ├── ratings.csv
│ └── tags.csv
├── ml-ls.inter # <-
├── ml-ls.item # <-
├── ml-ls.user # <-
├── ml-rdb
│ ├── genres.csv
│ ├── links.csv
│ ├── movies.csv
│ ├── movies_genres.csv
│ ├── ratings.csv
│ ├── tags.csv
│ └── users.csv
├── movies.csv
├── movies_genres.csv
├── movies_movies_similarity_matrix.csv # <-
├── rating_matrix.csv # <-
├── ratings.csv
├── reclist_bpr.csv # <-
├── reclist_movies_movies.csv # <-
├── reclist_popularity.csv # <-
├── tags.csv
├── users.csv
└── users_.csv
3 directories, 27 files
(recsys_full) offline$ cd data/
(recsys_full) offline/data$
less rating_matrix.csv
less movies_movies_similarity_matrix.csv
less ml-ls.inter
less ml-ls.item
less ml-ls.user
less reclist_popularity.csv
less reclist_movies_movies.csv
less reclist_bpr.csv
参考
- 風間正弘,飯塚洸二郎,松村優也,『著推薦システム実践入門 ―仕事で使える導入ガイド』,オライリー・ジャパン,2022.
- 与謝秀作,『特集3 最新レコメンドエンジン総実装 協調フィルタリングから深層学習まで』,WEB+DB PRESS Vol.129,pp.69-100,技術評論社,2022.
- [🐛BUG] Wrong number of users and items in datasets information · Issue #1516 · RUCAIBox/RecBole
- RecBole v1.2.0 — RecBole 1.2.0 documentation