pyr

pyreclab

pyRecLab is a library for quickly testing and prototyping of traditional recommender system methods, such as User KNN, Item KNN and FunkSVD Collaborative Filtering. It is developed and maintained by Gabriel Sepúlveda and Vicente Domínguez, advised by Prof. Denis Parra, all of them in Computer Science Department at PUC Chile, IA Lab and SocVis Lab.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

113

Maintenance

Last Commit

1yr ago

Contributors

6

Package

Dependencies

0

License

GPL 3.0

Categories

Readme

pyRecLab: Recommendation lab for Python

Overview

pyRecLab is a recommendation library designed for training recommendation models with a friendly and easy-to-use interface, keeping a good performance in memory and CPU usage.

In order to achieve this, pyRecLab is built as a Python module to give a friendly access to its algorithms and it is completely developed in C++ to avoid the lack of performace of the interpreted languages.

At this moment, the following recommendation algorithms are supported:

RecSys AlgorithmRating PredictionItem RecommendationImplicit Feedback
User Averagexx
Item Averagexx
Slope Onexx
User Based KNNxx
Item Based KNNxx
Funk's SVDxx
Most Popularx
ALSxx
ALS with Conjugate Gradientxx
BPR for Matrix Factorizationxx

Although pyRecLab can be compiled on most popular operating system, it has been tested on the following distributions.

Operating SystemVersion
Ubuntu16.04
CentOS6.4
Mac OS X10.11 ( El Capitan )
Mac OS X10.12 ( Sierra )

Citations

If you use this library, please cite:

@inproceedings{1706.06291v2, author = {Gabriel Sepulveda and Vicente Dominguez and Denis Parra}, title = {pyRecLab: A Software Library for Quick Prototyping of Recommender Systems}, year = {2017}, month = {August}, eprint = {arXiv:1706.06291v2}, keywords = {Recommender Systems, Software Development, Recommender Library, Python Library} }

Check out our paper

Install

pyRecLab can be installed directly using pip as follow:

Python 2

pip install pyreclab

Python 3

pip3 install pyreclab

Build and Install

In case there is not a package available for your favorite operating system, you can build pyRecLab through the following steps:

1.- Before starting, verify you have libpython-dev, boost and cmake installed on your system. If not, install it through your distribution's package manager, as shown next.

Debian based OS's ( Ubuntu )

$ sudo apt-get install libpython-dev
$ sudo apt-get install cmake
$ sudo apt-get install libboost-dev

Note: for Python 3.x, install libpython3-dev instead of libpython-dev.

RedHat based OS's ( CentOS )

$ yum install python-devel
$ yum install cmake
$ yum install boost-devel

MAC OS X

$ brew install cmake
$ brew install boost

2.- Clone the source code of pyRecLab in a local directory.

$ git clone https://github.com/gasevi/pyreclab.git

3.- Build the Python module ( default: Python 2.7 ).

$ cd pyreclab
$ cmake .
$ make

By default, pyRecLab will be compiled for Python 2.7. If you want to build it for Python 3.x, you can execute the following steps:

$ cd pyreclab
$ cmake -DCMAKE_PYTHON_VERSION=3.x .
$ make

4.- Install pyRecLab.

$ sudo make install

API Documentation

pyRecLab provides the following classes for representing each of the recommendation algorithm currenly supported:

>>> from pyreclab import <RecAlg>

or import the entire module as you prefer

>>> import pyreclab

Due to the different nature of each algorithm, their implementations can have some variations on its parameters. For this reason, each class is described in detail in the following sections.

pyreclab.UserAvg

  • Instance creation
>>> obj = pyreclab.UserAvg( dataset = filename,
                            dlmchar = b'\t',
                            header = False,
                            usercol = 0,
                            itemcol = 1,
                            ratingcol = 2 )
ParameterTypeDefault valueDescription
datasetmandatoryN.A.Dataset filename with fields: userid, itemid and rating
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseWhether dataset filename contains a header line to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
  • Training
>>> obj.train( progress = False )
ParameterTypeDefault valueDescription
progressoptionalFalseShow progress bar
  • Rating prediction
>>> prediction = obj.predict( userId, itemId )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
itemIdmandatoryN.A.Item identifier
  • Top-N item recommendation
>>> ranking = obj.recommend( userId, topN, includeRated )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
topNoptional10Top N items to recommend
includeRatedoptionalFalseInclude rated items in ranking generation
  • Testing and evaluation for prediction
>>> predictionList, mae, rmse = obj.test( input_file = testset,
                                          dlmchar = b'\t',
                                          header = False,
                                          usercol = 0,
                                          itemcol = 1,
                                          ratingcol = 2,
                                          output_file = 'predictions.csv' )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
output_fileoptionalN.A.Output file to write predictions
  • Testing for recommendation
>>> recommendationList, map, ndcg = obj.testrec( input_file = testset,
                                                 dlmchar = b'\t',
                                                 header = False,
                                                 usercol = 0,
                                                 itemcol = 1,
                                                 ratingcol = 2,
                                                 topn = 10,
                                                 output_file = 'ranking.json',
                                                 relevance_threshold = 0,
                                                 includeRated = False )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
topnoptional10Top N items to recommend
output_fileoptionalN.A.Output file to write predictions
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
includeRatedoptionalFalseInclude rated items in ranking generation
  • Precision
>>> precision = obj.precision( user_id,
                               retrieved,
                               topn = 10,
                               relevance_threshold = 0,
                               include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Recall
>>> recall = obj.recall( user_id,
                         retrieved,
                         topn = 10,
                         relevance_threshold = 0,
                         include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Area Under the ROC Curve (AUC)
>>> auc = obj.AUC( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Mean Average precision
>>> map = obj.MAP( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Normalized Discounted Cumulative Gain
>>> map = obj.nDCG( user_id,
                    retrieved,
                    topn = 10,
                    relevance_threshold = 0,
                    include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation

pyreclab.ItemAvg

  • Instance creation
>>> obj = pyreclab.ItemAvg( dataset = filename,
                            dlmchar = b'\t',
                            header = False,
                            usercol = 0,
                            itemcol = 1,
                            ratingcol = 2 )
ParameterTypeDefault valueDescription
datasetmandatoryN.A.Dataset filename with fields: userid, itemid and rating
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseWhether dataset filename contains a header line to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
  • Training
>>> obj.train( progress = False )
ParameterTypeDefault valueDescription
progressoptionalFalseShow progress bar
  • Rating prediction
>>> prediction = obj.predict( userId, itemId )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
itemIdmandatoryN.A.Item identifier
  • Top-N item recommendation
>>> ranking = obj.recommend( userId, topN, includeRated )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
topNoptional10Top N items to recommend
includeRatedoptionalFalseInclude rated items in ranking generation
  • Testing and evaluation for prediction
>>> predictionList, mae, rmse = obj.test( input_file = testset,
                                          dlmchar = b'\t',
                                          header = False,
                                          usercol = 0,
                                          itemcol = 1,
                                          ratingcol = 2,
                                          output_file = 'predictions.csv' )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
output_fileoptionalN.A.Output file to write predictions
  • Testing for recommendation
>>> recommendationList, map, ndcg = obj.testrec( input_file = testset,
                                                 dlmchar = b'\t',
                                                 header = False,
                                                 usercol = 0,
                                                 itemcol = 1,
                                                 ratingcol = 2,
                                                 topn = 10,
                                                 output_file = 'ranking.json',
                                                 relevance_threshold = 2,
                                                 includeRated = False )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
topnoptional10Top N items to recommend
output_fileoptionalN.A.Output file to write predictions
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
includeRatedoptionalFalseInclude rated items in ranking generation
  • Precision
>>> precision = obj.precision( user_id,
                               retrieved,
                               topn = 10,
                               relevance_threshold = 0,
                               include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Recall
>>> recall = obj.recall( user_id,
                         retrieved,
                         topn = 10,
                         relevance_threshold = 0,
                         include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Area Under the ROC Curve (AUC)
>>> auc = obj.AUC( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Mean Average precision
>>> map = obj.MAP( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Normalized Discounted Cumulative Gain
>>> map = obj.nDCG( user_id,
                    retrieved,
                    topn = 10,
                    relevance_threshold = 0,
                    include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation

pyreclab.SlopeOne

  • Instance creation
>>> obj = pyreclab.SlopeOne( dataset = filename,
                             dlmchar = b'\t',
                             header = False,
                             usercol = 0,
                             itemcol = 1,
                             ratingcol = 2 )
ParameterTypeDefault valueDescription
datasetmandatoryN.A.Dataset filename with fields: userid, itemid and rating
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseWhether dataset filename contains a header line to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
  • Training
>>> obj.train( progress = False )
ParameterTypeDefault valueDescription
progressoptionalFalseShow progress bar
  • Rating prediction
prediction = obj.predict( userId, itemId )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
itemIdmandatoryN.A.Item identifier
  • Top-N item recommendation
>>> ranking = obj.recommend( userId, topN, includeRated )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
topNoptional10Top N items to recommend
includeRatedoptionalFalseInclude rated items in ranking generation
  • Testing and evaluation for prediction
>>> predictionList, mae, rmse = obj.test( input_file = testset,
                                          dlmchar = b'\t',
                                          header = False,
                                          usercol = 0,
                                          itemcol = 1,
                                          ratingcol = 2,
                                          output_file = 'predictions.csv' )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
output_fileoptionalN.A.Output file to write predictions
  • Testing for recommendation
>>> recommendationList, map, ndcg = obj.testrec( input_file = testset,
                                                 dlmchar = b'\t',
                                                 header = False,
                                                 usercol = 0,
                                                 itemcol = 1,
                                                 ratingcol = 2,
                                                 topn = 10,
                                                 output_file = 'ranking.json',
                                                 relevance_threshold = 2,
                                                 includeRated = False )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
topnoptional10Top N items to recommend
output_fileoptionalN.A.Output file to write predictions
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
includeRatedoptionalFalseInclude rated items in ranking generation
  • Precision
>>> precision = obj.precision( user_id,
                               retrieved,
                               topn = 10,
                               relevance_threshold = 0,
                               include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Recall
>>> recall = obj.recall( user_id,
                         retrieved,
                         topn = 10,
                         relevance_threshold = 0,
                         include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Area Under the ROC Curve (AUC)
>>> auc = obj.AUC( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Mean Average precision
>>> map = obj.MAP( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Normalized Discounted Cumulative Gain
>>> map = obj.nDCG( user_id,
                    retrieved,
                    topn = 10,
                    relevance_threshold = 0,
                    include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation

pyreclab.UserKnn

  • Instance creation
>>> obj = pyreclab.UserKnn( dataset = filename,
                            dlmchar = b'\t',
                            header = False,
                            usercol = 0,
                            itemcol = 1,
                            ratingcol = 2 )
ParameterTypeDefault valueDescription
datasetmandatoryN.A.Dataset filename with fields: userid, itemid and rating
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseWhether dataset filename contains a header line to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
  • Training
>>> obj.train( knn, similarity, progress = False )
ParameterTypeDefault valueValid valuesDescription
knnoptional10positive integerK nearest neighbors
similarityoptional'pearson''pearson', 'cosine'Similarity metric
progressoptionalFalseShow progress bar
  • Rating prediction
>>> prediction = obj.predict( userId, itemId )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
itemIdmandatoryN.A.Item identifier
  • Top-N item recommendation
>>> ranking = obj.recommend( userId, topN, includeRated )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
topNoptional10Top N items to recommend
includeRatedoptionalFalseInclude rated items in ranking generation
  • Testing and evaluation for prediction
>>> predictionList, mae, rmse = obj.test( input_file = testset,
                                          dlmchar = b'\t',
                                          header = False,
                                          usercol = 0,
                                          itemcol = 1,
                                          ratingcol = 2,
                                          output_file = 'predictions.csv' )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
output_fileoptionalN.A.Output file to write predictions
  • Testing for recommendation
>>> recommendationList, map, ndcg = obj.testrec( input_file = testset,
                                                 dlmchar = b'\t',
                                                 header = False,
                                                 usercol = 0,
                                                 itemcol = 1,
                                                 ratingcol = 2,
                                                 topn = 10,
                                                 output_file = 'ranking.json',
                                                 relevance_threshold = 2,
                                                 includeRated = False )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
topnoptional10Top N items to recommend
output_fileoptionalN.A.Output file to write predictions
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
includeRatedoptionalFalseInclude rated items in ranking generation
  • Precision
>>> precision = obj.precision( user_id,
                               retrieved,
                               topn = 10,
                               relevance_threshold = 0,
                               include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Recall
>>> recall = obj.recall( user_id,
                         retrieved,
                         topn = 10,
                         relevance_threshold = 0,
                         include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Area Under the ROC Curve (AUC)
>>> auc = obj.AUC( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Mean Average precision
>>> map = obj.MAP( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Normalized Discounted Cumulative Gain
>>> map = obj.nDCG( user_id,
                    retrieved,
                    topn = 10,
                    relevance_threshold = 0,
                    include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation

pyreclab.ItemKnn

  • Instance creation
>>> obj = pyreclab.ItemKnn( dataset = filename,
                            dlmchar = b'\t',
                            header = False,
                            usercol = 0,
                            itemcol = 1,
                            ratingcol = 2 )
ParameterTypeDefault valueDescription
datasetmandatoryN.A.Dataset filename with fields: userid, itemid and rating
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseWhether dataset filename contains a header line to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
  • Training
>>> obj.train( knn, similarity, progress = False )
ParameterTypeDefault valueValid valuesDescription
knnoptional10positive integerK nearest neighbors
similarityoptional'pearson''pearson', 'cosine'Similarity metric
progressoptionalFalseShow progress bar
  • Rating prediction
>>> prediction = obj.predict( userId, itemId )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
itemIdmandatoryN.A.Item identifier
  • Top-N item recommendation
>>> ranking = obj.recommend( userId, topN, includeRated )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
topNoptional10Top N items to recommend
includeRatedoptionalFalseInclude rated items in ranking generation
  • Testing and evaluation for prediction
>>> predictionList, mae, rmse = obj.test( input_file = testset,
                                          dlmchar = b'\t',
                                          header = False,
                                          usercol = 0,
                                          itemcol = 1,
                                          ratingcol = 2,
                                          output_file = 'predictions.csv' )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
output_fileoptionalN.A.Output file to write predictions
  • Testing for recommendation
>>> recommendationList, map, ndcg = obj.testrec( input_file = testset,
                                                 dlmchar = b'\t',
                                                 header = False,
                                                 usercol = 0,
                                                 itemcol = 1,
                                                 ratingcol = 2,
                                                 topn = 10,
                                                 output_file = 'ranking.json',
                                                 relevance_threshold = 2,
                                                 includeRated = False )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
topnoptional10Top N items to recommend
output_fileoptionalN.A.Output file to write predictions
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
includeRatedoptionalFalseInclude rated items in ranking generation
  • Precision
>>> precision = obj.precision( user_id,
                               retrieved,
                               topn = 10,
                               relevance_threshold = 0,
                               include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Recall
>>> recall = obj.recall( user_id,
                         retrieved,
                         topn = 10,
                         relevance_threshold = 0,
                         include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Area Under the ROC Curve (AUC)
>>> auc = obj.AUC( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Mean Average precision
>>> map = obj.MAP( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Normalized Discounted Cumulative Gain
>>> map = obj.nDCG( user_id,
                    retrieved,
                    topn = 10,
                    relevance_threshold = 0,
                    include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation

pyreclab.SVD

  • Instance creation
>>> obj = pyreclab.SVD( factors = 1000,
                        dataset = filename,
                        dlmchar = b'\t',
                        header = False,
                        usercol = 0,
                        itemcol = 1,
                        ratingcol = 2 )
ParameterTypeDefault valueDescription
factorsoptional1000Number of latent factors in matrix factorization
datasetmandatoryN.A.Dataset filename with fields: userid, itemid and rating
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseWhether dataset filename contains a header line to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
  • Training
>>> obj.train( maxiter = 100, lr = 0.01, lamb = 0.1, progress = False )
ParameterTypeDefault valueDescription
maxiteroptional100Maximum number of iterations reached without convergence
lroptional0.01Learning rate
lamboptional0.1Regularization parameter
progressoptionalFalseShow progress bar
  • Rating prediction
>>> prediction = obj.predict( userId, itemId )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
itemIdmandatoryN.A.Item identifier
  • Top-N item recommendation
>>> ranking = obj.recommend( userId, topN, includeRated )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
topNoptional10Top N items to recommend
includeRatedoptionalFalseInclude rated items in ranking generation
  • Testing and evaluation for prediction
>>> predictionList, mae, rmse = obj.test( input_file = testset,
                                          dlmchar = b'\t',
                                          header = False,
                                          usercol = 0,
                                          itemcol = 1,
                                          ratingcol = 2,
                                          output_file = 'predictions.csv' )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
output_fileoptionalN.A.Output file to write predictions
  • Testing for recommendation
>>> recommendationList, map, ndcg = obj.testrec( input_file = testset,
                                                 dlmchar = b'\t',
                                                 header = False,
                                                 usercol = 0,
                                                 itemcol = 1,
                                                 ratingcol = 2,
                                                 topn = 10,
                                                 output_file = 'ranking.json',
                                                 relevance_threshold = 2,
                                                 includeRated = False )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
topnoptional10Top N items to recommend
output_fileoptionalN.A.Output file to write predictions
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
includeRatedoptionalFalseInclude rated items in ranking generation
  • Precision
>>> precision = obj.precision( user_id,
                               retrieved,
                               topn = 10,
                               relevance_threshold = 0,
                               include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Recall
>>> recall = obj.recall( user_id,
                         retrieved,
                         topn = 10,
                         relevance_threshold = 0,
                         include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Area Under the ROC Curve (AUC)
>>> auc = obj.AUC( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Mean Average precision
>>> map = obj.MAP( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Normalized Discounted Cumulative Gain
>>> map = obj.nDCG( user_id,
                    retrieved,
                    topn = 10,
                    relevance_threshold = 0,
                    include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Loss
>>> current_loss = obj.loss()
  • Reset factors
>>> obj.reset()

pyreclab.MostPopular

  • Instance creation
>>> obj = pyreclab.MostPopular( dataset = filename,
                                dlmchar = b'\t',
                                header = False,
                                usercol = 0,
                                itemcol = 1,
                                ratingcol = 2 )
ParameterTypeDefault valueDescription
datasetmandatoryN.A.Dataset filename with fields: userid, itemid and rating
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseWhether dataset filename contains a header line to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
  • Training
>>> obj.train( progress = False )
ParameterTypeDefault valueDescription
progressoptionalFalseShow progress bar
  • Top-N item recommendation
>>> ranking = obj.recommend( userId, topN, includeRated )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
topNoptional10Top N items to recommend
includeRatedoptionalFalseInclude rated items in ranking generation
  • Testing for recommendation
>>> recommendationList, map, ndcg = obj.testrec( input_file = testset,
                                                 dlmchar = b'\t',
                                                 header = False,
                                                 usercol = 0,
                                                 itemcol = 1,
                                                 ratingcol = 2,
                                                 topn = 10,
                                                 output_file = 'ranking.json',
                                                 relevance_threshold = 2,
                                                 includeRated = False )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
output_fileoptionalN.A.Output file to write rankings
topNoptional10Top N items to recommend
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
includeRatedoptionalFalseInclude rated items in ranking generation
  • Precision
>>> precision = obj.precision( user_id,
                               retrieved,
                               topn = 10,
                               relevance_threshold = 0,
                               include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Recall
>>> recall = obj.recall( user_id,
                         retrieved,
                         topn = 10,
                         relevance_threshold = 0,
                         include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Area Under the ROC Curve (AUC)
>>> auc = obj.AUC( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Mean Average precision
>>> map = obj.MAP( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Normalized Discounted Cumulative Gain
>>> map = obj.nDCG( user_id,
                    retrieved,
                    topn = 10,
                    relevance_threshold = 0,
                    include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation

pyreclab.IFAls

  • Instance creation
>>> obj = pyreclab.IFAls( factors = 50,
                          dataset = filename,
                          dlmchar = b'\t',
                          header = False,
                          usercol = 0,
                          itemcol = 1,
                          observationcol = 2 )
ParameterTypeDefault valueDescription
factorsoptional50Number of latent factors in matrix factorization
datasetmandatoryN.A.Dataset filename with fields: userid, itemid and rating
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseWhether dataset filename contains a header line to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
observationcoloptional2Observation column position in dataset file
  • Training
>>> obj.train( maxiter, lambd, progress = False )
ParameterTypeDefault valueDescription
alsNumIteroptional5Number of iterations in ALS algorithm
lambdoptional10Regularization parameter
progressoptionalFalseShow progress bar
  • Top-N item recommendation
>>> ranking = obj.recommend( userId, topN, includeRated )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
topNoptional10Top N items to recommend
includeRatedoptionalFalseInclude rated items in ranking generation
  • Testing for recommendation
>>> recommendationList, map, ndcg = obj.testrec( input_file = testset,
                                                 dlmchar = b'\t',
                                                 header = False,
                                                 usercol = 0,
                                                 itemcol = 1,
                                                 ratingcol = 2,
                                                 topn = 10,
                                                 output_file = 'ranking.json',
                                                 relevance_threshold = 2,
                                                 includeRated = False )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
output_fileoptionalN.A.Output file to write rankings
topNoptional10Top N items to recommend
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
includeRatedoptionalFalseInclude rated items in ranking generation
  • Precision
>>> precision = obj.precision( user_id,
                               retrieved,
                               topn = 10,
                               relevance_threshold = 0,
                               include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Recall
>>> recall = obj.recall( user_id,
                         retrieved,
                         topn = 10,
                         relevance_threshold = 0,
                         include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Area Under the ROC Curve (AUC)
>>> auc = obj.AUC( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Mean Average precision
>>> map = obj.MAP( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Normalized Discounted Cumulative Gain
>>> map = obj.nDCG( user_id,
                    retrieved,
                    topn = 10,
                    relevance_threshold = 0,
                    include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Reset factors
>>> obj.reset()

pyreclab.IFAlsConjugateGradient

  • Instance creation
>>> obj = pyreclab.IFAlsConjugateGradient( factors = 50,
                                           dataset = filename,
                                           dlmchar = b'\t',
                                           header = False,
                                           usercol = 0,
                                           itemcol = 1,
                                           observationcol = 2 )
ParameterTypeDefault valueDescription
factorsoptional50Number of latent factors in matrix factorization
datasetmandatoryN.A.Dataset filename with fields: userid, itemid and rating
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseWhether dataset filename contains a header line to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
observationcoloptional2Observation column position in dataset file
  • Training
>>> obj.train( alsNumIter, lambd, cgNumIter, progress = False )
ParameterTypeDefault valueDescription
alsNumIteroptional5Number of iterations in ALS algorithm
lambdoptional10Regularization parameter
cgNumIteroptional2Number of iterations in Conjugate Gradient algorithm
progressoptionalFalseShow progress bar
  • Top-N item recommendation
>>> ranking = obj.recommend( userId, topN, includeRated )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
topNoptional10Top N items to recommend
includeRatedoptionalFalseInclude rated items in ranking generation
  • Testing for recommendation
>>> recommendationList, map, ndcg = obj.testrec( input_file = testset,
                                                 dlmchar = b'\t',
                                                 header = False,
                                                 usercol = 0,
                                                 itemcol = 1,
                                                 ratingcol = 2,
                                                 topn = 10,
                                                 output_file = 'ranking.json',
                                                 relevance_threshold = 2,
                                                 includeRated = False )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
output_fileoptionalN.A.Output file to write rankings
topNoptional10Top N items to recommend
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
includeRatedoptionalFalseInclude rated items in ranking generation
  • Precision
>>> precision = obj.precision( user_id,
                               retrieved,
                               topn = 10,
                               relevance_threshold = 0,
                               include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Recall
>>> recall = obj.recall( user_id,
                         retrieved,
                         topn = 10,
                         relevance_threshold = 0,
                         include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Area Under the ROC Curve (AUC)
>>> auc = obj.AUC( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Mean Average precision
>>> map = obj.MAP( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Normalized Discounted Cumulative Gain
>>> map = obj.nDCG( user_id,
                    retrieved,
                    topn = 10,
                    relevance_threshold = 0,
                    include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Reset factors
>>> obj.reset()

pyreclab.BprMf

  • Instance creation
>>> obj = pyreclab.BprMf( factors = 20,
                          dataset = filename,
                          dlmchar = b'\t',
                          header = False,
                          usercol = 0,
                          itemcol = 1,
                          observationcol = 2 )
ParameterTypeDefault valueDescription
factorsoptional20Number of latent factors in matrix factorization
datasetmandatoryN.A.Dataset filename with fields: userid, itemid and rating
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseWhether dataset filename contains a header line to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
observationcoloptional2Observation column position in dataset file
  • Training
>>> obj.train( maxiter = 100,
               lr = 0.1,
               lambda_w = 0.01,
               lambda_hp = 0.01,
               lambda_hm = 0.01,
               progress = True )
ParameterTypeDefault valueDescription
maxiteroptional100Number of iterations
lroptional0.1Learning rate
lambda_woptional0.01Regularization parameter for the user features
lambda_hpoptional0.01Regularization parameter for the item features and positive updates
lambda_hmoptional0.01Regularization parameter for the item features and negative updates
progressoptionalFalseShow progress bar
  • Top-N item recommendation
>>> ranking = obj.recommend( userId, topN, includeRated )
ParameterTypeDefault valueDescription
userIdmandatoryN.A.User identifier
topNoptional10Top N items to recommend
includeRatedoptionalFalseInclude rated items in ranking generation
  • Testing for recommendation
>>> recommendationList, map, ndcg = obj.testrec( input_file = testset,
                                                 dlmchar = b'\t',
                                                 header = False,
                                                 usercol = 0,
                                                 itemcol = 1,
                                                 ratingcol = 2,
                                                 topn = 10,
                                                 output_file = 'ranking.json',
                                                 relevance_threshold = 2,
                                                 includeRated = False )
ParameterTypeDefault valueDescription
input_filemandatoryN.A.Testset filename
dlmcharoptionaltabDelimiter character between fields (userid, itemid, rating)
headeroptionalFalseDataset filename contains first line header to skip
usercoloptional0User column position in dataset file
itemcoloptional1Item column position in dataset file
ratingcoloptional2Rating column position in dataset file
output_fileoptionalN.A.Output file to write rankings
topNoptional10Top N items to recommend
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
includeRatedoptionalFalseInclude rated items in ranking generation
  • Precision
>>> precision = obj.precision( user_id,
                               retrieved,
                               topn = 10,
                               relevance_threshold = 0,
                               include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Recall
>>> recall = obj.recall( user_id,
                         retrieved,
                         topn = 10,
                         relevance_threshold = 0,
                         include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Area Under the ROC Curve (AUC)
>>> auc = obj.AUC( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Mean Average precision
>>> map = obj.MAP( user_id,
                   retrieved,
                   topn = 10,
                   relevance_threshold = 0,
                   include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Normalized Discounted Cumulative Gain
>>> map = obj.nDCG( user_id,
                    retrieved,
                    topn = 10,
                    relevance_threshold = 0,
                    include_rated = False )
ParameterTypeDefault valueDescription
user_idmandatoryN.A.User identifier
retrievedoptionalN.A.Recommendation list for user 'user_id'
topnoptional10Top N items to recommend. If 'retrieved' is provided, this value will be set to 'retrieved' length
relevance_thresholdoptional0Lower threshold to consider an item as relevant ( threshold value included )
include_ratedoptionalFalseInclude rated items in ranking generation
  • Loss
>>> current_loss = obj.loss()
  • Reset factors
>>> obj.reset()

On roadmap

  • Add Windows support.
  • Multi-threading.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial