rtrec


Namertrec JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
SummaryAn realtime recommendation system supporting online updates
upload_time2024-12-27 06:58:40
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords machine learning personalization recommendation systems recommender recsys
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            rtrec: Realtime Recommendation Library in Python
================================================

[![PyPI version](https://img.shields.io/pypi/v/rtrec.svg?logo=pypi&logoColor=FFE873)](https://pypi.org/project/rtrec/)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/rtrec.svg?logo=python&logoColor=FFE873)](https://pypi.org/project/rtrec/)
[![CI status](https://github.com/myui/rtrec/actions/workflows/ci.yml/badge.svg)](https://github.com/myui/rtrec/actions)
[![Licence](https://img.shields.io/github/license/myui/rtrec.svg)](LICENSE.txt)

An realtime recommendation system supporting online updates.

## Highlights

- ❇️ Supporting online updates.
- ⚡️ Fast implementation (>=190k samples/sec training on laptop).
- ◍ efficient sparse data support.
- 🕑 decaying weights of user-item interactions based on recency.
- ![Rust](https://avatars.githubusercontent.com/u/5430905?s=20&v=4) experimental [Rust implementation](https://github.com/myui/rtrec/tree/rust)

## Supported Recommendation Algorithims

- Sparse [SLIM](https://ieeexplore.ieee.org/document/6137254) with [time-weighted](https://dl.acm.org/doi/10.1145/1099554.1099689) interactions.
- [Factorization Machines](https://ieeexplore.ieee.org/document/5694074) using [LightFM](https://github.com/lyst/lightfm) (to appear)

## Installation

```bash
pip install rtrec
```

## Usage

Find usages in [notebooks](https://github.com/myui/rtrec/tree/main/notebooks)/[examples](https://github.com/myui/rtrec/tree/main/examples).

### Examples using Raw-level APIs

```py
# Dataset consists of user, item, tstamp, rating
import time
current_unixtime = time.time()
interactions = [('user_1', 'item_1', current_unixtime, 5.0),
                ('user_2', 'item_2', current_unixtime, -2.0),
                ('user_2', 'item_1', current_unixtime, 3.0),
                ('user_2', 'item_4', current_unixtime, 3.0),
                ('user_1', 'item_3', current_unixtime, 4.0)]

# Fit SLIM model
from rtrec.models import SLIM
model = SLIM()
model.fit(interactions)

# can fit from streams using yield as follows:
def yield_interactions():
    for interaction in interactions:
        yield interaction
model.fit(yield_interactions())

# Recommend top-5 items for a user
recommendations = model.recommend('user_1', top_k=5)
assert recommendations == ["item_4", "item_2"]
```

### Examples using high level DataFrame APIs

```py
# load dataset
from rtrec.experiments.datasets import load_dataset
df = load_dataset(name='movielens_1m')

# Split data set by temporal user split
from rtrec.experiments.split import temporal_user_split
train_df, test_df = temporal_user_split(df)

# Initialize SLIM model with custom options
from rtrec.recommender import Recommender
from rtrec.models import SLIM
model = SLIM(min_value=0, max_value=15, decay_in_days=180, nn_feature_selection=50)
recommender = Recommender(model)

# Bulk fit
recommender.bulk_fit(train_df)

# Partial fit
from rtrec.experiments.split import temporal_split
test_df1, test_df2 = temporal_split(test_df, test_frac=0.5)

recommender.fit(test_df1, update_interaction=True, parallel=True)

# Evaluation
metrics = recommender.evaluate(test_df2, recommend_size=10, filter_interacted=True)
print(metrics)

# User to Item Recommendation
recommended = recommender.recommend(user=10, top_k=10, filter_interacted=True)
assert len(recommended) == 10

# Item to Item recommendation
similar_items = recommender.similar_items(query_items=[3,10], top_k=5)
assert len(similar_items) == 2
```
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rtrec",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "machine learning, personalization, recommendation systems, recommender, recsys",
    "author": null,
    "author_email": "myui <myui@apache.org>",
    "download_url": "https://files.pythonhosted.org/packages/7a/cf/ce4d1ba86820c6aa38b615a4e142f8c2e9b524dd7049b6fcbebd56848031/rtrec-0.1.5.tar.gz",
    "platform": null,
    "description": "rtrec: Realtime Recommendation Library in Python\n================================================\n\n[![PyPI version](https://img.shields.io/pypi/v/rtrec.svg?logo=pypi&logoColor=FFE873)](https://pypi.org/project/rtrec/)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/rtrec.svg?logo=python&logoColor=FFE873)](https://pypi.org/project/rtrec/)\n[![CI status](https://github.com/myui/rtrec/actions/workflows/ci.yml/badge.svg)](https://github.com/myui/rtrec/actions)\n[![Licence](https://img.shields.io/github/license/myui/rtrec.svg)](LICENSE.txt)\n\nAn realtime recommendation system supporting online updates.\n\n## Highlights\n\n- \u2747\ufe0f Supporting online updates.\n- \u26a1\ufe0f Fast implementation (>=190k samples/sec training on laptop).\n- \u25cd efficient sparse data support.\n- \ud83d\udd51 decaying weights of user-item interactions based on recency.\n- ![Rust](https://avatars.githubusercontent.com/u/5430905?s=20&v=4) experimental [Rust implementation](https://github.com/myui/rtrec/tree/rust)\n\n## Supported Recommendation Algorithims\n\n- Sparse [SLIM](https://ieeexplore.ieee.org/document/6137254) with [time-weighted](https://dl.acm.org/doi/10.1145/1099554.1099689) interactions.\n- [Factorization Machines](https://ieeexplore.ieee.org/document/5694074) using [LightFM](https://github.com/lyst/lightfm) (to appear)\n\n## Installation\n\n```bash\npip install rtrec\n```\n\n## Usage\n\nFind usages in [notebooks](https://github.com/myui/rtrec/tree/main/notebooks)/[examples](https://github.com/myui/rtrec/tree/main/examples).\n\n### Examples using Raw-level APIs\n\n```py\n# Dataset consists of user, item, tstamp, rating\nimport time\ncurrent_unixtime = time.time()\ninteractions = [('user_1', 'item_1', current_unixtime, 5.0),\n                ('user_2', 'item_2', current_unixtime, -2.0),\n                ('user_2', 'item_1', current_unixtime, 3.0),\n                ('user_2', 'item_4', current_unixtime, 3.0),\n                ('user_1', 'item_3', current_unixtime, 4.0)]\n\n# Fit SLIM model\nfrom rtrec.models import SLIM\nmodel = SLIM()\nmodel.fit(interactions)\n\n# can fit from streams using yield as follows:\ndef yield_interactions():\n    for interaction in interactions:\n        yield interaction\nmodel.fit(yield_interactions())\n\n# Recommend top-5 items for a user\nrecommendations = model.recommend('user_1', top_k=5)\nassert recommendations == [\"item_4\", \"item_2\"]\n```\n\n### Examples using high level DataFrame APIs\n\n```py\n# load dataset\nfrom rtrec.experiments.datasets import load_dataset\ndf = load_dataset(name='movielens_1m')\n\n# Split data set by temporal user split\nfrom rtrec.experiments.split import temporal_user_split\ntrain_df, test_df = temporal_user_split(df)\n\n# Initialize SLIM model with custom options\nfrom rtrec.recommender import Recommender\nfrom rtrec.models import SLIM\nmodel = SLIM(min_value=0, max_value=15, decay_in_days=180, nn_feature_selection=50)\nrecommender = Recommender(model)\n\n# Bulk fit\nrecommender.bulk_fit(train_df)\n\n# Partial fit\nfrom rtrec.experiments.split import temporal_split\ntest_df1, test_df2 = temporal_split(test_df, test_frac=0.5)\n\nrecommender.fit(test_df1, update_interaction=True, parallel=True)\n\n# Evaluation\nmetrics = recommender.evaluate(test_df2, recommend_size=10, filter_interacted=True)\nprint(metrics)\n\n# User to Item Recommendation\nrecommended = recommender.recommend(user=10, top_k=10, filter_interacted=True)\nassert len(recommended) == 10\n\n# Item to Item recommendation\nsimilar_items = recommender.similar_items(query_items=[3,10], top_k=5)\nassert len(similar_items) == 2\n```",
    "bugtrack_url": null,
    "license": null,
    "summary": "An realtime recommendation system supporting online updates",
    "version": "0.1.5",
    "project_urls": {
        "homepage": "https://github.com/myui/rtrec",
        "repository": "https://github.com/myui/rtrec"
    },
    "split_keywords": [
        "machine learning",
        " personalization",
        " recommendation systems",
        " recommender",
        " recsys"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "78c970f18bfba64839d6f3c9f68622b28fc1f3a9e5dc7fe99ab6a133e20e97d1",
                "md5": "0b2f62e4ad6d344ac74c5c85e34d12ff",
                "sha256": "0275feac718a7a0245355483ab6cb00c5ad63a5169f43019377bc59ff7c5f625"
            },
            "downloads": -1,
            "filename": "rtrec-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0b2f62e4ad6d344ac74c5c85e34d12ff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 45648,
            "upload_time": "2024-12-27T06:58:39",
            "upload_time_iso_8601": "2024-12-27T06:58:39.370726Z",
            "url": "https://files.pythonhosted.org/packages/78/c9/70f18bfba64839d6f3c9f68622b28fc1f3a9e5dc7fe99ab6a133e20e97d1/rtrec-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7acfce4d1ba86820c6aa38b615a4e142f8c2e9b524dd7049b6fcbebd56848031",
                "md5": "00df3756ef1c5ef9207cb824c7f4038d",
                "sha256": "3aa1c9c0f8a2fd314480fa4890432fdc161b094b12c3dc4753bde075f086e558"
            },
            "downloads": -1,
            "filename": "rtrec-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "00df3756ef1c5ef9207cb824c7f4038d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 53231,
            "upload_time": "2024-12-27T06:58:40",
            "upload_time_iso_8601": "2024-12-27T06:58:40.795431Z",
            "url": "https://files.pythonhosted.org/packages/7a/cf/ce4d1ba86820c6aa38b615a4e142f8c2e9b524dd7049b6fcbebd56848031/rtrec-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-27 06:58:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "myui",
    "github_project": "rtrec",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "rtrec"
}
        
Elapsed time: 0.44988s