{"id":15350449,"url":"https://github.com/myui/rtrec","last_synced_at":"2025-04-14T23:37:13.236Z","repository":{"id":256331214,"uuid":"843208403","full_name":"myui/rtrec","owner":"myui","description":"An realtime recommendation system supporting online updates","archived":false,"fork":false,"pushed_at":"2025-04-03T05:10:41.000Z","size":387,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T10:58:12.513Z","etag":null,"topics":["factorization-machines","machine-learning","online-learning","realtime","recommendation","recommendation-system","recommender-system","recsys"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/myui.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-16T02:32:57.000Z","updated_at":"2025-04-03T05:10:45.000Z","dependencies_parsed_at":"2024-09-10T06:50:49.498Z","dependency_job_id":"6b43ab83-8e37-420e-b0f9-1c0077c1c681","html_url":"https://github.com/myui/rtrec","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":"0.11764705882352944","last_synced_commit":"56006f6b41807a69c69862c72752aa9228325411"},"previous_names":["myui/rtrec"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myui%2Frtrec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myui%2Frtrec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myui%2Frtrec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myui%2Frtrec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myui","download_url":"https://codeload.github.com/myui/rtrec/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248981000,"owners_count":21193142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["factorization-machines","machine-learning","online-learning","realtime","recommendation","recommendation-system","recommender-system","recsys"],"created_at":"2024-10-01T11:58:28.109Z","updated_at":"2025-04-14T23:37:13.230Z","avatar_url":"https://github.com/myui.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"rtrec: Realtime Recommendation Library in Python\n================================================\n\n[![PyPI version](https://img.shields.io/pypi/v/rtrec.svg?logo=pypi\u0026logoColor=FFE873)](https://pypi.org/project/rtrec/)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/rtrec.svg?logo=python\u0026logoColor=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[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/myui/rtrec/blob/main/notebooks/quickstart_colab.ipynb)\n\nA realtime recommendation system supporting online updates.\n\n## Highlights\n\n- ❇️ Supporting online updates.\n- ⚡️ Fast implementation (\u003e=190k samples/sec training on laptop).\n- ◍ efficient sparse data support.\n- 🕑 decaying weights of user-item interactions based on recency.\n- ![Rust](https://avatars.githubusercontent.com/u/5430905?s=20\u0026v=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)\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```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyui%2Frtrec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyui%2Frtrec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyui%2Frtrec/lists"}