QuickRank  v2.0
QuickRank: A C++ suite of Learning to Rank algorithms
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
quickrank::optimization::post_learning::pruning::Cleaver Class Referenceabstract

This implements various strategies for pruning ensembles. More...

#include <cleaver.h>

Inheritance diagram for quickrank::optimization::post_learning::pruning::Cleaver:
quickrank::optimization::post_learning::PostLearningOptimization quickrank::optimization::Optimization quickrank::optimization::post_learning::pruning::LastPruning quickrank::optimization::post_learning::pruning::LowWeightsPruning quickrank::optimization::post_learning::pruning::QualityLossPruning quickrank::optimization::post_learning::pruning::RandomPruning quickrank::optimization::post_learning::pruning::ScoreLossPruning quickrank::optimization::post_learning::pruning::SkipPruning

Public Types

enum  PruningMethod {
  PruningMethod::RANDOM, PruningMethod::LOW_WEIGHTS, PruningMethod::SKIP, PruningMethod::LAST,
  PruningMethod::QUALITY_LOSS, PruningMethod::SCORE_LOSS
}
 
- Public Types inherited from quickrank::optimization::Optimization
enum  OptimizationAlgorithm { OptimizationAlgorithm::EPRUNING }
 

Public Member Functions

 Cleaver (double pruning_rate)
 
 Cleaver (double pruning_rate, std::shared_ptr< learning::linear::LineSearch > lineSearch)
 
 Cleaver (const pugi::xml_document &model)
 
std::string name () const
 Returns the name of the optimizer. More...
 
virtual PruningMethod pruning_method () const =0
 Returns the pruning method of the algorithm. More...
 
virtual bool line_search_pre_pruning () const =0
 
virtual bool need_partial_score_dataset () const
 
virtual void pruning (std::set< unsigned int > &pruned_estimators, std::shared_ptr< data::Dataset > dataset, std::shared_ptr< metric::ir::Metric > scorer)=0
 
void optimize (std::shared_ptr< quickrank::learning::LTR_Algorithm > algo, std::shared_ptr< quickrank::data::Dataset > training_dataset, std::shared_ptr< quickrank::data::Dataset > validation_dataset, std::shared_ptr< quickrank::metric::ir::Metric > metric, size_t partial_save, const std::string model_filename)
 
virtual std::shared_ptr< data::Datasetfilter_dataset (std::shared_ptr< data::Dataset > dataset, std::set< unsigned int > &pruned_estimators) const
 Process the dataset filtering out features with 0-weight. More...
 
virtual pugi::xml_document * get_xml_model () const
 Return the xml model representing the current object. More...
 
virtual std::vector< float > & get_weigths ()
 Returns the learned weights. More...
 
- Public Member Functions inherited from quickrank::optimization::post_learning::PostLearningOptimization
bool is_pre_learning () const
 
- Public Member Functions inherited from quickrank::optimization::Optimization
 Optimization ()
 
 Optimization (const pugi::xml_document &model)
 Generates a LTR_Algorithm instance from a previously saved XML model. More...
 
virtual ~Optimization ()=default
 
 Optimization (const Optimization &other)=delete
 Avoid inefficient copy constructor. More...
 
Optimizationoperator= (const Optimization &)=delete
 Avoid inefficient copy assignment. More...
 
virtual void optimize (std::shared_ptr< learning::LTR_Algorithm > algo, 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 optimization process. More...
 
virtual void save (std::string model_filename, int suffix=-1) const
 Save the current model to the output_file. More...
 

Static Public Member Functions

static PruningMethod getPruningMethod (std::string name)
 
static std::string getPruningMethod (PruningMethod pruningMethod)
 
- Static Public Member Functions inherited from quickrank::optimization::Optimization
static std::shared_ptr< Optimizationload_model_from_file (std::string model_filename)
 Load a model from a given XML file. More...
 
static OptimizationAlgorithm getOptimizationAlgorithm (std::string name)
 
static std::string getPruningMethod (OptimizationAlgorithm optAlgo)
 

Static Public Attributes

static const std::vector< std::string > pruningMethodNames
 
static const std::string NAME_ = "CLEAVER"
 
- Static Public Attributes inherited from quickrank::optimization::Optimization
static const std::vector< std::string > optimizationAlgorithmNames
 

Protected Member Functions

std::ostream & put (std::ostream &os) const
 Prints the description of Algorithm, including its parameters. More...
 
virtual void score (data::Dataset *dataset, Score *scores) const
 
virtual void import_weights_from_line_search (std::set< unsigned int > &pruned_estimators)
 

Protected Attributes

double pruning_rate_
 
unsigned int estimators_to_prune_
 
unsigned int estimators_to_select_
 
std::shared_ptr< learning::linear::LineSearchlineSearch_
 
std::vector< float > weights_
 

Detailed Description

This implements various strategies for pruning ensembles.

This optimization algorithm expect the datasets to be in the partial scores format (i.e., a column for each ensemble, with the partial score returned by that ensamble on each document (row of the original dataset)

Member Enumeration Documentation

Enumerator
RANDOM 
LOW_WEIGHTS 
SKIP 
LAST 
QUALITY_LOSS 
SCORE_LOSS 

Constructor & Destructor Documentation

quickrank::optimization::post_learning::pruning::Cleaver::Cleaver ( double  pruning_rate)
quickrank::optimization::post_learning::pruning::Cleaver::Cleaver ( double  pruning_rate,
std::shared_ptr< learning::linear::LineSearch lineSearch 
)
quickrank::optimization::post_learning::pruning::Cleaver::Cleaver ( const pugi::xml_document &  model)

Member Function Documentation

std::shared_ptr< data::Dataset > quickrank::optimization::post_learning::pruning::Cleaver::filter_dataset ( std::shared_ptr< data::Dataset dataset,
std::set< unsigned int > &  pruned_estimators 
) const
virtual

Process the dataset filtering out features with 0-weight.

virtual std::vector<float>& quickrank::optimization::post_learning::pruning::Cleaver::get_weigths ( )
inlinevirtual

Returns the learned weights.

pugi::xml_document * quickrank::optimization::post_learning::pruning::Cleaver::get_xml_model ( ) const
virtual

Return the xml model representing the current object.

Implements quickrank::optimization::Optimization.

static PruningMethod quickrank::optimization::post_learning::pruning::Cleaver::getPruningMethod ( std::string  name)
inlinestatic
static std::string quickrank::optimization::post_learning::pruning::Cleaver::getPruningMethod ( PruningMethod  pruningMethod)
inlinestatic
void quickrank::optimization::post_learning::pruning::Cleaver::import_weights_from_line_search ( std::set< unsigned int > &  pruned_estimators)
protectedvirtual
virtual bool quickrank::optimization::post_learning::pruning::Cleaver::line_search_pre_pruning ( ) const
pure virtual
std::string quickrank::optimization::post_learning::pruning::Cleaver::name ( ) const
inlinevirtual

Returns the name of the optimizer.

Implements quickrank::optimization::Optimization.

virtual bool quickrank::optimization::post_learning::pruning::Cleaver::need_partial_score_dataset ( ) const
inlinevirtual
void quickrank::optimization::post_learning::pruning::Cleaver::optimize ( std::shared_ptr< quickrank::learning::LTR_Algorithm algo,
std::shared_ptr< quickrank::data::Dataset training_dataset,
std::shared_ptr< quickrank::data::Dataset validation_dataset,
std::shared_ptr< quickrank::metric::ir::Metric metric,
size_t  partial_save,
const std::string  model_filename 
)
virtual void quickrank::optimization::post_learning::pruning::Cleaver::pruning ( std::set< unsigned int > &  pruned_estimators,
std::shared_ptr< data::Dataset dataset,
std::shared_ptr< metric::ir::Metric scorer 
)
pure virtual
virtual PruningMethod quickrank::optimization::post_learning::pruning::Cleaver::pruning_method ( ) const
pure virtual
std::ostream & quickrank::optimization::post_learning::pruning::Cleaver::put ( std::ostream &  os) const
protectedvirtual

Prints the description of Algorithm, including its parameters.

Implements quickrank::optimization::Optimization.

void quickrank::optimization::post_learning::pruning::Cleaver::score ( data::Dataset dataset,
Score scores 
) const
protectedvirtual

Member Data Documentation

unsigned int quickrank::optimization::post_learning::pruning::Cleaver::estimators_to_prune_
protected
unsigned int quickrank::optimization::post_learning::pruning::Cleaver::estimators_to_select_
protected
std::shared_ptr<learning::linear::LineSearch> quickrank::optimization::post_learning::pruning::Cleaver::lineSearch_
protected
const std::string quickrank::optimization::post_learning::pruning::Cleaver::NAME_ = "CLEAVER"
static
double quickrank::optimization::post_learning::pruning::Cleaver::pruning_rate_
protected
const std::vector< std::string > quickrank::optimization::post_learning::pruning::Cleaver::pruningMethodNames
static
Initial value:
= {
"RANDOM", "LOW_WEIGHTS", "SKIP", "LAST", "QUALITY_LOSS", "SCORE_LOSS"
}
std::vector<float> quickrank::optimization::post_learning::pruning::Cleaver::weights_
protected

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