[mlpack-git] master: Add separate split info for binary splits. (cb3522e)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Wed Dec 23 11:45:57 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/de9cc4b05069e1fa4793d9355f2f595af5ff45d2...6070527af14296cd99739de6c62666cc5d2a2125
>---------------------------------------------------------------
commit cb3522e300fae8db08cccf6cddafd58dfffdc700
Author: Ryan Curtin <ryan at ratml.org>
Date: Thu Nov 5 14:33:35 2015 -0800
Add separate split info for binary splits.
>---------------------------------------------------------------
cb3522e300fae8db08cccf6cddafd58dfffdc700
src/mlpack/methods/hoeffding_trees/CMakeLists.txt | 1 +
.../hoeffding_trees/binary_numeric_split_info.hpp | 44 ++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/src/mlpack/methods/hoeffding_trees/CMakeLists.txt b/src/mlpack/methods/hoeffding_trees/CMakeLists.txt
index 4de724a..f457856 100644
--- a/src/mlpack/methods/hoeffding_trees/CMakeLists.txt
+++ b/src/mlpack/methods/hoeffding_trees/CMakeLists.txt
@@ -3,6 +3,7 @@
set(SOURCES
binary_numeric_split.hpp
binary_numeric_split_impl.hpp
+ binary_numeric_split_info.hpp
categorical_split_info.hpp
gini_impurity.hpp
hoeffding_categorical_split.hpp
diff --git a/src/mlpack/methods/hoeffding_trees/binary_numeric_split_info.hpp b/src/mlpack/methods/hoeffding_trees/binary_numeric_split_info.hpp
new file mode 100644
index 0000000..52bbb06
--- /dev/null
+++ b/src/mlpack/methods/hoeffding_trees/binary_numeric_split_info.hpp
@@ -0,0 +1,44 @@
+/**
+ * @file binary_numeric_split_info.hpp
+ * @author Ryan Curtin
+ *
+ * After a binary numeric split has been made, this holds information on the
+ * split (just the split point).
+ */
+#ifndef __MLPACK_METHODS_HOEFFDING_TREES_BINARY_NUMERIC_SPLIT_INFO_HPP
+#define __MLPACK_METHODS_HOEFFDING_TREES_BINARY_NUMERIC_SPLIT_INFO_HPP
+
+#include <mlpack/core.hpp>
+
+namespace mlpack {
+namespace tree {
+
+template<typename ObservationType = double>
+class BinaryNumericSplitInfo
+{
+ public:
+ BinaryNumericSplitInfo() { /* Nothing to do. */ }
+ BinaryNumericSplitInfo(const ObservationType& splitPoint) :
+ splitPoint(splitPoint) { /* Nothing to do. */ }
+
+ template<typename eT>
+ size_t CalculateDirection(const eT& value) const
+ {
+ return (value < splitPoint) ? 0 : 1;
+ }
+
+ //! Serialize the split (save/load the split points).
+ template<typename Archive>
+ void Serialize(Archive& ar, const unsigned int /* version */)
+ {
+ ar & data::CreateNVP(splitPoint, "splitPoint");
+ }
+
+ private:
+ ObservationType splitPoint;
+};
+
+} // namespace tree
+} // namespace mlpack
+
+#endif
More information about the mlpack-git
mailing list