QuickRank  v2.0
QuickRank: A C++ suite of Learning to Rank algorithms
Public Member Functions | Static Public Member Functions | Private Member Functions | Friends | List of all members
quickrank::learning::LTR_Algorithm Class Referenceabstract

#include <ltr_algorithm.h>

Inheritance diagram for quickrank::learning::LTR_Algorithm:
quickrank::learning::CustomLTR quickrank::learning::forests::Mart quickrank::learning::forests::Rankboost quickrank::learning::linear::CoordinateAscent quickrank::learning::linear::LineSearch quickrank::learning::forests::LambdaMart quickrank::learning::forests::ObliviousMart quickrank::learning::forests::ObliviousLambdaMart

Public Member Functions

 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 std::string name () const =0
 Returns the name of the ranker. More...
 
virtual void learn (std::shared_ptr< data::Dataset > training_dataset, std::shared_ptr< data::Dataset > validation_dataset, std::shared_ptr< metric::ir::Metric > metric, size_t partial_save, const std::string model_filename)=0
 Executes the learning process. 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 Score score_document (const Feature *d) const =0
 Returns the score of a given document. More...
 
virtual std::shared_ptr< std::vector< Score > > partial_scores_document (const Feature *d) const
 Returns the partial score of a given document, tree by tree. More...
 
virtual void save (std::string model_filename, int suffix=-1) const
 Save the current model to the output_file. More...
 
virtual pugi::xml_document * get_xml_model () const =0
 Return the xml model representing the current object. 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...
 

Static Public Member Functions

static std::shared_ptr< LTR_Algorithmload_model_from_file (std::string model_filename)
 Load a model from a given XML file. More...
 

Private Member Functions

virtual std::ostream & put (std::ostream &os) const =0
 Prints the description of Algorithm, including its parameters. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const LTR_Algorithm &a)
 The output stream operator. More...
 

Constructor & Destructor Documentation

quickrank::learning::LTR_Algorithm::LTR_Algorithm ( )
inline
quickrank::learning::LTR_Algorithm::LTR_Algorithm ( const pugi::xml_document &  model)

Generates a LTR_Algorithm instance from a previously saved XML model.

virtual quickrank::learning::LTR_Algorithm::~LTR_Algorithm ( )
inlinevirtual
quickrank::learning::LTR_Algorithm::LTR_Algorithm ( const LTR_Algorithm other)
delete

Avoid inefficient copy constructor.

Member Function Documentation

virtual std::shared_ptr<std::vector<double> > quickrank::learning::LTR_Algorithm::get_weights ( ) const
inlinevirtual

Return the weights for the ensemble models (only).

Default implementation will do nothing (default for non ensemble models).

Reimplemented in quickrank::learning::forests::Rankboost, quickrank::learning::forests::Mart, quickrank::learning::linear::LineSearch, and quickrank::learning::linear::CoordinateAscent.

virtual pugi::xml_document* quickrank::learning::LTR_Algorithm::get_xml_model ( ) const
pure virtual
virtual void quickrank::learning::LTR_Algorithm::learn ( std::shared_ptr< data::Dataset training_dataset,
std::shared_ptr< data::Dataset validation_dataset,
std::shared_ptr< metric::ir::Metric metric,
size_t  partial_save,
const std::string  model_filename 
)
pure virtual

Executes the learning process.

Parameters
training_datasetThe training dataset.
validation_datasetThe validation training dataset.
metricThe metric to be optimized.
partial_saveAllows to save a partial model every given number of iterations.
model_filenameThe file where the model, and the partial models, are saved.

Implemented in quickrank::learning::forests::Rankboost, quickrank::learning::linear::LineSearch, quickrank::learning::CustomLTR, quickrank::learning::linear::CoordinateAscent, and quickrank::learning::forests::Mart.

std::shared_ptr< LTR_Algorithm > quickrank::learning::LTR_Algorithm::load_model_from_file ( std::string  model_filename)
static

Load a model from a given XML file.

Parameters
model_filenameThe input file name.
virtual std::string quickrank::learning::LTR_Algorithm::name ( ) const
pure virtual
LTR_Algorithm& quickrank::learning::LTR_Algorithm::operator= ( const LTR_Algorithm )
delete

Avoid inefficient copy assignment.

virtual std::shared_ptr<std::vector<Score> > quickrank::learning::LTR_Algorithm::partial_scores_document ( const Feature d) const
inlinevirtual

Returns the partial score of a given document, tree by tree.

Parameters
dis a pointer to the document to be evaluated
next_fx_offsetThe offset to the next feature in the data representation.
Note
Each algorithm has a different implementation.

Reimplemented in quickrank::learning::forests::Rankboost, and quickrank::learning::forests::Mart.

virtual void quickrank::learning::LTR_Algorithm::print_additional_stats ( void  ) const
inlinevirtual

Print additional statistics.

At the moment this include only number of comparisons for tree-based algorithms.

Reimplemented in quickrank::learning::forests::Mart.

virtual std::ostream& quickrank::learning::LTR_Algorithm::put ( std::ostream &  os) const
privatepure virtual
void quickrank::learning::LTR_Algorithm::save ( std::string  model_filename,
int  suffix = -1 
) const
virtual

Save the current model to the output_file.

Parameters
model_filenameThe output file name.
suffixThe suffix used to identify partial model saves.
void quickrank::learning::LTR_Algorithm::score_dataset ( std::shared_ptr< data::Dataset dataset,
Score scores 
) const
virtual

Given and input dateset, the current ranker generates scores for each instance and store the in the scores vector.

Parameters
datasetThe dataset to be scored.
scoresThe vector where scores are stored.
Note
Before scoring it invokes the function preprocess_dataset. Usually this does not need to be overridden.
virtual Score quickrank::learning::LTR_Algorithm::score_document ( const Feature d) const
pure virtual

Returns the score of a given document.

Parameters
dis a pointer to the document to be evaluated
Note
Each algorithm has a different implementation.

Implemented in quickrank::learning::forests::Rankboost, quickrank::learning::linear::LineSearch, quickrank::learning::CustomLTR, quickrank::learning::linear::CoordinateAscent, and quickrank::learning::forests::Mart.

virtual bool quickrank::learning::LTR_Algorithm::update_weights ( std::shared_ptr< std::vector< double >>  weights)
inlinevirtual

Update the weights for the ensemble models (only).

Default implementation will do nothing (default for non ensemble models).

Reimplemented in quickrank::learning::forests::Mart, quickrank::learning::linear::LineSearch, and quickrank::learning::linear::CoordinateAscent.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const LTR_Algorithm a 
)
friend

The output stream operator.


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