mlpack: src/mlpack/methods/hoeffding_trees/binary_numeric_split_info.hpp Source File
binary_numeric_split_info.hpp
Go to the documentation of this file.
1 
15 #ifndef mlpack_METHODS_HOEFFDING_TREES_BINARY_NUMERIC_SPLIT_INFO_HPP
16 #define mlpack_METHODS_HOEFFDING_TREES_BINARY_NUMERIC_SPLIT_INFO_HPP
17 
18 #include <mlpack/core.hpp>
19 
20 namespace mlpack {
21 namespace tree {
22 
23 template<typename ObservationType = double>
25 {
26  public:
27  BinaryNumericSplitInfo() { /* Nothing to do. */ }
28  BinaryNumericSplitInfo(const ObservationType& splitPoint) :
29  splitPoint(splitPoint) { /* Nothing to do. */ }
30 
31  template<typename eT>
32  size_t CalculateDirection(const eT& value) const
33  {
34  return (value < splitPoint) ? 0 : 1;
35  }
36 
38  template<typename Archive>
39  void Serialize(Archive& ar, const unsigned int /* version */)
40  {
41  ar & data::CreateNVP(splitPoint, "splitPoint");
42  }
43 
44  private:
45  ObservationType splitPoint;
46 };
47 
48 } // namespace tree
49 } // namespace mlpack
50 
51 #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.
BinaryNumericSplitInfo(const ObservationType &splitPoint)
size_t CalculateDirection(const eT &value) const
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
void Serialize(Archive &ar, const unsigned int)
Serialize the split (save/load the split points).