Automatically exported from
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

jforests is a Java library that implements many tree-based learning algorithms.

jforests can be used for regression, classification and ranking problems. The latest release can be downloaded from

The following tutorial shows how jforests can be used for learning a ranking model using the LambdaMART algorithm.

#Learning to Rank with LambdaMART

##Data Sets Format jforests uses the following format for its input data sets (same as the one used in SVMLight):

<line> .=. <relevance> qid:<qid> <feature>:<value> ... <feature>:<value> 
<relevance> .=. <integer>
<qid> .=. <positive integer>
<feature> .=. <positive integer>
<value> .=. <float>

For this tutorial, we will use the sample data set which is available here.

##Converting Data Sets to Binary Format In order to speed up the computations, jforests converts its input data sets to binary format. We are assuming that you have unzipped the above sample data set in a folder and are currently on that folder. You should have also downloaded the latest jforests jar file and renamed it to 'jforests.jar' and put it in the same folder.

The following command can be used for converting data sets to binary format:

java -jar jforests.jar --cmd=generate-bin --ranking --folder . --file train.txt --file valid.txt --file test.txt

As this command shows, we are converting 'train.txt', 'valid.txt', and 'test.txt' to binary format. As a result 'train.bin', 'valid.bin', and 'test.bin' are generated.

##Learning the Ranking Model Once the input data sets are converted to the binary format, a ranking model can be trained on them.

First you need to specify the parameters of your machine learning algorithm. The following is a sample set of parameters for the LambdaMART algorithm:




Create a '' file in the current folder and save the above config in it.

Then the following command can be used for training a LambdaMART ensemble and storing it in the 'ensemble.txt' file:

java -jar jforests.jar --cmd=train --ranking --config-file --train-file train.bin --validation-file valid.bin --output-model ensemble.txt

##Predicting Scores of Documents Once you have the LambdaMART ensemble, you can use it for predicting scores of test documents. The following command performs this step and stores the results in the 'predcitions.txt' file.

java -jar jforests.jar --cmd=predict --ranking --model-file ensemble.txt --tree-type RegressionTree --test-file test.bin --output-file predictions.txt

Scores can then be used for measuring NDCG or other information retrieval measures.

Advanced Ranking Options

Jforests can be configured to change the used measure for LambdaMART using the learning.evaluation-metric entry in the file. Currently, NDCG is supported, as well as risk-sensitive evaluation measures such as URisk and TRisk - see RiskSensitiveLambdaMART.

#Source Code Source code is are available from the Github repository:

#Citation Policy If you use jforests for a research purpose, please use the following citation:

Y. Ganjisaffar, R. Caruana, C. Lopes, Bagging Gradient-Boosted Trees for High Precision, Low Variance Ranking Models, in SIGIR 2011, Beijing, China.


	author = {Yasser Ganjisaffar and Rich Caruana and Cristina Lopes},
	title = {Bagging Gradient-Boosted Trees for High Precision, Low Variance Ranking Models},
	booktitle = {Proceedings of the 34th international ACM SIGIR conference on Research and development in Information},
	series = {SIGIR '11},
	year = {2011},
	isbn = {978-1-4503-0757-4},
	location = {Beijing, China},
	pages = {85--94},
	numpages = {10},
	doi = {},
	acmid = {2009932},
	publisher = {ACM},
	address = {New York, NY, USA},

If you use risk-sensitive learning to rank, please see RiskSensitiveLambdaMART for citation information.


Copyright (c) 2011-2015 Yasser Ganjisaffar

Published under Apache License 2.0