Point Cloud Library (PCL)  1.8.0
decision_tree_evaluator.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef PCL_ML_DT_DECISION_TREE_EVALUATOR_H_
39 #define PCL_ML_DT_DECISION_TREE_EVALUATOR_H_
40 
41 #include <pcl/common/common.h>
42 
43 #include <pcl/ml/dt/decision_tree.h>
44 #include <pcl/ml/feature_handler.h>
45 #include <pcl/ml/stats_estimator.h>
46 
47 #include <vector>
48 
49 namespace pcl
50 {
51 
52  /** \brief Utility class for evaluating a decision tree. */
53  template <
54  class FeatureType,
55  class DataSet,
56  class LabelType,
57  class ExampleIndex,
58  class NodeType >
60  {
61 
62  public:
63 
64  /** \brief Constructor. */
66  /** \brief Destructor. */
67  virtual
69 
70  /** \brief Evaluates the specified examples using the supplied tree.
71  * \param[in] tree The decision tree.
72  * \param[in] feature_handler The feature handler used to train the tree.
73  * \param[in] stats_estimator The statistics estimation instance used while training the tree.
74  * \param[in] data_set The data set used for evaluation.
75  * \param[in] examples The examples that have to be evaluated.
76  * \param[out] label_data The destination for the resulting label data.
77  */
78  void
82  DataSet & data_set,
83  std::vector<ExampleIndex> & examples,
84  std::vector<LabelType> & label_data);
85 
86  /** \brief Evaluates the specified examples using the supplied tree and adds the results to the supplied results array.
87  * \param[in] tree The decision tree.
88  * \param[in] feature_handler The feature handler used to train the tree.
89  * \param[in] stats_estimator The statistics estimation instance used while training the tree.
90  * \param[in] data_set The data set used for evaluation.
91  * \param[in] examples The examples that have to be evaluated.
92  * \param[out] label_data The destination where the resulting label data is added to.
93  */
94  void
98  DataSet & data_set,
99  std::vector<ExampleIndex> & examples,
100  std::vector<LabelType> & label_data);
101 
102  /** \brief Evaluates the specified examples using the supplied tree.
103  * \param[in] tree The decision tree.
104  * \param[in] feature_handler The feature handler used to train the tree.
105  * \param[in] stats_estimator The statistics estimation instance used while training the tree.
106  * \param[in] data_set The data set used for evaluation.
107  * \param[in] example The example that has to be evaluated.
108  * \param[out] leave The leave reached by the examples.
109  */
110  void
114  DataSet & data_set,
115  ExampleIndex example,
116  NodeType & leave);
117 
118  /** \brief Evaluates the specified examples using the supplied tree.
119  * \param[in] tree The decision tree.
120  * \param[in] feature_handler The feature handler used to train the tree.
121  * \param[in] stats_estimator The statistics estimation instance used while training the tree.
122  * \param[in] data_set The data set used for evaluation.
123  * \param[in] examples The examples that have to be evaluated.
124  * \param[out] nodes The leaf-nodes reached while evaluation.
125  */
126  void
130  DataSet & data_set,
131  std::vector<ExampleIndex> & examples,
132  std::vector<NodeType*> & nodes);
133 
134  };
135 
136 }
137 
138 #include <pcl/ml/impl/dt/decision_tree_evaluator.hpp>
139 
140 #endif
Utility class for evaluating a decision tree.
Class representing a decision tree.
Definition: decision_tree.h:51
void evaluateAndAdd(pcl::DecisionTree< NodeType > &tree, pcl::FeatureHandler< FeatureType, DataSet, ExampleIndex > &feature_handler, pcl::StatsEstimator< LabelType, NodeType, DataSet, ExampleIndex > &stats_estimator, DataSet &data_set, std::vector< ExampleIndex > &examples, std::vector< LabelType > &label_data)
Evaluates the specified examples using the supplied tree and adds the results to the supplied results...
virtual ~DecisionTreeEvaluator()
Destructor.
void getNodes(pcl::DecisionTree< NodeType > &tree, pcl::FeatureHandler< FeatureType, DataSet, ExampleIndex > &feature_handler, pcl::StatsEstimator< LabelType, NodeType, DataSet, ExampleIndex > &stats_estimator, DataSet &data_set, std::vector< ExampleIndex > &examples, std::vector< NodeType * > &nodes)
Evaluates the specified examples using the supplied tree.
void evaluate(pcl::DecisionTree< NodeType > &tree, pcl::FeatureHandler< FeatureType, DataSet, ExampleIndex > &feature_handler, pcl::StatsEstimator< LabelType, NodeType, DataSet, ExampleIndex > &stats_estimator, DataSet &data_set, std::vector< ExampleIndex > &examples, std::vector< LabelType > &label_data)
Evaluates the specified examples using the supplied tree.
Utility class interface which is used for creating and evaluating features.