ml-recsys-tools
This is an updated version of the stale ml-recsys-tools source repo
Open source repo for various tools for recommender systems development work.
Main purpose is to provide a single wrapper for various recommender packages to train, tune, evaluate and get data in and recommendations / similarities out.
Installation:
Pip:
- PyPi:
pip install ml-recsys-tools - Github
master:pip install git+https://github.com/artdgn/ml-recsys-tools@master#egg=ml_recsys_tools
Basic usage:
# dataset: download and prepare dataframes
from ml_recsys_tools.datasets.prep_movielense_data import get_and_prep_data
rating_csv_path, users_csv_path, movies_csv_path = get_and_prep_data()
# read the interactions dataframe and create a data handler object and split to train and test
import pandas as pd
ratings_df = pd.read_csv(rating_csv_path)
from ml_recsys_tools.data_handlers.interaction_handlers_base import ObservationsDF
obs = ObservationsDF(ratings_df, uid_col='userid', iid_col='itemid')
train_obs, test_obs = obs.split_train_test(ratio=0.2)
# train and test LightFM recommender
from ml_recsys_tools.recommenders.lightfm_recommender import LightFMRecommender
lfm_rec = LightFMRecommender()
lfm_rec.fit(train_obs, epochs=10)
# print summary evaluation report:
print(lfm_rec.eval_on_test_by_ranking(test_obs.df_obs, prefix='lfm ', n_rec=100))
# get all recommendations and print a sample (training interactions are filtered out by default)
recs = lfm_rec.get_recommendations(lfm_rec.all_users, n_rec=5)
print(recs.sample(5))
# get all similarities and print a sample
simils = lfm_rec.get_similar_items(lfm_rec.all_items, n_simil=5)
print(simils.sample(10))
Additional examples in the examples/ folder:
- Cosine similarity
- Ensembles
- Hybrid features for LightFM
- Additional recommenders
- Using multiple testsets and Evaluation
Recommender models and tools:
-
LightFM package based recommender.
-
Implicit package based ALS recommender.
-
Evaluation features added for most recommenders:
- Dataframes for all inputs and outputs
- adding external features (for LightFM hybrid mode)
- fast batched methods for:
- user recommendation sampling
- similar items samplilng with different similarity measures
- similar users sampling
- evaluation by sampling and ranking
- dense user x item recommendation and item x item similarity
- Dataframes for all inputs and outputs
-
Additional recommender models:
-
Ensembles:
- subdivision based (multiple recommenders each on subset of data - e.g. geographical region):
- geo based: simple grid, equidense grid, geo clustering
- LightFM and cooccurrence based
- combination based - combining recommendations from multiple recommenders
- similarity combination based - similarity based recommender on similarities from multiple recommenders
- cascade ensemble
- subdivision based (multiple recommenders each on subset of data - e.g. geographical region):
-
Interaction dataframe and sparse matrix handlers / builders:
- sampling, data splitting,
- external features matrix creation (additional item features), with feature engineering: binning / one*hot encoding (via pandas_sklearn)
- evaluation and ranking helpers
- handlers for observations coupled with external features and features with geo coordinates
-
Evaluation utils:
- score reports on lightfm metrics (AUC, precision, recall, reciprocal)
- n-DCG, and n-MRR metrics, n-precision / recall
- references: best possible ranking and chance ranking
-
Utilities:
- similarity calculation helpers (similarities, dot, top N, top N on sparse)
- parallelism utils
- sklearn transformer extenstions (for feature engineering)
- logging, debug printouts decorators and other instrumentation and inspection tools
- pandas utils
Metadata
Release files for ml-recsys-tools 0.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ml_recsys_tools-0.9.1.tar.gz | 43.0 kB | Without provenance | Details for ml_recsys_tools-0.9.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ml_recsys_tools-0.9.1-py3-none-any.whl | Python 3 | none | any | Details for ml_recsys_tools-0.9.1-py3-none-any.whl |
Total release size: 99.3 kB
Release files / ml_recsys_tools-0.9.1.tar.gz
| Download URL | ml_recsys_tools-0.9.1.tar.gz |
|---|---|
| Size | 43.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb8342c4ece6879e8ec2cf4dc2d8b4767b904e466a03beb596114e8aede32b99
|
|
BLAKE2b-256 checksum How to use checksums |
bc9b7f768413426f162e59c92845864c95fcddd3f51068270c1a34801a3dbd17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9
|
Release files / ml_recsys_tools-0.9.1-py3-none-any.whl
| Download URL | ml_recsys_tools-0.9.1-py3-none-any.whl |
|---|---|
| Size | 56.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7899a1a7aa8851a9c1901ead2798fe75aa06fd83dac4b3670c9f4fcd30fc65a5
|
|
BLAKE2b-256 checksum How to use checksums |
337b215450af60c0493c8cb9e0daad3bd95f21a91f99779585a2b47c4d3688be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9
|
Security for ml-recsys-tools 0.9.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.