[mlpack-svn] r10760 - mlpack/trunk/src/mlpack/core/tree
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Dec 14 03:04:08 EST 2011
Author: rcurtin
Date: 2011-12-14 03:04:08 -0500 (Wed, 14 Dec 2011)
New Revision: 10760
Modified:
mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp
mlpack/trunk/src/mlpack/core/tree/statistic.hpp
Log:
Make statistics useful again.
Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp 2011-12-14 06:43:10 UTC (rev 10759)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp 2011-12-14 08:04:08 UTC (rev 10760)
@@ -99,6 +99,12 @@
{
// Perform the actual splitting.
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>
@@ -122,6 +128,12 @@
// Perform 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>
@@ -151,6 +163,12 @@
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());
}
template<typename BoundType, typename StatisticType, typename MatType>
Modified: mlpack/trunk/src/mlpack/core/tree/statistic.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/statistic.hpp 2011-12-14 06:43:10 UTC (rev 10759)
+++ mlpack/trunk/src/mlpack/core/tree/statistic.hpp 2011-12-14 08:04:08 UTC (rev 10760)
@@ -15,8 +15,6 @@
/**
* Empty statistic if you are not interested in storing statistics in your
* tree. Use this as a template for your own.
- *
- * @experimental
*/
class EmptyStatistic
{
@@ -25,17 +23,35 @@
~EmptyStatistic() {}
/**
- * Initializes by taking statistics on raw data.
+ * This constructor is called when a leaf is created.
+ *
+ * @param dataset Matrix that the tree is being built on.
+ * @param begin Starting index corresponding to this leaf.
+ * @param count Number of points held in this leaf.
*/
- void Init(const arma::mat& dataset, size_t start, size_t count) { }
+ template<typename MatType>
+ EmptyStatistic(const MatType& dataset,
+ const size_t begin,
+ const size_t count)
+ { }
/**
- * Initializes by combining statistics of two partitions.
+ * This constructor is called when a non-leaf node is created.
+ * This lets you build fast bottom-up statistics when building trees.
*
- * This lets you build fast bottom-up statistics when building trees.
+ * @param dataset Matrix that the tree is being built on.
+ * @param begin Starting index corresponding to this leaf.
+ * @param count Number of points held in this leaf.
+ * @param leftStat EmptyStatistic object of the left child node.
+ * @param rightStat EmptyStatistic object of the right child node.
*/
- void Init(const arma::mat& dataset, size_t start, size_t count,
- const EmptyStatistic& left_stat, const EmptyStatistic& right_stat) { }
+ template<typename MatType>
+ EmptyStatistic(const MatType& dataset,
+ const size_t start,
+ const size_t count,
+ const EmptyStatistic& leftStat,
+ const EmptyStatistic& rightStat)
+ { }
};
}; // namespace tree
More information about the mlpack-svn
mailing list