mlpack
mean_space_split_impl.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_CORE_TREE_SPILL_TREE_MEAN_SPACE_SPLIT_IMPL_HPP
14 #define MLPACK_CORE_TREE_SPILL_TREE_MEAN_SPACE_SPLIT_IMPL_HPP
15 
16 #include "mean_space_split.hpp"
17 #include "space_split.hpp"
18 
19 namespace mlpack {
20 namespace tree {
21 
22 template<typename MetricType, typename MatType>
23 template<typename HyperplaneType>
25  const typename HyperplaneType::BoundType& bound,
26  const MatType& data,
27  const arma::Col<size_t>& points,
28  HyperplaneType& hyp)
29 {
30  typename HyperplaneType::ProjVectorType projVector;
31  double midValue;
32 
33  if (!SpaceSplit<MetricType, MatType>::GetProjVector(bound, data, points,
34  projVector, midValue))
35  return false;
36 
37  double splitVal = 0.0;
38  for (size_t i = 0; i < points.n_elem; ++i)
39  splitVal += projVector.Project(data.col(points[i]));
40  splitVal /= points.n_elem;
41 
42  hyp = HyperplaneType(projVector, splitVal);
43 
44  return true;
45 }
46 
47 } // namespace tree
48 } // namespace mlpack
49 
50 #endif
static bool SplitSpace(const typename HyperplaneType::BoundType &bound, const MatType &data, const arma::Col< size_t > &points, HyperplaneType &hyp)
Create a splitting hyperplane considering the mean of the values in a certain projection.
Definition: mean_space_split_impl.hpp:24
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
Definition: space_split.hpp:23