mlpack: a scalable c++ machine learning library
mlpack  2.0.2
numeric_split_info.hpp
Go to the documentation of this file.
1 
14 #ifndef mlpack_METHODS_HOEFFDING_TREES_NUMERIC_SPLIT_INFO_HPP
15 #define mlpack_METHODS_HOEFFDING_TREES_NUMERIC_SPLIT_INFO_HPP
16 
17 #include <mlpack/core.hpp>
18 
19 namespace mlpack {
20 namespace tree {
21 
22 template<typename ObservationType = double>
24 {
25  public:
26  NumericSplitInfo() { /* Nothing to do. */ }
27  NumericSplitInfo(const arma::Col<ObservationType>& splitPoints) :
28  splitPoints(splitPoints) { /* Nothing to do. */ }
29 
30  template<typename eT>
31  size_t CalculateDirection(const eT& value) const
32  {
33  // What bin does the point fall into?
34  size_t bin = 0;
35  while (bin < splitPoints.n_elem && value > splitPoints[bin])
36  ++bin;
37 
38  return bin;
39  }
40 
42  template<typename Archive>
43  void Serialize(Archive& ar, const unsigned int /* version */)
44  {
45  ar & data::CreateNVP(splitPoints, "splitPoints");
46  }
47 
48  private:
49  arma::Col<ObservationType> splitPoints;
50 };
51 
52 } // namespace tree
53 } // namespace mlpack
54 
55 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename boost::enable_if< HasSerialize< T >>::type *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
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).
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
NumericSplitInfo(const arma::Col< ObservationType > &splitPoints)