Skip to main content

A Comparative Framework for Multimodal Recommender Systems

Project description

Cornac

Cornac is a comparative framework for multimodal recommender systems. It focuses on making it convenient to work with models leveraging auxiliary data (e.g., item descriptive text and image, social network, etc). Cornac enables fast experiments and straightforward implementations of new models. It is highly compatible with existing machine learning libraries (e.g., TensorFlow, PyTorch).

Quick Links

Website | Documentation | Tutorials | Examples | Models | Datasets | Paper | Preferred.AI

TravisCI CircleCI AppVeyor Codecov Docs
Release PyPI Conda Conda Recipe
Python License

Installation

Currently, we are supporting Python 3. There are several ways to install Cornac:

  • From PyPI (you may need a C++ compiler):
pip3 install cornac
  • From Anaconda:
conda install cornac -c conda-forge
  • From the GitHub source (for latest updates):
pip3 install Cython
git clone https://github.com/PreferredAI/cornac.git
cd cornac
python3 setup.py install

Note:

Additional dependencies required by models are listed here.

Some algorithm implementations use OpenMP to support multi-threading. For OSX users, in order to run those algorithms efficiently, you might need to install gcc from Homebrew to have an OpenMP compiler:

brew install gcc | brew link gcc

If you want to utilize your GPUs, you might consider:

Getting started: your first Cornac experiment

Flow of an Experiment in Cornac

Load the built-in MovieLens 100K dataset (will be downloaded if not cached):

import cornac

ml_100k = cornac.datasets.movielens.load_feedback(variant="100K")

Split the data based on ratio:

rs = cornac.eval_methods.RatioSplit(data=ml_100k, test_size=0.2, rating_threshold=4.0, seed=123)

Here we are comparing Biased MF, PMF, and BPR:

mf = cornac.models.MF(k=10, max_iter=25, learning_rate=0.01, lambda_reg=0.02, use_bias=True, seed=123)
pmf = cornac.models.PMF(k=10, max_iter=100, learning_rate=0.001, lambda_reg=0.001, seed=123)
bpr = cornac.models.BPR(k=10, max_iter=200, learning_rate=0.001, lambda_reg=0.01, seed=123)

Define metrics used to evaluate the models:

mae = cornac.metrics.MAE()
rmse = cornac.metrics.RMSE()
prec = cornac.metrics.Precision(k=10)
recall = cornac.metrics.Recall(k=10)
ndcg = cornac.metrics.NDCG(k=10)
auc = cornac.metrics.AUC()
mAP = cornac.metrics.MAP()

Put everything together into an experiment and run it:

cornac.Experiment(
  eval_method=rs,
  models=[mf, pmf, bpr],
  metrics=[mae, rmse, recall, ndcg, auc, mAP],
  user_based=True
).run()

Output:

MAE RMSE AUC MAP NDCG@10 Precision@10 Recall@10 Train (s) Test (s)
MF 0.7430 0.8998 0.7445 0.0407 0.0479 0.0437 0.0352 0.13 1.57
PMF 0.7534 0.9138 0.7744 0.0491 0.0617 0.0533 0.0479 2.18 1.64
BPR N/A N/A 0.8695 0.0753 0.0975 0.0727 0.0891 3.74 1.49

For more details, please take a look at our examples as well as tutorials.

Models

The recommender models supported by Cornac are listed below. Why don't you join us to lengthen the list?

Year Model and paper Additional dependencies Examples
2018 Collaborative Context Poisson Factorization (C2PF), paper N/A c2pf_exp.py
Multi-Task Explainable Recommendation (MTER), paper N/A mter_exp.py
Probabilistic Collaborative Representation Learning (PCRL), paper requirements.txt pcrl_exp.py
Variational Autoencoder for Collaborative Filtering (VAECF), paper requirements.txt vaecf_citeulike.py
2017 Collaborative Variational Autoencoder (CVAE), paper requirements.txt cvae_exp.py
Conditional Variational Autoencoder for Collaborative Filtering (CVAECF), paper requirements.txt cvaecf_filmtrust.py
Generalized Matrix Factorization (GMF), paper requirements.txt ncf_exp.py
Indexable Bayesian Personalized Ranking (IBPR), paper requirements.txt ibpr_exp.py
Matrix Co-Factorization (MCF), paper N/A mcf_office.py
Multi-Layer Perceptron (MLP), paper requirements.txt ncf_exp.py
Neural Matrix Factorization (NeuMF) / Neural Collaborative Filtering (NCF), paper requirements.txt ncf_exp.py
Online Indexable Bayesian Personalized Ranking (Online IBPR), paper requirements.txt
Visual Matrix Factorization (VMF), paper requirements.txt vmf_clothing.py
2016 Collaborative Deep Ranking (CDR), paper requirements.txt cdr_exp.py
Collaborative Ordinal Embedding (COE), paper requirements.txt
Convolutional Matrix Factorization (ConvMF), paper requirements.txt convmf_exp.py
Spherical K-means (SKM), paper N/A
Visual Bayesian Personalized Ranking (VBPR), paper requirements.txt vbpr_tradesy.py
2015 Collaborative Deep Learning (CDL), paper requirements.txt cdl_exp.py
Hierarchical Poisson Factorization (HPF), paper N/A
2014 Explicit Factor Model (EFM), paper N/A efm_exp.py
Social Bayesian Personalized Ranking (SBPR), paper N/A sbpr_epinions.py
2013 Hidden Factors and Hidden Topics (HFT), paper N/A hft_exp.py
2012 Weighted Bayesian Personalized Ranking (WBPR), paper N/A bpr_netflix.py
2011 Collaborative Topic Modeling (CTR), paper N/A ctr_citeulike.py
Earlier Baseline Only, paper N/A svd_exp.py
Bayesian Personalized Ranking (BPR), paper N/A bpr_netflix.py
Global Average (GlobalAvg), paper N/A biased_mf.py
Item K-Nearest-Neighbors (ItemKNN), paper N/A knn_movielens.py
Matrix Factorization (MF), paper N/A biased_mf.py, given_data.py
Maximum Margin Matrix Factorization (MMMF), paper N/A mmmf_exp.py
Most Popular (MostPop), paper N/A bpr_netflix.py
Non-negative Matrix Factorization (NMF), paper N/A nmf_exp.py
Probabilistic Matrix Factorization (PMF), paper N/A pmf_ratio.py
Singular Value Decomposition (SVD), paper N/A svd_exp.py
Social Recommendation using PMF (SoRec), paper N/A sorec_filmtrust.py
User K-Nearest-Neighbors (UserKNN), paper N/A knn_movielens.py
Weighted Matrix Factorization (WMF), paper requirements.txt wmf_exp.py

Support

Your contributions at any level of the library are welcome. If you intend to contribute, please:

  • Fork the Cornac repository to your own account.
  • Make changes and create pull requests.

You can also post bug reports and feature requests in GitHub issues.

Citation

If you use Cornac in a scientific publication, we would appreciate citations to the following paper:

Cornac: A Comparative Framework for Multimodal Recommender Systems, Salah et al., JMLR 21, pp. 1-5, 2020.

Bibtex entry:

@article{cornac,
  author  = {Aghiles Salah and Quoc-Tuan Truong and Hady W. Lauw},
  title   = {Cornac: A Comparative Framework for Multimodal Recommender Systems},
  journal = {Journal of Machine Learning Research},
  year    = {2020},
  volume  = {21},
  number  = {95},
  pages   = {1-5},
  url     = {http://jmlr.org/papers/v21/19-805.html}
}

License

Apache License 2.0

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

cornac-1.7.0.tar.gz (7.0 MB view details)

Uploaded Source

Built Distributions

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

cornac-1.7.0-cp37-cp37m-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.7mWindows x86-64

cornac-1.7.0-cp37-cp37m-manylinux1_x86_64.whl (10.0 MB view details)

Uploaded CPython 3.7m

cornac-1.7.0-cp37-cp37m-macosx_10_9_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

cornac-1.7.0-cp36-cp36m-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.6mWindows x86-64

cornac-1.7.0-cp36-cp36m-manylinux1_x86_64.whl (10.1 MB view details)

Uploaded CPython 3.6m

cornac-1.7.0-cp36-cp36m-macosx_10_9_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

cornac-1.7.0-cp35-cp35m-manylinux1_x86_64.whl (9.8 MB view details)

Uploaded CPython 3.5m

File details

Details for the file cornac-1.7.0.tar.gz.

File metadata

  • Download URL: cornac-1.7.0.tar.gz
  • Upload date:
  • Size: 7.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for cornac-1.7.0.tar.gz
Algorithm Hash digest
SHA256 85baff63a284387698b3511970271929d7b673c52a3ed761b5aabe468a5dcb05
MD5 a6b16ed872e8e40015cf1e9b701f1b70
BLAKE2b-256 9a46eec5afbd2638fabe6b198fcb627d3bc5885cdc592ecd542eaaaef2911867

See more details on using hashes here.

File details

Details for the file cornac-1.7.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: cornac-1.7.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0.post20200710 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for cornac-1.7.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 73c4aa89da2e410d8cf3fe20b05af1fa5e2bf3262d20d6c5a2bdf57b8adab9e7
MD5 bab3b151c25e2cd1aa395794985b928a
BLAKE2b-256 60e7a88f93b5f3141aa26ce87527bde45af859bab51c125156311a1cd485baae

See more details on using hashes here.

File details

Details for the file cornac-1.7.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: cornac-1.7.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 10.0 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for cornac-1.7.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a9a6c1a59aa4e3a327e83ca4c20cbf098994ae51f71868d46ef006ca955d6d8e
MD5 8c4e57bd5e629877d4a2bb714053d1c0
BLAKE2b-256 46ccad731cfbbb2b3dd189a11d3a2dac48139f4e38f33bb3d22d73df1a992e5b

See more details on using hashes here.

File details

Details for the file cornac-1.7.0-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cornac-1.7.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for cornac-1.7.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 981d4b824d5396e4a9021945f05abbd0fe3754d9b3514d0ad753a139c23c0f6e
MD5 3ea973b8672e54b4ed13ae8cabe7f20b
BLAKE2b-256 415f2de2922ba54f4e2fd57bae2402dcd7931cb1f5479db22e173d892e0305c8

See more details on using hashes here.

File details

Details for the file cornac-1.7.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: cornac-1.7.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for cornac-1.7.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 42ad44dc46ed88755ae779fd8968d255f9789f9125532c89234f27104fbec988
MD5 3fa8e81c55cb4a240e3fcb78531c07aa
BLAKE2b-256 1002254dc415e6eacef4de7c1bb402ecf74b2046c502b7799b663e0fc48e8f05

See more details on using hashes here.

File details

Details for the file cornac-1.7.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: cornac-1.7.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 10.1 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for cornac-1.7.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a60f9f10ca939b0e327c4af3397d397812b9d63dc6af2428944a924604d91005
MD5 e238284cde1270d0e60fefd0c8790b83
BLAKE2b-256 d8d446fff9fc6d723c4c624034d2fe62979bcfb6a454fc6b7bce5b56ae642b29

See more details on using hashes here.

File details

Details for the file cornac-1.7.0-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cornac-1.7.0-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for cornac-1.7.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1833597a6e28b6181fada8f4cfb9b508e81e2d0ed9fa69041f2fb7d92fab0435
MD5 1342841fd4d3a1547943f98f80b66b78
BLAKE2b-256 de2800a3ad0d1fd2685ddcfabedae854674466ab94e98b3c16a5a227495d85d5

See more details on using hashes here.

File details

Details for the file cornac-1.7.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: cornac-1.7.0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 9.8 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for cornac-1.7.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 19d46a238b14478f0a7f30908d4c282ef59818c2439d7fbcbe0575fffb3e5210
MD5 8b525c7242de782cdd93e73fbf05a973
BLAKE2b-256 127d3b68825c4c3cd71b716743be34a9fec09017fe3c0cd4c4f51103633ee88c

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