[mlpack-svn] r11566 - mlpack/trunk/src/mlpack/core/tree
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Feb 20 21:39:14 EST 2012
Author: rcurtin
Date: 2012-02-20 21:39:14 -0500 (Mon, 20 Feb 2012)
New Revision: 11566
Modified:
mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp
mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp
Log:
Initialize StatisticType objects in the root node too.
Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp 2012-02-21 02:22:46 UTC (rev 11565)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp 2012-02-21 02:39:14 UTC (rev 11566)
@@ -46,9 +46,9 @@
{
private:
//! The left child node.
- BinarySpaceTree *left;
+ BinarySpaceTree* left;
//! The right child node.
- BinarySpaceTree *right;
+ BinarySpaceTree* right;
//! The index of the first point in the dataset contained in this node (and
//! its children).
size_t begin;
Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp 2012-02-21 02:22:46 UTC (rev 11565)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp 2012-02-21 02:39:14 UTC (rev 11566)
@@ -31,6 +31,12 @@
{
// Do the actual splitting of this node.
SplitNode(data);
+
+ // Create the statistic depending on if we are a leaf or not.
+ if (IsLeaf())
+ stat = StatisticType(data, begin, count);
+ else
+ stat = StatisticType(data, begin, count, left->Stat(), right->Stat());
}
template<typename BoundType, typename StatisticType, typename MatType>
@@ -53,6 +59,12 @@
// Now do the actual splitting.
SplitNode(data, oldFromNew);
+
+ // Create the statistic depending on if we are a leaf or not.
+ if (IsLeaf())
+ stat = StatisticType(data, begin, count);
+ else
+ stat = StatisticType(data, begin, count, left->Stat(), right->Stat());
}
template<typename BoundType, typename StatisticType, typename MatType>
@@ -77,6 +89,12 @@
// Now do the actual splitting.
SplitNode(data, oldFromNew);
+ // Create the statistic depending on if we are a leaf or not.
+ if (IsLeaf())
+ stat = StatisticType(data, begin, count);
+ else
+ stat = StatisticType(data, begin, count, left->Stat(), right->Stat());
+
// Map the newFromOld indices correctly.
newFromOld.resize(data.n_cols);
for (size_t i = 0; i < data.n_cols; i++)
@@ -159,16 +177,16 @@
// Perform the actual splitting.
SplitNode(data, oldFromNew);
- // Map the newFromOld indices correctly.
- newFromOld.resize(data.n_cols);
- for (size_t i = 0; i < data.n_cols; i++)
- newFromOld[oldFromNew[i]] = i;
-
// Create the statistic depending on if we are a leaf or not.
if (IsLeaf())
stat = StatisticType(data, begin, count);
else
stat = StatisticType(data, begin, count, left->Stat(), right->Stat());
+
+ // Map the newFromOld indices correctly.
+ newFromOld.resize(data.n_cols);
+ for (size_t i = 0; i < data.n_cols; i++)
+ newFromOld[oldFromNew[i]] = i;
}
template<typename BoundType, typename StatisticType, typename MatType>
@@ -309,7 +327,7 @@
}
template<typename BoundType, typename StatisticType, typename MatType>
-inline const
+inline const
BoundType& BinarySpaceTree<BoundType, StatisticType, MatType>::Bound() const
{
return bound;
@@ -322,7 +340,7 @@
}
template<typename BoundType, typename StatisticType, typename MatType>
-inline const StatisticType&
+inline const StatisticType&
BinarySpaceTree<BoundType, StatisticType, MatType>::Stat() const
{
return stat;
@@ -388,7 +406,7 @@
}
template<typename BoundType, typename StatisticType, typename MatType>
-void
+void
BinarySpaceTree<BoundType, StatisticType, MatType>::SplitNode(MatType& data)
{
// We need to expand the bounds of this node properly.
More information about the mlpack-svn
mailing list