mlpack  master
binary_numeric_split_info.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_HOEFFDING_TREES_BINARY_NUMERIC_SPLIT_INFO_HPP
14 #define MLPACK_METHODS_HOEFFDING_TREES_BINARY_NUMERIC_SPLIT_INFO_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace tree {
20 
21 template<typename ObservationType = double>
23 {
24  public:
25  BinaryNumericSplitInfo() { /* Nothing to do. */ }
26  BinaryNumericSplitInfo(const ObservationType& splitPoint) :
27  splitPoint(splitPoint) { /* Nothing to do. */ }
28 
29  template<typename eT>
30  size_t CalculateDirection(const eT& value) const
31  {
32  return (value < splitPoint) ? 0 : 1;
33  }
34 
36  template<typename Archive>
37  void Serialize(Archive& ar, const unsigned int /* version */)
38  {
39  ar & data::CreateNVP(splitPoint, "splitPoint");
40  }
41 
42  private:
43  ObservationType splitPoint;
44 };
45 
46 } // namespace tree
47 } // namespace mlpack
48 
49 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
The core includes that mlpack expects; standard C++ includes and Armadillo.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename std::enable_if_t< HasSerialize< T >::value > *=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.
BinaryNumericSplitInfo(const ObservationType &splitPoint)
size_t CalculateDirection(const eT &value) const
void Serialize(Archive &ar, const unsigned int)
Serialize the split (save/load the split points).