QuickRank  v2.0
QuickRank: A C++ suite of Learning to Rank algorithms
obliviousmart.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"
25 #include "learning/forests/mart.h"
26 #include "learning/tree/ot.h"
27 #include "learning/tree/ensemble.h"
28 
29 namespace quickrank {
30 namespace learning {
31 namespace forests {
32 
33 class ObliviousMart: public Mart {
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  ObliviousMart(size_t ntrees, double shrinkage, size_t nthresholds,
45  size_t treedepth, size_t minleafsupport,
46  size_t esr)
47  : Mart(ntrees, shrinkage, nthresholds, 1 << treedepth, minleafsupport,
48  esr),
49  treedepth_(treedepth) {
50  }
51 
52  ObliviousMart(const pugi::xml_document &model);
53 
54  virtual ~ObliviousMart() {
55  }
56 
57  /// Returns the name of the ranker.
58  virtual std::string name() const {
59  return NAME_;
60  }
61 
62  static const std::string NAME_;
63 
64  protected:
65  /// Fits a regression tree on the gradient given by the pseudo residuals
66  ///
67  /// \param training_dataset The dataset used for training
68  virtual std::unique_ptr<RegressionTree> fit_regressor_on_gradient(
69  std::shared_ptr<data::VerticalDataset> training_dataset);
70 
71  virtual pugi::xml_document *get_xml_model() const;
72 
73  size_t treedepth_; //>0
74 
75  private:
76  /// The output stream operator.
77  friend std::ostream &operator<<(std::ostream &os, const ObliviousMart &a) {
78  return a.put(os);
79  }
80 
81  /// Prints the description of Algorithm, including its parameters.
82  virtual std::ostream &put(std::ostream &os) const;
83 
84 };
85 
86 } // namespace forests
87 } // namespace learning
88 } // namespace quickrank
Definition: dataset.cc:28
virtual std::string name() const
Returns the name of the ranker.
Definition: obliviousmart.h:58
virtual std::ostream & put(std::ostream &os) const
Prints the description of Algorithm, including its parameters.
Definition: obliviousmart.cc:39
virtual ~ObliviousMart()
Definition: obliviousmart.h:54
virtual pugi::xml_document * get_xml_model() const
Return the xml model representing the current object.
Definition: obliviousmart.cc:66
static const std::string NAME_
Definition: obliviousmart.h:62
size_t treedepth_
Definition: obliviousmart.h:73
Definition: obliviousmart.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: obliviousmart.cc:55
ObliviousMart(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: obliviousmart.h:44
friend std::ostream & operator<<(std::ostream &os, const ObliviousMart &a)
The output stream operator.
Definition: obliviousmart.h:77