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

This implements the RankBoost algorithm. More...

#include <rankboost.h>

Inheritance diagram for quickrank::learning::forests::Rankboost:
quickrank::learning::LTR_Algorithm

Public Member Functions

 Rankboost (size_t max_wr)
 
 Rankboost (const pugi::xml_document &model)
 
virtual ~Rankboost ()
 
 Rankboost (const Rankboost &other)=delete
 Avoid inefficient copy constructor. More...
 
Rankboostoperator= (const Rankboost &)=delete
 Avoid inefficient copy assignment. More...
 
virtual std::string name () const
 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)
 Executes the learning process. More...
 
virtual Score score_document (const Feature *d) const
 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 scores of a given document, tree. More...
 
virtual pugi::xml_document * get_xml_model () const
 Return the xml model representing the current object. More...
 
virtual bool update_weights (std::vector< double > &weights)
 
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...
 
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...
 

Static Public Attributes

static const std::string NAME_ = "RANKBOOST"
 

Private Member Functions

void init (std::shared_ptr< data::Dataset > training_dataset, std::shared_ptr< data::Dataset > validation_dataset)
 
void compute_pi (std::shared_ptr< data::Dataset > dataset)
 
WeakRankercompute_weak_ranker (std::shared_ptr< data::Dataset > dataset)
 
void update_d (std::shared_ptr< data::Dataset > dataset, WeakRanker *wr, float alpha)
 
MetricScore compute_metric_score (std::shared_ptr< data::Dataset > dataset, std::shared_ptr< quickrank::metric::ir::Metric > scorer)
 
void clean (std::shared_ptr< data::Dataset > dataset)
 
virtual std::ostream & put (std::ostream &os) const
 Prints the description of Algorithm, including its parameters. More...
 

Private Attributes

float *** D = NULL
 
float ** PI = NULL
 
Feature ** THETA = NULL
 
unsigned int * n_theta = NULL
 
unsigned int *** SDF = NULL
 
Scoretraining_scores = NULL
 
Scorevalidation_scores = NULL
 
size_t T
 
size_t best_T
 
bool go_parallel
 
char const * omp_schedule
 
WeakRanker ** weak_rankers = NULL
 
float * alphas = NULL
 
float best_r = 0.0
 
float max_alpha = 0.0
 
float r_t = 0.0
 
float z_t = 1.0
 

Friends

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

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...
 

Detailed Description

This implements the RankBoost algorithm.

Freund, Y., Iyer, R., Schapire, R. E., & Singer, Y. (2003). An efficient boosting algorithm for combining preferences. The Journal of machine learning research, 4, 933-969.

Constructor & Destructor Documentation

quickrank::learning::forests::Rankboost::Rankboost ( size_t  max_wr)
quickrank::learning::forests::Rankboost::Rankboost ( const pugi::xml_document &  model)
quickrank::learning::forests::Rankboost::~Rankboost ( )
virtual
quickrank::learning::forests::Rankboost::Rankboost ( const Rankboost other)
delete

Avoid inefficient copy constructor.

Member Function Documentation

void quickrank::learning::forests::Rankboost::clean ( std::shared_ptr< data::Dataset dataset)
private
MetricScore quickrank::learning::forests::Rankboost::compute_metric_score ( std::shared_ptr< data::Dataset dataset,
std::shared_ptr< quickrank::metric::ir::Metric scorer 
)
private
void quickrank::learning::forests::Rankboost::compute_pi ( std::shared_ptr< data::Dataset dataset)
private
WeakRanker * quickrank::learning::forests::Rankboost::compute_weak_ranker ( std::shared_ptr< data::Dataset dataset)
private
std::shared_ptr< std::vector< double > > quickrank::learning::forests::Rankboost::get_weights ( ) const
virtual

Return the weights for the ensemble models (only).

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

Reimplemented from quickrank::learning::LTR_Algorithm.

pugi::xml_document * quickrank::learning::forests::Rankboost::get_xml_model ( ) const
virtual

Return the xml model representing the current object.

Implements quickrank::learning::LTR_Algorithm.

void quickrank::learning::forests::Rankboost::init ( std::shared_ptr< data::Dataset training_dataset,
std::shared_ptr< data::Dataset validation_dataset 
)
private
void quickrank::learning::forests::Rankboost::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 
)
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.

Implements quickrank::learning::LTR_Algorithm.

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

Returns the name of the ranker.

Implements quickrank::learning::LTR_Algorithm.

Rankboost& quickrank::learning::forests::Rankboost::operator= ( const Rankboost )
delete

Avoid inefficient copy assignment.

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

Returns the partial scores of a given document, tree.

Parameters
dis a pointer to the document to be evaluated

Reimplemented from quickrank::learning::LTR_Algorithm.

std::ostream & quickrank::learning::forests::Rankboost::put ( std::ostream &  os) const
privatevirtual

Prints the description of Algorithm, including its parameters.

Implements quickrank::learning::LTR_Algorithm.

Score quickrank::learning::forests::Rankboost::score_document ( const Feature d) const
virtual

Returns the score of a given document.

Implements quickrank::learning::LTR_Algorithm.

void quickrank::learning::forests::Rankboost::update_d ( std::shared_ptr< data::Dataset dataset,
WeakRanker wr,
float  alpha 
)
private
bool quickrank::learning::forests::Rankboost::update_weights ( std::vector< double > &  weights)
virtual

Friends And Related Function Documentation

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

The output stream operator.

Member Data Documentation

float* quickrank::learning::forests::Rankboost::alphas = NULL
private
float quickrank::learning::forests::Rankboost::best_r = 0.0
private
size_t quickrank::learning::forests::Rankboost::best_T
private
float*** quickrank::learning::forests::Rankboost::D = NULL
private
bool quickrank::learning::forests::Rankboost::go_parallel
private
float quickrank::learning::forests::Rankboost::max_alpha = 0.0
private
unsigned int* quickrank::learning::forests::Rankboost::n_theta = NULL
private
const std::string quickrank::learning::forests::Rankboost::NAME_ = "RANKBOOST"
static
char const* quickrank::learning::forests::Rankboost::omp_schedule
private
float** quickrank::learning::forests::Rankboost::PI = NULL
private
float quickrank::learning::forests::Rankboost::r_t = 0.0
private
unsigned int*** quickrank::learning::forests::Rankboost::SDF = NULL
private
size_t quickrank::learning::forests::Rankboost::T
private
Feature** quickrank::learning::forests::Rankboost::THETA = NULL
private
Score* quickrank::learning::forests::Rankboost::training_scores = NULL
private
Score* quickrank::learning::forests::Rankboost::validation_scores = NULL
private
WeakRanker** quickrank::learning::forests::Rankboost::weak_rankers = NULL
private
float quickrank::learning::forests::Rankboost::z_t = 1.0
private

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