numeric_split_info.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_HOEFFDING_TREES_NUMERIC_SPLIT_INFO_HPP
13 #define MLPACK_METHODS_HOEFFDING_TREES_NUMERIC_SPLIT_INFO_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace tree {
19 
20 template<typename ObservationType = double>
22 {
23  public:
24  NumericSplitInfo() { /* Nothing to do. */ }
25  NumericSplitInfo(const arma::Col<ObservationType>& splitPoints) :
26  splitPoints(splitPoints) { /* Nothing to do. */ }
27 
28  template<typename eT>
29  size_t CalculateDirection(const eT& value) const
30  {
31  // What bin does the point fall into?
32  size_t bin = 0;
33  while (bin < splitPoints.n_elem && value > splitPoints[bin])
34  ++bin;
35 
36  return bin;
37  }
38 
40  template<typename Archive>
41  void serialize(Archive& ar, const unsigned int /* version */)
42  {
43  ar & BOOST_SERIALIZATION_NVP(splitPoints);
44  }
45 
46  private:
47  arma::Col<ObservationType> splitPoints;
48 };
49 
50 } // namespace tree
51 } // namespace mlpack
52 
53 #endif
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
NumericSplitInfo(const arma::Col< ObservationType > &splitPoints)
size_t CalculateDirection(const eT &value) const
void serialize(Archive &ar, const unsigned int)
Serialize the split (save/load the split points).