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 | Preferred.AI

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

Installation

Currently, we are supporting Python 3 (version 3.6 is recommended). 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 of the algorithms 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):

from cornac.datasets import movielens

ml_100k = movielens.load_100k()

Split the data based on ratio:

from cornac.eval_methods import RatioSplit

ratio_split = RatioSplit(data=ml_100k, test_size=0.2, rating_threshold=4.0, seed=123)

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

from cornac.models import MF, PMF, BPR

mf = MF(k=10, max_iter=25, learning_rate=0.01, lambda_reg=0.02, use_bias=True)
pmf = PMF(k=10, max_iter=100, learning_rate=0.001, lamda=0.001)
bpr = BPR(k=10, max_iter=200, learning_rate=0.001, lambda_reg=0.01)

Define metrics used to evaluate the models:

mae = cornac.metrics.MAE()
rmse = cornac.metrics.RMSE()
rec_20 = cornac.metrics.Recall(k=20)
ndcg_20 = cornac.metrics.NDCG(k=20)
auc = cornac.metrics.AUC()

Put everything together into an experiment and run it:

from cornac import Experiment

exp = Experiment(eval_method=ratio_split,
                 models=[mf, pmf, bpr],
                 metrics=[mae, rmse, rec_20, ndcg_20, auc],
                 user_based=True)
exp.run()

Output:

MAE RMSE Recall@20 NDCG@20 AUC Train (s) Test (s)
MF 0.7441 0.9007 0.0622 0.0534 0.2952 0.0791 1.3119
PMF 0.7490 0.9093 0.0831 0.0683 0.4660 8.7645 2.1569
BPR N/A N/A 0.1449 0.1124 0.8750 0.8898 1.3769

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

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
Probabilistic Collaborative Representation Learning (PCRL), paper requirements.txt pcrl_exp.py
Variational Autoencoder for Collaborative Filtering (VAECF), paper requirements.txt
2017 Collaborative Variational Autoencoder (CVAE), paper requirements.txt cvae_exp.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
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 Social Bayesian Personalized Ranking (SBPR), paper N/A sbpr_epinions.py
2013 Hidden Factors and Hidden Topics (HFT), paper N/A hft_exp.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
Collaborative Filtering for Implicit Feedback (CF), paper requirements.txt cf_exp.py
Matrix Factorization (MF), paper N/A biased_mf.py, given_data.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

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.

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.0.0.tar.gz (3.2 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.0.0-cp37-cp37m-manylinux1_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.7m

cornac-1.0.0-cp36-cp36m-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.6mWindows x86-64

cornac-1.0.0-cp36-cp36m-manylinux1_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.6m

cornac-1.0.0-cp36-cp36m-macosx_10_7_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.6mmacOS 10.7+ x86-64

cornac-1.0.0-cp35-cp35m-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.5mWindows x86-64

cornac-1.0.0-cp35-cp35m-manylinux1_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.5m

cornac-1.0.0-cp35-cp35m-macosx_10_6_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.5mmacOS 10.6+ x86-64

File details

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

File metadata

  • Download URL: cornac-1.0.0.tar.gz
  • Upload date:
  • Size: 3.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.6

File hashes

Hashes for cornac-1.0.0.tar.gz
Algorithm Hash digest
SHA256 268f09e506dcb30433afc0b2f61a09271f5a9bcb527470a567a780c288c952c8
MD5 61b5202659bcdeb31968d28533573073
BLAKE2b-256 c33adac916d25a89c154e0961291bf86aa5b3802b6025760539122f11fb685b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cornac-1.0.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 5.7 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/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for cornac-1.0.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ee849316735900ba1ff7294a7e720c0b05b1a42b4783369643d413736855663c
MD5 a0cf4d3db8042b3c025db5939babda2e
BLAKE2b-256 1a16d84b00e81d3c31ab015b45c944e6a53417ca09df4aa04316b87fc6d0327d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cornac-1.0.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.7

File hashes

Hashes for cornac-1.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 3ac6cc8d8a9fe8e8b4f0f17cee913c1c0ce552002c1f83e6a99c4bcd72d94f00
MD5 f698cd8d22120b417f01668278855cb8
BLAKE2b-256 43bccc0d19ee631fb27ca3e070a5957db1b78eeaf1439d3403fef10f8cc9399a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cornac-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 5.8 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/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for cornac-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b94383a8c3a6f18dd75ce0c2ba85a154bf8ae8df0d06558a6a49fb0569b0a81a
MD5 f1e0d52aaf4451219e575a54b8c91c05
BLAKE2b-256 edb9af45460cf6cb5073ab88eba7bdd4e6477e555b194eed74294909e9318e8d

See more details on using hashes here.

File details

Details for the file cornac-1.0.0-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: cornac-1.0.0-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.9

File hashes

Hashes for cornac-1.0.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0f49ee0fcda79f5f479376de05ae486a2db987bf2f9db5087515c819ae0497dd
MD5 b878d5dd38feabc0ecfe6ec0e412f7bc
BLAKE2b-256 ebf5d60f61a95fb2a4c54cdc83e5c71fd5f5f68a0c15f2f8aa9df5038d1162c9

See more details on using hashes here.

File details

Details for the file cornac-1.0.0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: cornac-1.0.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.6

File hashes

Hashes for cornac-1.0.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 2f991a1afe4e3b613c95abc4128cb20b3ed0dd5ac8aa599cc2608db38aa66c30
MD5 c251f3f7f1153a42dc5b1d4fc9745b5a
BLAKE2b-256 1c289bb79497aeebf89df8f0d0be8954d71ee3f92e77f5a695bc3017ac984d40

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cornac-1.0.0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 5.6 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/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for cornac-1.0.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d2e361c009f830251f34dd089f1dafc44f6cc43aacbc1d489a9dab4860a3c6ba
MD5 04ccfba9eb95bbfc5e6ef63a997ef735
BLAKE2b-256 c7dee33adcf51e85d576655b80873f8b6c1fdad793336a5a2648f34f9bb8f439

See more details on using hashes here.

File details

Details for the file cornac-1.0.0-cp35-cp35m-macosx_10_6_x86_64.whl.

File metadata

  • Download URL: cornac-1.0.0-cp35-cp35m-macosx_10_6_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.5m, macOS 10.6+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.6

File hashes

Hashes for cornac-1.0.0-cp35-cp35m-macosx_10_6_x86_64.whl
Algorithm Hash digest
SHA256 dff607e94ada2402f8602ac02e88c86caa5c23ccad95c1c3f9ae06c0ca556e0a
MD5 8d5e51d52b22d3f145ef440ed01d03d9
BLAKE2b-256 f8778cccdf3f5e226bd88e2a974aa4f37cf2701ffb3a74eaeff2774a7c654ce6

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