Recommender System using JAVA & LibRec

LibRec is a promising JAVA library for Recommender Systems. It implements a lot of Recommender Algorithms. It consists of three major components: Generic Interfaces, Data Structures and Recommendation Algorithms.

Here are some useful resources for LibRec:

LibRec Tutorial

LibRec Examples on Real Data Sets & comparison with other recommendation libraries

A Collection of Recommendation Data Sets

Downloading and Running LibRec

1. Download the latest release zip file and unzip it to a local directory.

2. Run command or terminal and use “cd” to locate the library directory.

3. Extract librec.jar library

4. Run the LibRec library by: java -jar librec.jar

After you extract the librec.jar file, you can see librec.conf file in your directory. This configuration file contains all the necessary settings about which dataset to use, what evaluation measure to use, etc. It also contains the path to output evaluation result. However, when you run java -jar librec.jar, you can also see the result in your terminal.

Output results = evaluation measurements followed by the recommender options and execution time.

Rating prediction: MAE, RMSE, NMAE, rMAE, rRMSE, MPE
Item recommendation: Precision@5, Precision@10, Recall@5, Recall@10, AUC, MAP, NDCG, MRR

By default, LibRec uses FilmTrust’s ratings dataset. You can use your own dataset (CSV format, txt format, etc.) as well. For that, you just need to edit the dataset path in librec.config file.

You can also use your own custom config file instead of using the default librec.config. To use your custom config file, you can modify the command as below:

java -jar librec.jar -c configFile1.conf [configFile2.conf …]

LibRec also provides some demo config files (like UserKNN.config, ItemKNN.config, SVD++.config, etc.) that can be used to implement some particular recommendation algorithms. These demo configs are present inside your “librec-folder/demo/config” directory.

Here’s how UserKNN.config looks like. The evaluation result output is displayed in the terminal and also saved in “librec-folder/demo/Results” directory.

dataset.ratings.wins=.\\demo\\Datasets\\FilmTrust\\ratings.txt
dataset.ratings.lins=./demo/Datasets/FilmTrust/ratings.txt

ratings.setup=-columns 0 1 2 -threshold -1

recommender=UserKNN
evaluation.setup=cv -k 5 -p on –rand-seed 1 –test-view all
item.ranking=off -topN -1 -ignore -1

similarity=PCC
num.shrinkage=30

num.neighbors=50

output.setup=on -dir ./demo/Results/

ItemKNN.config

dataset.ratings.wins=.\\demo\\Datasets\\FilmTrust\\ratings.txt
dataset.ratings.lins=./demo/Datasets/FilmTrust/ratings.txt

ratings.setup=-columns 0 1 2 -threshold -1

recommender=ItemKNN
evaluation.setup=cv -k 5 -p on –rand-seed 1 –test-view all
item.ranking=off -topN -1 -ignore -1

similarity=PCC
num.shrinkage=30

num.neighbors=50

output.setup=on -dir ./demo/Results/

Hope this helps.
Thanks.