RecTools 0.10.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. rectools-0.10.0/LICENSE +203 -0
  2. rectools-0.10.0/PKG-INFO +254 -0
  3. rectools-0.10.0/README.md +198 -0
  4. rectools-0.10.0/pyproject.toml +130 -0
  5. rectools-0.10.0/rectools/__init__.py +52 -0
  6. rectools-0.10.0/rectools/columns.py +33 -0
  7. rectools-0.10.0/rectools/compat.py +70 -0
  8. rectools-0.10.0/rectools/dataset/__init__.py +46 -0
  9. rectools-0.10.0/rectools/dataset/dataset.py +321 -0
  10. rectools-0.10.0/rectools/dataset/features.py +466 -0
  11. rectools-0.10.0/rectools/dataset/identifiers.py +252 -0
  12. rectools-0.10.0/rectools/dataset/interactions.py +210 -0
  13. rectools-0.10.0/rectools/dataset/torch_datasets.py +213 -0
  14. rectools-0.10.0/rectools/exceptions.py +26 -0
  15. rectools-0.10.0/rectools/metrics/__init__.py +97 -0
  16. rectools-0.10.0/rectools/metrics/auc.py +553 -0
  17. rectools-0.10.0/rectools/metrics/base.py +141 -0
  18. rectools-0.10.0/rectools/metrics/classification.py +567 -0
  19. rectools-0.10.0/rectools/metrics/debias.py +205 -0
  20. rectools-0.10.0/rectools/metrics/distances.py +177 -0
  21. rectools-0.10.0/rectools/metrics/diversity.py +286 -0
  22. rectools-0.10.0/rectools/metrics/dq.py +337 -0
  23. rectools-0.10.0/rectools/metrics/intersection.py +148 -0
  24. rectools-0.10.0/rectools/metrics/novelty.py +254 -0
  25. rectools-0.10.0/rectools/metrics/popularity.py +171 -0
  26. rectools-0.10.0/rectools/metrics/ranking.py +616 -0
  27. rectools-0.10.0/rectools/metrics/scoring.py +214 -0
  28. rectools-0.10.0/rectools/metrics/serendipity.py +333 -0
  29. rectools-0.10.0/rectools/model_selection/__init__.py +46 -0
  30. rectools-0.10.0/rectools/model_selection/cross_validate.py +169 -0
  31. rectools-0.10.0/rectools/model_selection/last_n_split.py +121 -0
  32. rectools-0.10.0/rectools/model_selection/random_split.py +143 -0
  33. rectools-0.10.0/rectools/model_selection/splitter.py +166 -0
  34. rectools-0.10.0/rectools/model_selection/time_split.py +147 -0
  35. rectools-0.10.0/rectools/model_selection/utils.py +75 -0
  36. rectools-0.10.0/rectools/models/__init__.py +73 -0
  37. rectools-0.10.0/rectools/models/base.py +814 -0
  38. rectools-0.10.0/rectools/models/dssm.py +414 -0
  39. rectools-0.10.0/rectools/models/ease.py +188 -0
  40. rectools-0.10.0/rectools/models/implicit_als.py +675 -0
  41. rectools-0.10.0/rectools/models/implicit_bpr.py +284 -0
  42. rectools-0.10.0/rectools/models/implicit_knn.py +255 -0
  43. rectools-0.10.0/rectools/models/lightfm.py +320 -0
  44. rectools-0.10.0/rectools/models/popular.py +317 -0
  45. rectools-0.10.0/rectools/models/popular_in_category.py +440 -0
  46. rectools-0.10.0/rectools/models/pure_svd.py +152 -0
  47. rectools-0.10.0/rectools/models/random.py +166 -0
  48. rectools-0.10.0/rectools/models/rank.py +275 -0
  49. rectools-0.10.0/rectools/models/serialization.py +66 -0
  50. rectools-0.10.0/rectools/models/utils.py +136 -0
  51. rectools-0.10.0/rectools/models/vector.py +153 -0
  52. rectools-0.10.0/rectools/tools/__init__.py +36 -0
  53. rectools-0.10.0/rectools/tools/ann.py +475 -0
  54. rectools-0.10.0/rectools/types.py +27 -0
  55. rectools-0.10.0/rectools/utils/__init__.py +57 -0
  56. rectools-0.10.0/rectools/utils/array_set_ops.py +282 -0
  57. rectools-0.10.0/rectools/utils/config.py +19 -0
  58. rectools-0.10.0/rectools/utils/indexing.py +136 -0
  59. rectools-0.10.0/rectools/utils/misc.py +230 -0
  60. rectools-0.10.0/rectools/utils/serialization.py +51 -0
  61. rectools-0.10.0/rectools/version.py +15 -0
  62. rectools-0.10.0/rectools/visuals/__init__.py +38 -0
  63. rectools-0.10.0/rectools/visuals/metrics_app.py +378 -0
  64. rectools-0.10.0/rectools/visuals/visual_app.py +825 -0
@@ -0,0 +1,203 @@
1
+ Copyright 2022 MTS (Mobile Telesystems). All rights reserved.
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright 2022 MTS (Mobile Telesystems).
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
@@ -0,0 +1,254 @@
1
+ Metadata-Version: 2.1
2
+ Name: RecTools
3
+ Version: 0.10.0
4
+ Summary: An easy-to-use Python library for building recommendation systems
5
+ Home-page: https://github.com/MobileTeleSystems/RecTools
6
+ License: Apache-2.0
7
+ Keywords: recsys,recommendation systems,machine learning,AI,personalization
8
+ Author: Emiliy Feldman
9
+ Author-email: feldlime@yandex.ru
10
+ Maintainer: Emiliy Feldman
11
+ Maintainer-email: feldlime@yandex.ru
12
+ Requires-Python: >=3.9,<3.13
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Education
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Operating System :: MacOS
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Classifier: Operating System :: Unix
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Provides-Extra: all
28
+ Provides-Extra: lightfm
29
+ Provides-Extra: nmslib
30
+ Provides-Extra: torch
31
+ Provides-Extra: visuals
32
+ Requires-Dist: attrs (>=19.1.0,<24.0.0)
33
+ Requires-Dist: implicit (>=0.7.1,<0.8.0)
34
+ Requires-Dist: ipywidgets (>=7.7,<8.2) ; extra == "visuals" or extra == "all"
35
+ Requires-Dist: nbformat (>=4.2.0) ; extra == "visuals" or extra == "all"
36
+ Requires-Dist: nmslib (>=2.0.4,<3.0.0) ; (python_version < "3.11") and (extra == "nmslib" or extra == "all")
37
+ Requires-Dist: nmslib-metabrainz (>=2.1.3,<3.0.0) ; (python_version >= "3.11" and python_version < "3.13") and (extra == "nmslib" or extra == "all")
38
+ Requires-Dist: numpy (>=1.22,<2.0.0) ; python_version < "3.12"
39
+ Requires-Dist: numpy (>=1.26,<2.0.0) ; python_version == "3.12"
40
+ Requires-Dist: pandas (>=1.5.0,<3.0.0)
41
+ Requires-Dist: plotly (>=5.22.0,<6.0.0) ; extra == "visuals" or extra == "all"
42
+ Requires-Dist: pydantic (>=2.8.2,<3.0.0)
43
+ Requires-Dist: pydantic-core (>=2.20.1,<3.0.0)
44
+ Requires-Dist: pytorch-lightning (>=1.6.0,<3.0.0) ; extra == "torch" or extra == "all"
45
+ Requires-Dist: rectools-lightfm (>=1.17.3,<2.0.0) ; extra == "lightfm" or extra == "all"
46
+ Requires-Dist: scipy (>=1.10.1,<1.13)
47
+ Requires-Dist: torch (>=1.6.0,<2.3.0) ; (sys_platform == "darwin" and platform_machine == "x86_64") and (extra == "torch" or extra == "all")
48
+ Requires-Dist: torch (>=1.6.0,<3.0.0) ; extra == "torch" or extra == "all"
49
+ Requires-Dist: tqdm (>=4.27.0,<5.0.0)
50
+ Requires-Dist: typeguard (>=4.1.0,<5.0.0)
51
+ Requires-Dist: typing-extensions (>=4.12.2,<5.0.0)
52
+ Project-URL: Documentation, https://rectools.readthedocs.io
53
+ Project-URL: Repository, https://github.com/MobileTeleSystems/RecTools
54
+ Description-Content-Type: text/markdown
55
+
56
+ # RecTools
57
+
58
+ [![Python versions](https://img.shields.io/pypi/pyversions/rectools.svg)](https://pypi.org/project/rectools)
59
+ [![PyPI](https://img.shields.io/pypi/v/rectools.svg)](https://pypi.org/project/rectools)
60
+ [![Docs](https://img.shields.io/github/actions/workflow/status/MobileTeleSystems/RecTools/publish.yml?label=docs)](https://rectools.readthedocs.io)
61
+
62
+ [![License](https://img.shields.io/github/license/MobileTeleSystems/RecTools.svg)](https://github.com/MobileTeleSystems/RecTools/blob/main/LICENSE)
63
+ [![Coverage](https://img.shields.io/codecov/c/github/MobileTeleSystems/RecTools.svg)](https://app.codecov.io/gh/MobileTeleSystems/RecTools)
64
+ [![Tests](https://img.shields.io/github/actions/workflow/status/MobileTeleSystems/RecTools/test.yml?branch=main&label=tests)](https://github.com/MobileTeleSystems/RecTools/actions/workflows/test.yml?query=branch%3Amain++)
65
+
66
+ [![Contributors](https://img.shields.io/github/contributors/MobileTeleSystems/RecTools.svg)](https://github.com/MobileTeleSystems/RecTools/graphs/contributors)
67
+ [![Downloads](https://static.pepy.tech/badge/rectools)](https://pepy.tech/project/rectools)
68
+ [![Telegram](https://img.shields.io/badge/channel-telegram-blue)](https://t.me/RecTools_Support)
69
+
70
+ <p align="center">
71
+ <a href="https://rectools.readthedocs.io/en/stable/">Documentation</a> |
72
+ <a href="https://github.com/MobileTeleSystems/RecTools/tree/main/examples">Examples</a> |
73
+ <a href="https://github.com/MobileTeleSystems/RecTools/tree/main/examples/tutorials">Tutorials</a> |
74
+ <a href="https://github.com/MobileTeleSystems/RecTools/blob/main/CONTRIBUTING.rst">Contributing</a> |
75
+ <a href="https://github.com/MobileTeleSystems/RecTools/releases">Releases</a> |
76
+ <a href="https://github.com/orgs/MobileTeleSystems/projects/1">Developers Board</a>
77
+ </p>
78
+
79
+ RecTools is an easy-to-use Python library which makes the process of building recommendation systems easier,
80
+ faster and more structured than ever before.
81
+ It includes built-in toolkits for data processing and metrics calculation,
82
+ a variety of recommender models, some wrappers for already existing implementations of popular algorithms
83
+ and model selection framework.
84
+ The aim is to collect ready-to-use solutions and best practices in one place to make processes
85
+ of creating your first MVP and deploying model to production as fast and easy as possible.
86
+
87
+
88
+
89
+ ## Get started
90
+
91
+ Prepare data with
92
+
93
+ ```shell
94
+ wget https://files.grouplens.org/datasets/movielens/ml-1m.zip
95
+ unzip ml-1m.zip
96
+ ```
97
+
98
+ ```python
99
+ import pandas as pd
100
+ from implicit.nearest_neighbours import TFIDFRecommender
101
+
102
+ from rectools import Columns
103
+ from rectools.dataset import Dataset
104
+ from rectools.models import ImplicitItemKNNWrapperModel
105
+
106
+ # Read the data
107
+ ratings = pd.read_csv(
108
+ "ml-1m/ratings.dat",
109
+ sep="::",
110
+ engine="python", # Because of 2-chars separators
111
+ header=None,
112
+ names=[Columns.User, Columns.Item, Columns.Weight, Columns.Datetime],
113
+ )
114
+
115
+ # Create dataset
116
+ dataset = Dataset.construct(ratings)
117
+
118
+ # Fit model
119
+ model = ImplicitItemKNNWrapperModel(TFIDFRecommender(K=10))
120
+ model.fit(dataset)
121
+
122
+ # Make recommendations
123
+ recos = model.recommend(
124
+ users=ratings[Columns.User].unique(),
125
+ dataset=dataset,
126
+ k=10,
127
+ filter_viewed=True,
128
+ )
129
+ ```
130
+
131
+ ## Installation
132
+
133
+ RecTools is on PyPI, so you can use `pip` to install it.
134
+ ```
135
+ pip install rectools
136
+ ```
137
+ The default version doesn't contain all the dependencies, because some of them are needed only for specific functionality. Available user extensions are the following:
138
+
139
+ - `lightfm`: adds wrapper for LightFM model,
140
+ - `torch`: adds models based on neural nets,
141
+ - `visuals`: adds visualization tools,
142
+ - `nmslib`: adds fast ANN recommenders.
143
+
144
+ Install extension:
145
+ ```
146
+ pip install rectools[extension-name]
147
+ ```
148
+
149
+ Install all extensions:
150
+ ```
151
+ pip install rectools[all]
152
+ ```
153
+
154
+
155
+ ## Recommender Models
156
+ The table below lists recommender models that are available in RecTools.
157
+ See [recommender baselines extended tutorial](https://github.com/MobileTeleSystems/RecTools/blob/main/examples/tutorials/baselines_extended_tutorial.ipynb) for deep dive into theory & practice of our supported models.
158
+
159
+ | Model | Type | Description (🎏 for user/item features, 🔆 for warm inference, ❄️ for cold inference support) | Tutorials & Benchmarks |
160
+ |----|----|---------|--------|
161
+ | [implicit](https://github.com/benfred/implicit) ALS Wrapper | Matrix Factorization | `rectools.models.ImplicitALSWrapperModel` - Alternating Least Squares Matrix Factorizattion algorithm for implicit feedback. <br>🎏| 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#Implicit-ALS)<br> 🚀 [50% boost to metrics with user & item features](examples/5_benchmark_iALS_with_features.ipynb) |
162
+ | [implicit](https://github.com/benfred/implicit) BPR-MF Wrapper | Matrix Factorization | `rectools.models.ImplicitBPRWrapperModel` - Bayesian Personalized Ranking Matrix Factorization algorithm. | 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#Bayesian-Personalized-Ranking-Matrix-Factorization-(BPR-MF)) |
163
+ | [implicit](https://github.com/benfred/implicit) ItemKNN Wrapper | Nearest Neighbours | `rectools.models.ImplicitItemKNNWrapperModel` - Algorithm that calculates item-item similarity matrix using distances between item vectors in user-item interactions matrix | 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#ItemKNN) |
164
+ | [LightFM](https://github.com/lyst/lightfm) Wrapper | Matrix Factorization | `rectools.models.LightFMWrapperModel` - Hybrid matrix factorization algorithm which utilises user and item features and supports a variety of losses.<br>🎏 🔆 ❄️| 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#LightFM)<br>🚀 [10-25 times faster inference with RecTools](examples/6_benchmark_lightfm_inference.ipynb)|
165
+ | EASE | Linear Autoencoder | `rectools.models.EASEModel` - Embarassingly Shallow Autoencoders implementation that explicitly calculates dense item-item similarity matrix | 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#EASE) |
166
+ | PureSVD | Matrix Factorization | `rectools.models.PureSVDModel` - Truncated Singular Value Decomposition of user-item interactions matrix | 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#PureSVD) |
167
+ | DSSM | Neural Network | `rectools.models.DSSMModel` - Two-tower Neural model that learns user and item embeddings utilising their explicit features and learning on triplet loss.<br>🎏 🔆 | - |
168
+ | Popular | Heuristic | `rectools.models.PopularModel` - Classic baseline which computes popularity of items and also accepts params like time window and type of popularity computation.<br>❄️| - |
169
+ | Popular in Category | Heuristic | `rectools.models.PopularInCategoryModel` - Model that computes poularity within category and applies mixing strategy to increase Diversity.<br>❄️| - |
170
+ | Random | Heuristic | `rectools.models.RandomModel` - Simple random algorithm useful to benchmark Novelty, Coverage, etc.<br>❄️| - |
171
+
172
+ - All of the models follow the same interface. **No exceptions**
173
+ - No need for manual creation of sparse matrixes or mapping ids. Preparing data for models is as simple as `dataset = Dataset.construct(interactions_df)`
174
+ - Fitting any model is as simple as `model.fit(dataset)`
175
+ - For getting recommendations `filter_viewed` and `items_to_recommend` options are available
176
+ - For item-to-item recommendations use `recommend_to_items` method
177
+ - For feeding user/item features to model just specify dataframes when constructing `Dataset`. [Check our tutorial](examples/4_dataset_with_features.ipynb)
178
+ - For warm / cold inference just provide all required ids in `users` or `target_items` parameters of `recommend` or `recommend_to_items` methods and make sure you have features in the dataset for warm users/items. **Nothing else is needed, everything works out of the box.**
179
+
180
+
181
+ ## Extended validation tools
182
+
183
+ ### `DebiasConfig` for debiased metrics calculation
184
+
185
+ [User guide](https://github.com/MobileTeleSystems/RecTools/blob/main/examples/8_debiased_metrics.ipynb) | [Documentation](https://rectools.readthedocs.io/en/stable/api/rectools.metrics.debias.DebiasConfig.html)
186
+
187
+ ### `VisualApp` for model recommendations comparison
188
+
189
+ <img src="https://recsysart.ru/images/visual_app.gif" width=500>
190
+
191
+
192
+ [Example](https://github.com/MobileTeleSystems/RecTools/blob/main/examples/7_visualization.ipynb) | [Demo](https://recsysart.ru/voila/) | [Documentation](https://rectools.readthedocs.io/en/stable/api/rectools.visuals.visual_app.VisualApp.html)
193
+
194
+
195
+
196
+ ### `MetricsApp` for metrics trade-off analysis
197
+
198
+
199
+ <img src="https://recsysart.ru/images/metrics_app.gif" width=600>
200
+
201
+ [Example](https://github.com/MobileTeleSystems/RecTools/blob/main/examples/2_cross_validation.ipynb) |
202
+ [Documentation](https://rectools.readthedocs.io/en/stable/api/rectools.visuals.metrics_app.MetricsApp.html)
203
+
204
+
205
+ ## Contribution
206
+ [Contributing guide](CONTRIBUTING.rst)
207
+
208
+ To install all requirements
209
+ - you must have `python3` and `poetry` installed
210
+ - make sure you have no active virtual environments (deactivate conda `base` if applicable)
211
+ - run
212
+ ```
213
+ make install
214
+ ```
215
+
216
+
217
+ For autoformatting run
218
+ ```
219
+ make format
220
+ ```
221
+
222
+ For linters check run
223
+ ```
224
+ make lint
225
+ ```
226
+
227
+ For tests run
228
+ ```
229
+ make test
230
+ ```
231
+
232
+ For coverage run
233
+ ```
234
+ make coverage
235
+ ```
236
+
237
+ To remove virtual environment run
238
+ ```
239
+ make clean
240
+ ```
241
+
242
+ ## RecTools Team
243
+
244
+ - [Emiliy Feldman](https://github.com/feldlime) [Maintainer]
245
+ - [Daria Tikhonovich](https://github.com/blondered) [Maintainer]
246
+ - [Andrey Semenov](https://github.com/In48semenov)
247
+ - [Mike Sokolov](https://github.com/mikesokolovv)
248
+ - [Maya Spirina](https://github.com/spirinamayya)
249
+ - [Grigoriy Gusarov](https://github.com/Gooogr)
250
+ - [Aki Ariga](https://github.com/chezou)
251
+
252
+ Previous contributors: [Ildar Safilo](https://github.com/irsafilo) [ex-Maintainer], [Daniil Potapov](https://github.com/sharthZ23) [ex-Maintainer], [Alexander Butenko](https://github.com/iomallach), [Igor Belkov](https://github.com/OzmundSedler), [Artem Senin](https://github.com/artemseninhse), [Mikhail Khasykov](https://github.com/mkhasykov), [Julia Karamnova](https://github.com/JuliaKup), [Maxim Lukin](https://github.com/groundmax), [Yuri Ulianov](https://github.com/yukeeul), [Egor Kratkov](https://github.com/jegorus), [Azat Sibagatulin](https://github.com/azatnv), [Vadim Vetrov](https://github.com/Waujito)
253
+
254
+
@@ -0,0 +1,198 @@
1
+ # RecTools
2
+
3
+ [![Python versions](https://img.shields.io/pypi/pyversions/rectools.svg)](https://pypi.org/project/rectools)
4
+ [![PyPI](https://img.shields.io/pypi/v/rectools.svg)](https://pypi.org/project/rectools)
5
+ [![Docs](https://img.shields.io/github/actions/workflow/status/MobileTeleSystems/RecTools/publish.yml?label=docs)](https://rectools.readthedocs.io)
6
+
7
+ [![License](https://img.shields.io/github/license/MobileTeleSystems/RecTools.svg)](https://github.com/MobileTeleSystems/RecTools/blob/main/LICENSE)
8
+ [![Coverage](https://img.shields.io/codecov/c/github/MobileTeleSystems/RecTools.svg)](https://app.codecov.io/gh/MobileTeleSystems/RecTools)
9
+ [![Tests](https://img.shields.io/github/actions/workflow/status/MobileTeleSystems/RecTools/test.yml?branch=main&label=tests)](https://github.com/MobileTeleSystems/RecTools/actions/workflows/test.yml?query=branch%3Amain++)
10
+
11
+ [![Contributors](https://img.shields.io/github/contributors/MobileTeleSystems/RecTools.svg)](https://github.com/MobileTeleSystems/RecTools/graphs/contributors)
12
+ [![Downloads](https://static.pepy.tech/badge/rectools)](https://pepy.tech/project/rectools)
13
+ [![Telegram](https://img.shields.io/badge/channel-telegram-blue)](https://t.me/RecTools_Support)
14
+
15
+ <p align="center">
16
+ <a href="https://rectools.readthedocs.io/en/stable/">Documentation</a> |
17
+ <a href="https://github.com/MobileTeleSystems/RecTools/tree/main/examples">Examples</a> |
18
+ <a href="https://github.com/MobileTeleSystems/RecTools/tree/main/examples/tutorials">Tutorials</a> |
19
+ <a href="https://github.com/MobileTeleSystems/RecTools/blob/main/CONTRIBUTING.rst">Contributing</a> |
20
+ <a href="https://github.com/MobileTeleSystems/RecTools/releases">Releases</a> |
21
+ <a href="https://github.com/orgs/MobileTeleSystems/projects/1">Developers Board</a>
22
+ </p>
23
+
24
+ RecTools is an easy-to-use Python library which makes the process of building recommendation systems easier,
25
+ faster and more structured than ever before.
26
+ It includes built-in toolkits for data processing and metrics calculation,
27
+ a variety of recommender models, some wrappers for already existing implementations of popular algorithms
28
+ and model selection framework.
29
+ The aim is to collect ready-to-use solutions and best practices in one place to make processes
30
+ of creating your first MVP and deploying model to production as fast and easy as possible.
31
+
32
+
33
+
34
+ ## Get started
35
+
36
+ Prepare data with
37
+
38
+ ```shell
39
+ wget https://files.grouplens.org/datasets/movielens/ml-1m.zip
40
+ unzip ml-1m.zip
41
+ ```
42
+
43
+ ```python
44
+ import pandas as pd
45
+ from implicit.nearest_neighbours import TFIDFRecommender
46
+
47
+ from rectools import Columns
48
+ from rectools.dataset import Dataset
49
+ from rectools.models import ImplicitItemKNNWrapperModel
50
+
51
+ # Read the data
52
+ ratings = pd.read_csv(
53
+ "ml-1m/ratings.dat",
54
+ sep="::",
55
+ engine="python", # Because of 2-chars separators
56
+ header=None,
57
+ names=[Columns.User, Columns.Item, Columns.Weight, Columns.Datetime],
58
+ )
59
+
60
+ # Create dataset
61
+ dataset = Dataset.construct(ratings)
62
+
63
+ # Fit model
64
+ model = ImplicitItemKNNWrapperModel(TFIDFRecommender(K=10))
65
+ model.fit(dataset)
66
+
67
+ # Make recommendations
68
+ recos = model.recommend(
69
+ users=ratings[Columns.User].unique(),
70
+ dataset=dataset,
71
+ k=10,
72
+ filter_viewed=True,
73
+ )
74
+ ```
75
+
76
+ ## Installation
77
+
78
+ RecTools is on PyPI, so you can use `pip` to install it.
79
+ ```
80
+ pip install rectools
81
+ ```
82
+ The default version doesn't contain all the dependencies, because some of them are needed only for specific functionality. Available user extensions are the following:
83
+
84
+ - `lightfm`: adds wrapper for LightFM model,
85
+ - `torch`: adds models based on neural nets,
86
+ - `visuals`: adds visualization tools,
87
+ - `nmslib`: adds fast ANN recommenders.
88
+
89
+ Install extension:
90
+ ```
91
+ pip install rectools[extension-name]
92
+ ```
93
+
94
+ Install all extensions:
95
+ ```
96
+ pip install rectools[all]
97
+ ```
98
+
99
+
100
+ ## Recommender Models
101
+ The table below lists recommender models that are available in RecTools.
102
+ See [recommender baselines extended tutorial](https://github.com/MobileTeleSystems/RecTools/blob/main/examples/tutorials/baselines_extended_tutorial.ipynb) for deep dive into theory & practice of our supported models.
103
+
104
+ | Model | Type | Description (🎏 for user/item features, 🔆 for warm inference, ❄️ for cold inference support) | Tutorials & Benchmarks |
105
+ |----|----|---------|--------|
106
+ | [implicit](https://github.com/benfred/implicit) ALS Wrapper | Matrix Factorization | `rectools.models.ImplicitALSWrapperModel` - Alternating Least Squares Matrix Factorizattion algorithm for implicit feedback. <br>🎏| 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#Implicit-ALS)<br> 🚀 [50% boost to metrics with user & item features](examples/5_benchmark_iALS_with_features.ipynb) |
107
+ | [implicit](https://github.com/benfred/implicit) BPR-MF Wrapper | Matrix Factorization | `rectools.models.ImplicitBPRWrapperModel` - Bayesian Personalized Ranking Matrix Factorization algorithm. | 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#Bayesian-Personalized-Ranking-Matrix-Factorization-(BPR-MF)) |
108
+ | [implicit](https://github.com/benfred/implicit) ItemKNN Wrapper | Nearest Neighbours | `rectools.models.ImplicitItemKNNWrapperModel` - Algorithm that calculates item-item similarity matrix using distances between item vectors in user-item interactions matrix | 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#ItemKNN) |
109
+ | [LightFM](https://github.com/lyst/lightfm) Wrapper | Matrix Factorization | `rectools.models.LightFMWrapperModel` - Hybrid matrix factorization algorithm which utilises user and item features and supports a variety of losses.<br>🎏 🔆 ❄️| 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#LightFM)<br>🚀 [10-25 times faster inference with RecTools](examples/6_benchmark_lightfm_inference.ipynb)|
110
+ | EASE | Linear Autoencoder | `rectools.models.EASEModel` - Embarassingly Shallow Autoencoders implementation that explicitly calculates dense item-item similarity matrix | 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#EASE) |
111
+ | PureSVD | Matrix Factorization | `rectools.models.PureSVDModel` - Truncated Singular Value Decomposition of user-item interactions matrix | 📙 [Theory & Practice](https://rectools.readthedocs.io/en/latest/examples/tutorials/baselines_extended_tutorial.html#PureSVD) |
112
+ | DSSM | Neural Network | `rectools.models.DSSMModel` - Two-tower Neural model that learns user and item embeddings utilising their explicit features and learning on triplet loss.<br>🎏 🔆 | - |
113
+ | Popular | Heuristic | `rectools.models.PopularModel` - Classic baseline which computes popularity of items and also accepts params like time window and type of popularity computation.<br>❄️| - |
114
+ | Popular in Category | Heuristic | `rectools.models.PopularInCategoryModel` - Model that computes poularity within category and applies mixing strategy to increase Diversity.<br>❄️| - |
115
+ | Random | Heuristic | `rectools.models.RandomModel` - Simple random algorithm useful to benchmark Novelty, Coverage, etc.<br>❄️| - |
116
+
117
+ - All of the models follow the same interface. **No exceptions**
118
+ - No need for manual creation of sparse matrixes or mapping ids. Preparing data for models is as simple as `dataset = Dataset.construct(interactions_df)`
119
+ - Fitting any model is as simple as `model.fit(dataset)`
120
+ - For getting recommendations `filter_viewed` and `items_to_recommend` options are available
121
+ - For item-to-item recommendations use `recommend_to_items` method
122
+ - For feeding user/item features to model just specify dataframes when constructing `Dataset`. [Check our tutorial](examples/4_dataset_with_features.ipynb)
123
+ - For warm / cold inference just provide all required ids in `users` or `target_items` parameters of `recommend` or `recommend_to_items` methods and make sure you have features in the dataset for warm users/items. **Nothing else is needed, everything works out of the box.**
124
+
125
+
126
+ ## Extended validation tools
127
+
128
+ ### `DebiasConfig` for debiased metrics calculation
129
+
130
+ [User guide](https://github.com/MobileTeleSystems/RecTools/blob/main/examples/8_debiased_metrics.ipynb) | [Documentation](https://rectools.readthedocs.io/en/stable/api/rectools.metrics.debias.DebiasConfig.html)
131
+
132
+ ### `VisualApp` for model recommendations comparison
133
+
134
+ <img src="https://recsysart.ru/images/visual_app.gif" width=500>
135
+
136
+
137
+ [Example](https://github.com/MobileTeleSystems/RecTools/blob/main/examples/7_visualization.ipynb) | [Demo](https://recsysart.ru/voila/) | [Documentation](https://rectools.readthedocs.io/en/stable/api/rectools.visuals.visual_app.VisualApp.html)
138
+
139
+
140
+
141
+ ### `MetricsApp` for metrics trade-off analysis
142
+
143
+
144
+ <img src="https://recsysart.ru/images/metrics_app.gif" width=600>
145
+
146
+ [Example](https://github.com/MobileTeleSystems/RecTools/blob/main/examples/2_cross_validation.ipynb) |
147
+ [Documentation](https://rectools.readthedocs.io/en/stable/api/rectools.visuals.metrics_app.MetricsApp.html)
148
+
149
+
150
+ ## Contribution
151
+ [Contributing guide](CONTRIBUTING.rst)
152
+
153
+ To install all requirements
154
+ - you must have `python3` and `poetry` installed
155
+ - make sure you have no active virtual environments (deactivate conda `base` if applicable)
156
+ - run
157
+ ```
158
+ make install
159
+ ```
160
+
161
+
162
+ For autoformatting run
163
+ ```
164
+ make format
165
+ ```
166
+
167
+ For linters check run
168
+ ```
169
+ make lint
170
+ ```
171
+
172
+ For tests run
173
+ ```
174
+ make test
175
+ ```
176
+
177
+ For coverage run
178
+ ```
179
+ make coverage
180
+ ```
181
+
182
+ To remove virtual environment run
183
+ ```
184
+ make clean
185
+ ```
186
+
187
+ ## RecTools Team
188
+
189
+ - [Emiliy Feldman](https://github.com/feldlime) [Maintainer]
190
+ - [Daria Tikhonovich](https://github.com/blondered) [Maintainer]
191
+ - [Andrey Semenov](https://github.com/In48semenov)
192
+ - [Mike Sokolov](https://github.com/mikesokolovv)
193
+ - [Maya Spirina](https://github.com/spirinamayya)
194
+ - [Grigoriy Gusarov](https://github.com/Gooogr)
195
+ - [Aki Ariga](https://github.com/chezou)
196
+
197
+ Previous contributors: [Ildar Safilo](https://github.com/irsafilo) [ex-Maintainer], [Daniil Potapov](https://github.com/sharthZ23) [ex-Maintainer], [Alexander Butenko](https://github.com/iomallach), [Igor Belkov](https://github.com/OzmundSedler), [Artem Senin](https://github.com/artemseninhse), [Mikhail Khasykov](https://github.com/mkhasykov), [Julia Karamnova](https://github.com/JuliaKup), [Maxim Lukin](https://github.com/groundmax), [Yuri Ulianov](https://github.com/yukeeul), [Egor Kratkov](https://github.com/jegorus), [Azat Sibagatulin](https://github.com/azatnv), [Vadim Vetrov](https://github.com/Waujito)
198
+