33 #include "pugixml/src/pugixml.hpp" 36 namespace optimization {
37 namespace post_learning {
55 std::shared_ptr<learning::linear::LineSearch> lineSearch);
57 Cleaver(
const pugi::xml_document &model);
73 virtual void pruning(std::set<unsigned int> &pruned_estimators,
74 std::shared_ptr<data::Dataset> dataset,
75 std::shared_ptr<metric::ir::Metric> scorer) = 0;
77 void optimize(std::shared_ptr<quickrank::learning::LTR_Algorithm> algo,
78 std::shared_ptr<quickrank::data::Dataset> training_dataset,
79 std::shared_ptr<quickrank::data::Dataset> validation_dataset,
80 std::shared_ptr<quickrank::metric::ir::Metric> metric,
82 const std::string model_filename);
86 std::shared_ptr<data::Dataset> dataset,
87 std::set<unsigned int> &pruned_estimators)
const;
95 auto i_item = std::find(pruningMethodNames.cbegin(),
96 pruningMethodNames.cend(),
98 if (i_item != pruningMethodNames.cend()) {
100 return PruningMethod(std::distance(pruningMethodNames.cbegin(), i_item));
104 throw std::invalid_argument(
"pruning method " + name +
" is not valid");
109 return pruningMethodNames[
static_cast<int>(pruningMethod)];
128 std::ostream &
put(std::ostream &os)
const;
133 std::set<unsigned int> &pruned_estimators);
Definition: dataset.cc:28
virtual bool need_partial_score_dataset() const
Definition: cleaver.h:69
double pruning_rate_
Definition: cleaver.h:120
std::string name() const
Returns the name of the optimizer.
Definition: cleaver.h:60
virtual std::shared_ptr< data::Dataset > filter_dataset(std::shared_ptr< data::Dataset > dataset, std::set< unsigned int > &pruned_estimators) const
Process the dataset filtering out features with 0-weight.
Definition: cleaver.cc:315
static PruningMethod getPruningMethod(std::string name)
Definition: cleaver.h:94
This class implements a Dataset to be used for a L-t-R task.
Definition: dataset.h:45
Cleaver(double pruning_rate)
Definition: cleaver.cc:45
virtual void score(data::Dataset *dataset, Score *scores) const
Definition: cleaver.cc:287
virtual std::vector< float > & get_weigths()
Returns the learned weights.
Definition: cleaver.h:113
Definition: post_learning_opt.h:30
static const std::string NAME_
Definition: cleaver.h:117
std::ostream & put(std::ostream &os) const
Prints the description of Algorithm, including its parameters.
Definition: cleaver.cc:89
static std::string getPruningMethod(PruningMethod pruningMethod)
Definition: cleaver.h:108
virtual void pruning(std::set< unsigned int > &pruned_estimators, std::shared_ptr< data::Dataset > dataset, std::shared_ptr< metric::ir::Metric > scorer)=0
unsigned int estimators_to_select_
Definition: cleaver.h:122
PruningMethod
Definition: cleaver.h:48
double Score
data type for instance truth label
Definition: types.h:30
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)
Definition: cleaver.cc:102
virtual PruningMethod pruning_method() const =0
Returns the pruning method of the algorithm.
virtual bool line_search_pre_pruning() const =0
std::vector< float > weights_
Definition: cleaver.h:125
static const std::vector< std::string > pruningMethodNames
Definition: cleaver.h:92
virtual void import_weights_from_line_search(std::set< unsigned int > &pruned_estimators)
Definition: cleaver.cc:301
virtual pugi::xml_document * get_xml_model() const
Return the xml model representing the current object.
Definition: cleaver.cc:248
std::shared_ptr< learning::linear::LineSearch > lineSearch_
Definition: cleaver.h:123
This implements various strategies for pruning ensembles.
Definition: cleaver.h:44
unsigned int estimators_to_prune_
Definition: cleaver.h:121