QuickRank  v2.0
QuickRank: A C++ suite of Learning to Rank algorithms
rt.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 <cfloat>
25 #include <cmath>
26 #include <cstring>
27 
28 #include "utils/maxheap.h"
29 #include "data/vertical_dataset.h"
30 #include "learning/tree/rtnode.h"
32 
34 
35 class DevianceMaxHeap: public rt_maxheap {
36  public:
37  DevianceMaxHeap(unsigned int initsize)
38  : rt_maxheap(initsize) {
39  }
40  void push_chidrenof(RTNode *parent);
41  void pop();
42 };
43 
45  protected:
46  const size_t
47  nrequiredleaves; //0 for unlimited number of nodes (the size of the tree will then be controlled only by minls)
48  const size_t minls; //minls>0
49  quickrank::data::VerticalDataset *training_dataset = NULL;
50  double *training_labels = NULL;
51  RTNode **leaves = NULL;
52  size_t nleaves = 0;
53  RTNode *root = NULL;
54  public:
55  RegressionTree(size_t nrequiredleaves, quickrank::data::VerticalDataset *dps,
56  double *labels, size_t minls)
57  : nrequiredleaves(nrequiredleaves),
58  minls(minls),
59  training_dataset(dps),
60  training_labels(labels) {
61  }
62  ~RegressionTree();
63 
64  void fit(RTNodeHistogram *hist);
65 
66  double update_output(double const *pseudoresponses);
67 
68  double update_output(double const *pseudoresponses,
69  double const *cachedweights);
70 
71  RTNode *get_proot() const {
72  return root;
73  }
74 
75  private:
76  //if require_devianceltparent is true the node is split if minvar is lt the current node deviance (require_devianceltparent=false in RankLib)
77  bool split(RTNode *node, const float featuresamplingrate,
78  const bool require_devianceltparent);
79 
80 };
81 
DevianceMaxHeap(unsigned int initsize)
Definition: rt.h:37
void pop()
Definition: rt.cc:34
Definition: maxheap.h:31
void push_chidrenof(RTNode *parent)
Definition: rt.cc:30
Definition: rt.h:35
This class implements a Dataset to be used for a L-t-R task.
Definition: vertical_dataset.h:46
const size_t minls
Definition: rt.h:48
MaxHeap< RTNode * > rt_maxheap
Definition: rt.h:33
Definition: rt.h:44
RTNode * get_proot() const
Definition: rt.h:71
Definition: rtnode_histogram.h:26
Definition: rtnode.h:36
const size_t nrequiredleaves
Definition: rt.h:47
RegressionTree(size_t nrequiredleaves, quickrank::data::VerticalDataset *dps, double *labels, size_t minls)
Definition: rt.h:55