Skip to main content

A collection of recommendation algorithms and comparisons

Project description

Cornac

Cornac is python recommender system library for easy, effective and efficient experiments. Cornac is simple and handy. It is designed from the ground-up to faithfully reflect the standard steps taken by researchers to implement and evaluate personalized recommendation models.

Quick Links

Website | Documentation | Models | Examples | 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 here. Why don't you join us to lengthen the list?

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-0.3.0.tar.gz (3.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-0.3.0-cp36-cp36m-win_amd64.whl (891.8 kB view details)

Uploaded CPython 3.6mWindows x86-64

cornac-0.3.0-cp36-cp36m-manylinux1_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.6m

cornac-0.3.0-cp36-cp36m-macosx_10_7_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.6mmacOS 10.7+ x86-64

cornac-0.3.0-cp35-cp35m-win_amd64.whl (871.6 kB view details)

Uploaded CPython 3.5mWindows x86-64

cornac-0.3.0-cp35-cp35m-manylinux1_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.5m

cornac-0.3.0-cp35-cp35m-macosx_10_6_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.5mmacOS 10.6+ x86-64

File details

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

File metadata

  • Download URL: cornac-0.3.0.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.6

File hashes

Hashes for cornac-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c6abf5b20cb6c4a818fc34cf6b39984b319c2c302236ef13dba3936a8f7caa04
MD5 a1db7095bb3c388f89484354f59eb348
BLAKE2b-256 65d2194030416f8dfe45ba2a0ed55664af7670f10684bc3181524074547bd2b8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cornac-0.3.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 70263fc36d99e4ba96818ebf6cdeb0252041c37e2e4df0329d0f61b66adb325e
MD5 cf80ed7d7f309021afa25386dfaaa92f
BLAKE2b-256 e5860adbf192f582c47577af6e11e4889b6d6f666f28e5cc0afb9c8423398ab7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cornac-0.3.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.5 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-0.3.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7d093d1655ee3b45edb52da6f9d4e8e1b8e0040016b26e4d0e83bd27982232f8
MD5 cc1e5719e81c6c28e75d29caf6fbb2f4
BLAKE2b-256 013bdc17fd0cdf0b829e63befee35c11af9058469cffb11fba9205386718079f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cornac-0.3.0-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for cornac-0.3.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 e559e4569288c1e584b504605abe14ee55d2269d20b8e72c025cbd534e06b6a0
MD5 742235ab493eda41f9cf706e33fcd7d3
BLAKE2b-256 1d07e525836ccc4e0034eebfa37ae8d1cb2ff75ee86f20ccc3f7419daecd413c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cornac-0.3.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 41897a5c49cc9d7d4d6430bcd6feae743a734bd031291a37d901f0493f57faf6
MD5 1a0b9a687ce3c0cdc312713bc611baa9
BLAKE2b-256 afa3ddeba8f69e135f392b11113b18d99a03d220907834cd90311c5cc8d02c23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cornac-0.3.0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.4 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-0.3.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 76f43ae5ed79a143c9518721477d67250f210ea8596f8331186cef5d37657c40
MD5 7567d617e2db7acc067da97dd80cc3b3
BLAKE2b-256 d5c315058c972eae1bce0b1a2cb7e1911ba7eb572fe3c602387fa2dc6fa41920

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cornac-0.3.0-cp35-cp35m-macosx_10_6_x86_64.whl
Algorithm Hash digest
SHA256 32f6ac005b2f810cd5e0065380fa2cd6ced165eeec89a506b9bb8a84403e7c4b
MD5 ceb5ab031ffc444213bc672c0ef1d593
BLAKE2b-256 55c3bf7799ce564d0fa940b9a6f34a5ff0b29605a49a4288320ab7d91f2f11b5

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