Skip to content

Latest commit

 

History

History
180 lines (136 loc) · 12.8 KB

README.md

File metadata and controls

180 lines (136 loc) · 12.8 KB

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 | 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()
recall = cornac.metrics.Recall(k=[10, 20])
ndcg = cornac.metrics.NDCG(k=[10, 20])
auc = cornac.metrics.AUC()

Put everything together into an experiment and run it:

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

Output:

MAE RMSE AUC NDCG@10 NDCG@20 Recall@10 Recall@20 Train (s) Test (s)
MF 0.7430 0.8998 0.7445 0.0479 0.0556 0.0352 0.0654 0.13 1.57
PMF 0.7534 0.9138 0.7744 0.0617 0.0719 0.0479 0.0880 2.18 1.64
BPR N/A N/A 0.8695 0.0975 0.1129 0.0891 0.1449 3.74 1.49

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
Multi-Task Explainable Recommendation (MTER), paper requirements.txt 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
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
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
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.

License

Apache License 2.0