QuickRank  v2.0
QuickRank: A C++ suite of Learning to Rank algorithms
obliviouslambdamart.h
Go to the documentation of this file.
1 /*
2  * QuickRank - A C++ suite of Learning to Rank algorithms
3  * Webpage: http://quickrank.isti.cnr.it/
4  * Contact: quickrank@isti.cnr.it
5  *
6  * Unless explicitly acquired and licensed from Licensor under another
7  * license, the contents of this file are subject to the Reciprocal Public
8  * License ("RPL") Version 1.5, or subsequent versions as allowed by the RPL,
9  * and You may not copy or use this file in either source code or executable
10  * form, except in compliance with the terms and conditions of the RPL.
11  *
12  * All software distributed under the RPL is provided strictly on an "AS
13  * IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND
14  * LICENSOR HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
15  * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16  * PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the RPL for specific
17  * language governing rights and limitations under the RPL.
18  *
19  * Contributor:
20  * HPC. Laboratory - ISTI - CNR - http://hpc.isti.cnr.it/
21  */
22 #pragma once
23 
24 #include "types.h"
26 #include "learning/tree/ot.h"
27 #include "learning/tree/ensemble.h"
28 
29 namespace quickrank {
30 namespace learning {
31 namespace forests {
32 
34  public:
35  /// Initializes a new ObliviousLambdaMart instance with the given learning parameters.
36  ///
37  /// \param ntrees Maximum number of trees.
38  /// \param shrinkage Learning rate.
39  /// \param nthresholds Number of bins in discretization. 0 means no discretization.
40  /// \param treedepth Maximum depth of each tree.
41  /// \param minleafsupport Minimum number of instances in each leaf.
42  /// \param esr Early stopping if no improvement after \esr iterations
43  /// on the validation set.
44  ObliviousLambdaMart(size_t ntrees, double shrinkage,
45  size_t nthresholds, size_t treedepth,
46  size_t minleafsupport, size_t esr)
47  : LambdaMart(ntrees, shrinkage, nthresholds, 1 << treedepth,
48  minleafsupport, esr),
49  treedepth_(treedepth) {
50  }
51 
52  ObliviousLambdaMart(const pugi::xml_document &model);
53 
55  }
56 
57  /// Returns the name of the ranker.
58  virtual std::string name() const {
59  return NAME_;
60  }
61 
62  virtual pugi::xml_document *get_xml_model() const;
63 
64  static const std::string NAME_;
65 
66  protected:
67  /// Fits a regression tree on the gradient given by the pseudo residuals
68  ///
69  /// \param training_dataset The dataset used for training
70  virtual std::unique_ptr<RegressionTree> fit_regressor_on_gradient(
71  std::shared_ptr<data::VerticalDataset> training_dataset);
72 
73  size_t treedepth_; //>0
74 
75  private:
76  /// The output stream operator.
77  friend std::ostream &operator<<(std::ostream &os,
78  const ObliviousLambdaMart &a) {
79  return a.put(os);
80  }
81 
82  /// Prints the description of Algorithm, including its parameters.
83  virtual std::ostream &put(std::ostream &os) const;
84 
85 };
86 
87 } // namespace forests
88 } // namespace learning
89 } // namespace quickrank
Definition: dataset.cc:28
virtual std::ostream & put(std::ostream &os) const
Prints the description of Algorithm, including its parameters.
Definition: obliviouslambdamart.cc:39
virtual ~ObliviousLambdaMart()
Definition: obliviouslambdamart.h:54
static const std::string NAME_
Definition: obliviouslambdamart.h:64
Definition: lambdamart.h:33
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.
Definition: obliviouslambdamart.cc:55
Definition: obliviouslambdamart.h:33
friend std::ostream & operator<<(std::ostream &os, const ObliviousLambdaMart &a)
The output stream operator.
Definition: obliviouslambdamart.h:77
virtual pugi::xml_document * get_xml_model() const
Return the xml model representing the current object.
Definition: obliviouslambdamart.cc:66
virtual std::string name() const
Returns the name of the ranker.
Definition: obliviouslambdamart.h:58
size_t treedepth_
Definition: obliviouslambdamart.h:73
ObliviousLambdaMart(size_t ntrees, double shrinkage, size_t nthresholds, size_t treedepth, size_t minleafsupport, size_t esr)
Initializes a new ObliviousLambdaMart instance with the given learning parameters.
Definition: obliviouslambdamart.h:44