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::linear::LineSearch Class Reference

This implements the Line Search algorithm. More...

#include <line_search.h>

Inheritance diagram for quickrank::learning::linear::LineSearch:
quickrank::learning::LTR_Algorithm

Public Member Functions

 LineSearch (unsigned int num_points, double window_size, double reduction_factor, unsigned int max_iterations, unsigned int max_failed_vali, bool adaptive, unsigned int last_only=0)
 
 LineSearch (const pugi::xml_document &model)
 
virtual ~LineSearch ()
 
virtual std::string name () const
 Returns the name of the ranker. More...
 
unsigned int get_last_only () const
 
void set_last_only (unsigned int last_only)
 
void reset_weights ()
 
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< double > > get_weights () const
 Returns the learned weights. More...
 
virtual bool update_weights (std::shared_ptr< std::vector< double >> weights)
 Update the weights for the ensemble models (only). More...
 
virtual pugi::xml_document * get_xml_model () const
 Return the xml model representing the current object. 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 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 void print_additional_stats (void) const
 Print additional statistics. More...
 

Static Public Attributes

static const std::string NAME_ = "LINESEARCH"
 

Private Member Functions

virtual std::ostream & put (std::ostream &os) const
 Prints the description of Algorithm, including its parameters. More...
 
virtual void preCompute (Feature *training_dataset, unsigned int num_samples, unsigned int num_features, Score *pre_sum, double *weights, Score *training_score, unsigned int feature_exclude)
 
virtual void score (Feature *dataset, unsigned int num_samples, unsigned int num_features, double *weights, Score *scores)
 

Private Attributes

unsigned int num_points_
 
double window_size_
 
double reduction_factor_
 
unsigned int max_iterations_
 
unsigned int max_failed_vali_
 
bool adaptive_
 
unsigned int train_only_last_
 
std::vector< double > best_weights_
 

Friends

std::ostream & operator<< (std::ostream &os, const LineSearch &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 Line Search algorithm.

Constructor & Destructor Documentation

quickrank::learning::linear::LineSearch::LineSearch ( unsigned int  num_points,
double  window_size,
double  reduction_factor,
unsigned int  max_iterations,
unsigned int  max_failed_vali,
bool  adaptive,
unsigned int  last_only = 0 
)
quickrank::learning::linear::LineSearch::LineSearch ( const pugi::xml_document &  model)
quickrank::learning::linear::LineSearch::~LineSearch ( )
virtual

Member Function Documentation

unsigned int quickrank::learning::linear::LineSearch::get_last_only ( ) const
inline
virtual std::shared_ptr<std::vector<double> > quickrank::learning::linear::LineSearch::get_weights ( ) const
inlinevirtual

Returns the learned weights.

Reimplemented from quickrank::learning::LTR_Algorithm.

pugi::xml_document * quickrank::learning::linear::LineSearch::get_xml_model ( ) const
virtual

Return the xml model representing the current object.

Implements quickrank::learning::LTR_Algorithm.

void quickrank::learning::linear::LineSearch::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::linear::LineSearch::name ( ) const
inlinevirtual

Returns the name of the ranker.

Implements quickrank::learning::LTR_Algorithm.

void quickrank::learning::linear::LineSearch::preCompute ( Feature training_dataset,
unsigned int  num_samples,
unsigned int  num_features,
Score pre_sum,
double *  weights,
Score training_score,
unsigned int  feature_exclude 
)
privatevirtual
std::ostream & quickrank::learning::linear::LineSearch::put ( std::ostream &  os) const
privatevirtual

Prints the description of Algorithm, including its parameters.

Implements quickrank::learning::LTR_Algorithm.

void quickrank::learning::linear::LineSearch::reset_weights ( )
inline
void quickrank::learning::linear::LineSearch::score ( Feature dataset,
unsigned int  num_samples,
unsigned int  num_features,
double *  weights,
Score scores 
)
privatevirtual
Score quickrank::learning::linear::LineSearch::score_document ( const Feature d) const
virtual

Returns the score of a given document.

Implements quickrank::learning::LTR_Algorithm.

void quickrank::learning::linear::LineSearch::set_last_only ( unsigned int  last_only)
inline
bool quickrank::learning::linear::LineSearch::update_weights ( std::shared_ptr< std::vector< double >>  weights)
virtual

Update the weights for the ensemble models (only).

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

Reimplemented from quickrank::learning::LTR_Algorithm.

Friends And Related Function Documentation

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

The output stream operator.

Member Data Documentation

bool quickrank::learning::linear::LineSearch::adaptive_
private
std::vector<double> quickrank::learning::linear::LineSearch::best_weights_
private
unsigned int quickrank::learning::linear::LineSearch::max_failed_vali_
private
unsigned int quickrank::learning::linear::LineSearch::max_iterations_
private
const std::string quickrank::learning::linear::LineSearch::NAME_ = "LINESEARCH"
static
unsigned int quickrank::learning::linear::LineSearch::num_points_
private
double quickrank::learning::linear::LineSearch::reduction_factor_
private
unsigned int quickrank::learning::linear::LineSearch::train_only_last_
private
double quickrank::learning::linear::LineSearch::window_size_
private

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