![]() |
QuickRank
v2.0
QuickRank: A C++ suite of Learning to Rank algorithms
|
#include <mart.h>
Public Member Functions | |
| Mart (size_t ntrees, double shrinkage, size_t nthresholds, size_t ntreeleaves, size_t minleafsupport, size_t valid_iterations) | |
| Initializes a new Mart instance with the given learning parameters. More... | |
| Mart (const pugi::xml_document &model) | |
| Generates a LTR_Algorithm instance from a previously saved XML model. More... | |
| virtual | ~Mart () |
| virtual void | learn (std::shared_ptr< data::Dataset > training_dataset, std::shared_ptr< data::Dataset > validation_dataset, std::shared_ptr< metric::ir::Metric > training_metric, size_t partial_save, const std::string output_basename) |
| Start the learning process. More... | |
| virtual Score | score_document (const Feature *d) const |
| Returns the score by the current ranker. 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 void | print_additional_stats (void) const |
| Print additional statistics. More... | |
| virtual std::string | name () const |
| Returns the name of the ranker. 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... | |
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_Algorithm & | operator= (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... | |
Static Public Attributes | |
| static const std::string | NAME_ = "MART" |
Protected Member Functions | |
| virtual void | init (std::shared_ptr< data::VerticalDataset > training_dataset) |
| Prepares private data structures before training takes place. More... | |
| virtual void | clear (size_t num_features) |
| De-allocates private data structure after training has taken place. More... | |
| virtual void | compute_pseudoresponses (std::shared_ptr< data::VerticalDataset > training_dataset, metric::ir::Metric *metric) |
| Computes pseudo responses. More... | |
| virtual std::unique_ptr< RegressionTree > | fit_regressor_on_gradient (std::shared_ptr< data::VerticalDataset > training_dataset) |
| Fits a regression tree on the gradient given by the pseudo residuals. More... | |
| virtual void | update_modelscores (std::shared_ptr< data::Dataset > dataset, Score *scores, RegressionTree *tree) |
| Updates scores with the last learnt regression tree. More... | |
| virtual void | update_modelscores (std::shared_ptr< data::VerticalDataset > dataset, Score *scores, RegressionTree *tree) |
| virtual pugi::xml_document * | get_xml_model () const |
| Return the xml model representing the current object. More... | |
Protected Attributes | |
| float ** | thresholds_ = NULL |
| size_t * | thresholds_size_ = NULL |
| double * | scores_on_training_ = NULL |
| quickrank::Score * | scores_on_validation_ = NULL |
| size_t | validation_bestmodel_ = 0 |
| double * | pseudoresponses_ = NULL |
| Ensemble | ensemble_model_ |
| size_t | ntrees_ |
| double | shrinkage_ |
| size_t | nthresholds_ |
| size_t | nleaves_ |
| size_t | minleafsupport_ |
| size_t | valid_iterations_ |
| size_t ** | sortedsid_ = NULL |
| size_t | sortedsize_ = 0 |
| RTRootHistogram * | hist_ = NULL |
Private Member Functions | |
| virtual std::ostream & | put (std::ostream &os) const |
| Prints the description of Algorithm, including its parameters. More... | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Mart &a) |
| The output stream operator. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from quickrank::learning::LTR_Algorithm | |
| static std::shared_ptr< LTR_Algorithm > | load_model_from_file (std::string model_filename) |
| Load a model from a given XML file. More... | |
|
inline |
Initializes a new Mart instance with the given learning parameters.
| ntrees | Maximum number of trees. |
| shrinkage | Learning rate. |
| nthresholds | Number of bins in discretization. 0 means no discretization. |
| ntreeleaves | Maximum number of leaves in each tree. |
| minleafsupport | Minimum number of instances in each leaf. |
| valid_iterations | Early stopping if no improvement after iterations on the validation set. |
| quickrank::learning::forests::Mart::Mart | ( | const pugi::xml_document & | model | ) |
Generates a LTR_Algorithm instance from a previously saved XML model.
|
inlinevirtual |
|
protectedvirtual |
De-allocates private data structure after training has taken place.
Reimplemented in quickrank::learning::forests::LambdaMart.
|
protectedvirtual |
Computes pseudo responses.
| training_dataset | The training data. |
| metric | The metric to be optimized. |
Reimplemented in quickrank::learning::forests::LambdaMart.
|
protectedvirtual |
Fits a regression tree on the gradient given by the pseudo residuals.
| training_dataset | The dataset used for training |
Reimplemented in quickrank::learning::forests::LambdaMart, quickrank::learning::forests::ObliviousLambdaMart, and quickrank::learning::forests::ObliviousMart.
|
inlinevirtual |
Return the weights for the ensemble models (only).
Default implementation will do nothing (default for non ensemble models).
Reimplemented from quickrank::learning::LTR_Algorithm.
|
protectedvirtual |
Return the xml model representing the current object.
Implements quickrank::learning::LTR_Algorithm.
Reimplemented in quickrank::learning::forests::ObliviousMart, and quickrank::learning::forests::ObliviousLambdaMart.
|
protectedvirtual |
Prepares private data structures before training takes place.
Reimplemented in quickrank::learning::forests::LambdaMart.
|
virtual |
Start the learning process.
Implements quickrank::learning::LTR_Algorithm.
|
inlinevirtual |
Returns the name of the ranker.
Implements quickrank::learning::LTR_Algorithm.
Reimplemented in quickrank::learning::forests::LambdaMart, quickrank::learning::forests::ObliviousLambdaMart, and quickrank::learning::forests::ObliviousMart.
|
inlinevirtual |
Returns the partial scores of a given document, tree.
| d | is a pointer to the document to be evaluated |
| next_fx_offset | The offset to the next feature in the data representation. |
Reimplemented from quickrank::learning::LTR_Algorithm.
|
virtual |
Print additional statistics.
At the moment this include only number of comparisons for tree-based algorithms.
Reimplemented from quickrank::learning::LTR_Algorithm.
|
privatevirtual |
Prints the description of Algorithm, including its parameters.
Implements quickrank::learning::LTR_Algorithm.
Reimplemented in quickrank::learning::forests::ObliviousLambdaMart, and quickrank::learning::forests::ObliviousMart.
|
inlinevirtual |
Returns the score by the current ranker.
| d | Document to be scored. |
Implements quickrank::learning::LTR_Algorithm.
|
protectedvirtual |
Updates scores with the last learnt regression tree.
| dataset | Dataset to be scored. |
| scores | Scores vector to be updated. |
| tree | Last regression tree leartn. |
|
protectedvirtual |
|
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.
|
friend |
The output stream operator.
|
protected |
|
protected |
|
protected |
|
static |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
1.8.11