Giter VIP home page Giter VIP logo

cornac's Introduction

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.

Useful links

Docs | Preferred.AI

Getting started

Getting started with Cornac is simple, and you just need to install it first.

Installation

Please make sure you are using Python 3 (version >=3.6, is recommended), and you are on the latest pip. Then, please run the appropriate Cornac install command according to your platform.

  • Windows:

     #Installing PyTorch is required as this dependency is not handle automatically.
     pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl 
     pip3 install https://github.com/PreferredAI/cornac/raw/master/dist/cornac-0.1.0-cp36-cp36m-win_amd64.whl
  • Linux:

     pip3 install https://github.com/PreferredAI/cornac/archive/master.zip --process-dependency-links
    
  • MacOS:

    • You will need to install the Torch dependency first. Please follow the instructions here to install PyTorch on MacOS using conda. Then run the following command.
     pip install https://github.com/PreferredAI/cornac/archive/master.zip
    

Your first Cornac experiment

This example will show you how to run your very first experiment using Cornac. It consists in training and evaluating the Probabilistic Matrix Factorization (PMF) recommender model.

#Importing required modules from Cornac.
from cornac.models import Pmf
from cornac.experiment import Experiment
from cornac.evaluation_strategies import Split
from cornac import metrics 

#Importing some additional useful modules.
from scipy.io import loadmat

#Loading and preparing the Amazon office data,
#Available in the GitHub repository, inside folder 'data/'. 
office= loadmat("path to office.mat")
mat_office = office['mat']

#Instantiate a pfm recommender model.
#Please refer to the documentation for details on parameter settings.
rec_pmf = Pmf(k=10, max_iter=100, learning_rate=0.001, lamda=0.001, init_params={'U':None,'V':None})

#Instantiate an evaluation strategy.
es_split = Split(data = mat_office, prop_test=0.2, prop_validation=0.0, good_rating=4)

#Instantiate evaluation metrics.
rec = metrics.Recall(m=20)
pre = metrics.Precision(m=20)
mae = metrics.Mae()
rmse = metrics.Rmse()

#Instantiate and then run an experiment.
res_pmf = Experiment(es_split, [rec_pmf], metrics=[mae,rmse,pre,rec])
res_pmf.run_()

#Get average results.
res_pmf.res_avg

cornac's People

Contributors

jinygao avatar andrew-dungle avatar saghiles avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.