QuickRank  v2.0
QuickRank: A C++ suite of Learning to Rank algorithms
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
quickrank::learning::forests::LambdaMart Class Reference

#include <lambdamart.h>

Inheritance diagram for quickrank::learning::forests::LambdaMart:
quickrank::learning::forests::Mart quickrank::learning::LTR_Algorithm quickrank::learning::forests::ObliviousLambdaMart

Public Member Functions

 LambdaMart (size_t ntrees, double shrinkage, size_t nthresholds, size_t ntreeleaves, size_t minleafsupport, size_t esr)
 Initializes a new LambdaMart instance with the given learning parameters. More...
 
 LambdaMart (const pugi::xml_document &model)
 Generates a LTR_Algorithm instance from a previously saved XML model. More...
 
virtual ~LambdaMart ()
 
virtual std::string name () const
 Returns the name of the ranker. More...
 
- Public Member Functions inherited from quickrank::learning::forests::Mart
 Mart (size_t ntrees, double shrinkage, size_t nthresholds, size_t ntreeleaves, size_t minleafsupport, size_t valid_iterations)
 Initializes a new Mart instance with the given learning parameters. More...
 
 Mart (const pugi::xml_document &model)
 Generates a LTR_Algorithm instance from a previously saved XML model. More...
 
virtual ~Mart ()
 
virtual void learn (std::shared_ptr< data::Dataset > training_dataset, std::shared_ptr< data::Dataset > validation_dataset, std::shared_ptr< metric::ir::Metric > training_metric, size_t partial_save, const std::string output_basename)
 Start the learning process. More...
 
virtual Score score_document (const Feature *d) const
 Returns the score by the current ranker. More...
 
virtual std::shared_ptr< std::vector< Score > > partial_scores_document (const Feature *d) const
 Returns the partial scores of a given document, tree. More...
 
virtual void print_additional_stats (void) const
 Print additional statistics. More...
 
virtual bool update_weights (std::shared_ptr< std::vector< double >> weights)
 Update the weights for the ensemble models (only). More...
 
virtual std::shared_ptr< std::vector< double > > get_weights () const
 Return the weights for the ensemble models (only). More...
 
- Public Member Functions inherited from quickrank::learning::LTR_Algorithm
 LTR_Algorithm ()
 
 LTR_Algorithm (const pugi::xml_document &model)
 Generates a LTR_Algorithm instance from a previously saved XML model. More...
 
virtual ~LTR_Algorithm ()
 
 LTR_Algorithm (const LTR_Algorithm &other)=delete
 Avoid inefficient copy constructor. More...
 
LTR_Algorithmoperator= (const LTR_Algorithm &)=delete
 Avoid inefficient copy assignment. More...
 
virtual void score_dataset (std::shared_ptr< data::Dataset > dataset, Score *scores) const
 Given and input dateset, the current ranker generates scores for each instance and store the in the scores vector. More...
 
virtual void save (std::string model_filename, int suffix=-1) const
 Save the current model to the output_file. More...
 

Static Public Attributes

static const std::string NAME_ = "LAMBDAMART"
 
- Static Public Attributes inherited from quickrank::learning::forests::Mart
static const std::string NAME_ = "MART"
 

Protected Member Functions

virtual void init (std::shared_ptr< data::VerticalDataset > training_dataset)
 Prepares private data structurs befor training takes place. More...
 
virtual void clear (size_t num_features)
 De-allocates private data structure after training has taken place. More...
 
virtual void compute_pseudoresponses (std::shared_ptr< data::VerticalDataset > training_dataset, metric::ir::Metric *metric)
 Computes pseudo responses. More...
 
virtual std::unique_ptr< RegressionTreefit_regressor_on_gradient (std::shared_ptr< data::VerticalDataset > training_dataset)
 Fits a regression tree on the gradient given by the pseudo residuals. More...
 
- Protected Member Functions inherited from quickrank::learning::forests::Mart
virtual void update_modelscores (std::shared_ptr< data::Dataset > dataset, Score *scores, RegressionTree *tree)
 Updates scores with the last learnt regression tree. More...
 
virtual void update_modelscores (std::shared_ptr< data::VerticalDataset > dataset, Score *scores, RegressionTree *tree)
 
virtual pugi::xml_document * get_xml_model () const
 Return the xml model representing the current object. More...
 

Protected Attributes

double * instance_weights_ = NULL
 
- Protected Attributes inherited from quickrank::learning::forests::Mart
float ** thresholds_ = NULL
 
size_t * thresholds_size_ = NULL
 
double * scores_on_training_ = NULL
 
quickrank::Scorescores_on_validation_ = NULL
 
size_t validation_bestmodel_ = 0
 
double * pseudoresponses_ = NULL
 
Ensemble ensemble_model_
 
size_t ntrees_
 
double shrinkage_
 
size_t nthresholds_
 
size_t nleaves_
 
size_t minleafsupport_
 
size_t valid_iterations_
 
size_t ** sortedsid_ = NULL
 
size_t sortedsize_ = 0
 
RTRootHistogramhist_ = NULL
 

Additional Inherited Members

- Static Public Member Functions inherited from quickrank::learning::LTR_Algorithm
static std::shared_ptr< LTR_Algorithmload_model_from_file (std::string model_filename)
 Load a model from a given XML file. More...
 

Constructor & Destructor Documentation

quickrank::learning::forests::LambdaMart::LambdaMart ( size_t  ntrees,
double  shrinkage,
size_t  nthresholds,
size_t  ntreeleaves,
size_t  minleafsupport,
size_t  esr 
)
inline

Initializes a new LambdaMart instance with the given learning parameters.

Parameters
ntreesMaximum number of trees.
shrinkageLearning rate.
nthresholdsNumber of bins in discretization. 0 means no discretization.
ntreeleavesMaximum number of leaves in each tree.
minleafsupportMinimum number of instances in each leaf.
esrEarly stopping if no improvement after iterations on the validation set.
quickrank::learning::forests::LambdaMart::LambdaMart ( const pugi::xml_document &  model)
inline

Generates a LTR_Algorithm instance from a previously saved XML model.

virtual quickrank::learning::forests::LambdaMart::~LambdaMart ( )
inlinevirtual

Member Function Documentation

void quickrank::learning::forests::LambdaMart::clear ( size_t  num_features)
protectedvirtual

De-allocates private data structure after training has taken place.

Reimplemented from quickrank::learning::forests::Mart.

void quickrank::learning::forests::LambdaMart::compute_pseudoresponses ( std::shared_ptr< data::VerticalDataset training_dataset,
metric::ir::Metric metric 
)
protectedvirtual

Computes pseudo responses.

Parameters
training_datasetThe training data.
metricThe metric to be optimized.

Reimplemented from quickrank::learning::forests::Mart.

std::unique_ptr< RegressionTree > quickrank::learning::forests::LambdaMart::fit_regressor_on_gradient ( std::shared_ptr< data::VerticalDataset training_dataset)
protectedvirtual

Fits a regression tree on the gradient given by the pseudo residuals.

Parameters
training_datasetThe dataset used for training
Todo:
TODO: memory management of regression tree is wrong!!!

Reimplemented from quickrank::learning::forests::Mart.

Reimplemented in quickrank::learning::forests::ObliviousLambdaMart.

void quickrank::learning::forests::LambdaMart::init ( std::shared_ptr< data::VerticalDataset training_dataset)
protectedvirtual

Prepares private data structurs befor training takes place.

Reimplemented from quickrank::learning::forests::Mart.

virtual std::string quickrank::learning::forests::LambdaMart::name ( ) const
inlinevirtual

Returns the name of the ranker.

Reimplemented from quickrank::learning::forests::Mart.

Reimplemented in quickrank::learning::forests::ObliviousLambdaMart.

Member Data Documentation

double* quickrank::learning::forests::LambdaMart::instance_weights_ = NULL
protected
const std::string quickrank::learning::forests::LambdaMart::NAME_ = "LAMBDAMART"
static

The documentation for this class was generated from the following files: