Name | elsarec JSON |
Version |
0.1.4
JSON |
| download |
home_page | |
Summary | Scalable Linear Shallow Autoencoder for Collaborative Filtering |
upload_time | 2023-07-30 05:42:07 |
maintainer | |
docs_url | None |
author | Recombee |
requires_python | >=3.7 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
# ELSA
This is an official implementation of our paper [Scalable Linear Shallow Autoencoder for Collaborative Filtering](https://dl.acm.org/doi/10.1145/3523227.3551482).
### Requirements
PyTorch in version >=10.1 (along with compatible [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads)) must be installed in the system. If not, one can install [PyTorch](https://pytorch.org/get-started/locally/) with
```
pip install torch==1.10.2+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
```
## Instalation
ELSA can be installed from [pypi](https://pypi.org/project/elsarec/) with:
```
pip install elsarec
```
## Basic usage
```python
from elsa import ELSA
import torch
import numpy as np
device = torch.device("cuda")
X_csr = ... # load your interaction matrix (scipy.sparse.csr_matrix with users in rows and items in columns)
X_test = ... # load your test data (scipy.sparse.csr_matrix with users in rows and items in columns)
items_cnt = X_csr.shape[1]
factors = 256
num_epochs = 5
batch_size = 128
model = ELSA(n_items=items_cnt, device=device, n_dims=factors)
model.fit(X_csr, batch_size=batch_size, epochs=num_epochs)
# save item embeddings into np array
A = torch.nn.functional.normalize(model.get_items_embeddings(), dim=-1).cpu().numpy()
# get predictions in PyTorch
predictions = model.predict(X_test, batch_size=batch_size)
# get predictions in numpy
predictions = ((X_test @ A) @ (A.T)) - X_test
# find related items for a subset of items
itemids = np.array([id1, id2, ...]) # id1, id2 are indices of items in the X_csr
related = model.similar_items(N=100, batch_size=128, sources=itemids)
```
## Notes
### Reproducibility
Instructions for reproducing the results from the paper on the MovieLens20M dataset are in the branch `reproduce_movielens` https://github.com/recombee/ELSA/tree/reproduce_movielens.
Reproducibility instructions for Netflix and Goodbooks10k datasets will follow soon.
### Tensorflow users
We decided to implement ELSA in PyTorch, but implementation in TensorFlow is simple and straightforward. One can, for example, implement ELSA as a Keras layer:
```python
class ELSA(tf.keras.layers.Layer):
def __init__(self, latent, nr_of_items):
super(ELSA, self).__init__()
w_init = tf.keras.initializers.HeNormal()
self.A = tf.Variable(
initial_value=w_init(shape=(nr_of_items, latent), dtype="float32"),
trainable=True,
)
def get_items_embeddings(self):
A = tf.math.l2_normalize(self.A, axis=-1)
return A.numpy()
@tf.function
def call(self, x):
A = tf.math.l2_normalize(self.A, axis=-1)
xA = tf.matmul(x, A, transpose_b=False)
xAAT = tf.matmul(xA, A, transpose_b=True)
return xAAT - x
```
### Licence
[MIT licence](https://github.com/recombee/ELSA/blob/main/LICENCE)
### Troubleshooting
If you encounter a problem or have a question about ELSA, do not hesitate to create an issue and ask. In case of an implementation problem, please include the Python, PyTorch and CUDA versions in the description of the issue.
### Cite us
Please consider citing our paper:
```
@inproceedings{10.1145/3523227.3551482,
author = {Van\v{c}ura, Vojt\v{e}ch and Alves, Rodrigo and Kasalick\'{y}, Petr and Kord\'{\i}k, Pavel},
title = {Scalable Linear Shallow Autoencoder for Collaborative Filtering},
year = {2022},
isbn = {9781450392785},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3523227.3551482},
doi = {10.1145/3523227.3551482},
abstract = {Recently, the RS research community has witnessed a surge in popularity for shallow autoencoder-based CF methods. Due to its straightforward implementation and high accuracy$
booktitle = {Proceedings of the 16th ACM Conference on Recommender Systems},
pages = {604–609},
numpages = {6},
keywords = {Linear models, Shallow autoencoders, Implicit feedback recommendation},
location = {Seattle, WA, USA},
series = {RecSys '22}
}
```
Raw data
{
"_id": null,
"home_page": "",
"name": "elsarec",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Recombee",
"author_email": "vojtech.vancura@recombee.com",
"download_url": "https://files.pythonhosted.org/packages/a7/d4/7acf4071cf6031de21109d155d99d4491f8328174bd959e93dc3fff345ee/elsarec-0.1.4.tar.gz",
"platform": null,
"description": "[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n# ELSA\n\nThis is an official implementation of our paper [Scalable Linear Shallow Autoencoder for Collaborative Filtering](https://dl.acm.org/doi/10.1145/3523227.3551482).\n\n### Requirements\n\nPyTorch in version >=10.1 (along with compatible [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads)) must be installed in the system. If not, one can install [PyTorch](https://pytorch.org/get-started/locally/) with \n```\npip install torch==1.10.2+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113\n```\n\n## Instalation\n\nELSA can be installed from [pypi](https://pypi.org/project/elsarec/) with:\n\n```\npip install elsarec\n```\n\n## Basic usage\n\n```python\nfrom elsa import ELSA\nimport torch\nimport numpy as np\n\ndevice = torch.device(\"cuda\")\n\nX_csr = ... # load your interaction matrix (scipy.sparse.csr_matrix with users in rows and items in columns)\nX_test = ... # load your test data (scipy.sparse.csr_matrix with users in rows and items in columns)\n\nitems_cnt = X_csr.shape[1]\nfactors = 256 \nnum_epochs = 5\nbatch_size = 128\n\nmodel = ELSA(n_items=items_cnt, device=device, n_dims=factors)\n\nmodel.fit(X_csr, batch_size=batch_size, epochs=num_epochs)\n\n# save item embeddings into np array\nA = torch.nn.functional.normalize(model.get_items_embeddings(), dim=-1).cpu().numpy()\n\n# get predictions in PyTorch\npredictions = model.predict(X_test, batch_size=batch_size)\n\n# get predictions in numpy\npredictions = ((X_test @ A) @ (A.T)) - X_test\n\n# find related items for a subset of items\nitemids = np.array([id1, id2, ...]) # id1, id2 are indices of items in the X_csr\nrelated = model.similar_items(N=100, batch_size=128, sources=itemids)\n```\n\n## Notes\n\n### Reproducibility\n\nInstructions for reproducing the results from the paper on the MovieLens20M dataset are in the branch `reproduce_movielens` https://github.com/recombee/ELSA/tree/reproduce_movielens.\n\nReproducibility instructions for Netflix and Goodbooks10k datasets will follow soon.\n\n### Tensorflow users\n\nWe decided to implement ELSA in PyTorch, but implementation in TensorFlow is simple and straightforward. One can, for example, implement ELSA as a Keras layer:\n\n```python\nclass ELSA(tf.keras.layers.Layer):\n def __init__(self, latent, nr_of_items):\n super(ELSA, self).__init__()\n w_init = tf.keras.initializers.HeNormal()\n self.A = tf.Variable(\n initial_value=w_init(shape=(nr_of_items, latent), dtype=\"float32\"),\n trainable=True,\n )\n \n def get_items_embeddings(self):\n A = tf.math.l2_normalize(self.A, axis=-1)\n return A.numpy()\n \n @tf.function\n def call(self, x):\n A = tf.math.l2_normalize(self.A, axis=-1)\n xA = tf.matmul(x, A, transpose_b=False)\n xAAT = tf.matmul(xA, A, transpose_b=True)\n return xAAT - x\n```\n\n### Licence\n[MIT licence](https://github.com/recombee/ELSA/blob/main/LICENCE)\n\n### Troubleshooting\nIf you encounter a problem or have a question about ELSA, do not hesitate to create an issue and ask. In case of an implementation problem, please include the Python, PyTorch and CUDA versions in the description of the issue.\n\n### Cite us\n\nPlease consider citing our paper:\n\n```\n@inproceedings{10.1145/3523227.3551482,\nauthor = {Van\\v{c}ura, Vojt\\v{e}ch and Alves, Rodrigo and Kasalick\\'{y}, Petr and Kord\\'{\\i}k, Pavel},\ntitle = {Scalable Linear Shallow Autoencoder for Collaborative Filtering},\nyear = {2022},\nisbn = {9781450392785},\npublisher = {Association for Computing Machinery},\naddress = {New York, NY, USA},\nurl = {https://doi.org/10.1145/3523227.3551482},\ndoi = {10.1145/3523227.3551482},\nabstract = {Recently, the RS research community has witnessed a surge in popularity for shallow autoencoder-based CF methods. Due to its straightforward implementation and high accuracy$\nbooktitle = {Proceedings of the 16th ACM Conference on Recommender Systems},\npages = {604\u2013609},\nnumpages = {6},\nkeywords = {Linear models, Shallow autoencoders, Implicit feedback recommendation},\nlocation = {Seattle, WA, USA},\nseries = {RecSys '22}\n}\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Scalable Linear Shallow Autoencoder for Collaborative Filtering",
"version": "0.1.4",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "24b7c204bbde2db65d89044e8e9cd8d1039716fe37e85fe09abe299b664f5db2",
"md5": "2a5e1bb72c96f1e6c7429d496c0b3139",
"sha256": "240914c1212af0b58b4beb347c3e9f715bccb08e6552f576f082b7fefd81377b"
},
"downloads": -1,
"filename": "elsarec-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2a5e1bb72c96f1e6c7429d496c0b3139",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 9392,
"upload_time": "2023-07-30T05:42:06",
"upload_time_iso_8601": "2023-07-30T05:42:06.714447Z",
"url": "https://files.pythonhosted.org/packages/24/b7/c204bbde2db65d89044e8e9cd8d1039716fe37e85fe09abe299b664f5db2/elsarec-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a7d47acf4071cf6031de21109d155d99d4491f8328174bd959e93dc3fff345ee",
"md5": "f4e9ac1fe9381fac479d03dd138fe746",
"sha256": "928c372d58ddcce40bd2a1d0396815f5a2e00f7395093b3bfe2cc6242ef9bdb1"
},
"downloads": -1,
"filename": "elsarec-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "f4e9ac1fe9381fac479d03dd138fe746",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 11135,
"upload_time": "2023-07-30T05:42:07",
"upload_time_iso_8601": "2023-07-30T05:42:07.834954Z",
"url": "https://files.pythonhosted.org/packages/a7/d4/7acf4071cf6031de21109d155d99d4491f8328174bd959e93dc3fff345ee/elsarec-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-30 05:42:07",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "elsarec"
}