Skip to main content

Tools for recommendation systems development

Project description

CI

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:

  • pip install git+https://github.com/artdgn/ml-recsys-tools@master#egg=ml_recsys_tools
  • As dependency (add to requirements.txt): add line git+https://github.com/artdgn/ml-recsys-tools@master#egg=ml_recsys_tools

Basic example:

# 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))

Recommender models and tools:

  • LightFM package based recommender.

  • Implicit package based ALS recommender.

  • Serving / Tuning / 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
  • Additional recommender models:

    • Similarity based:
      • cooccurence (items, users)
      • generic similarity based (can be used with external features)
  • 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
  • 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ml_recsys_tools-0.9.0.tar.gz (42.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ml_recsys_tools-0.9.0-py3-none-any.whl (56.1 kB view details)

Uploaded Python 3

File details

Details for the file ml_recsys_tools-0.9.0.tar.gz.

File metadata

  • Download URL: ml_recsys_tools-0.9.0.tar.gz
  • Upload date:
  • Size: 42.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for ml_recsys_tools-0.9.0.tar.gz
Algorithm Hash digest
SHA256 2cfd34e28c3429c2970bd86a5dfdcf19e8bdf120ea0f635a5b46c007d1a7cc1c
MD5 85975a42e265658e77174b7381f15465
BLAKE2b-256 6f9701f5e0f5cb9362540ed81d56331729d157a2dbf2ea1588b45e981f839f3f

See more details on using hashes here.

File details

Details for the file ml_recsys_tools-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: ml_recsys_tools-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 56.1 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for ml_recsys_tools-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95c7f343741d92ed5ddff0cf37f41368014bf7e47f070f168ce177a0f1b4ab9b
MD5 0718b45a9d1b15d0a25cbda800e896a2
BLAKE2b-256 253bc373975789f8fdb346190ae1f595e865edf04c90e51f68a7ba66d2acc0fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page