[mlpack-git] master: Don't save observations we haven't seen yet. (736df58)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Wed Dec 23 11:44:29 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/de9cc4b05069e1fa4793d9355f2f595af5ff45d2...6070527af14296cd99739de6c62666cc5d2a2125

>---------------------------------------------------------------

commit 736df582dab50845715ca8f53e3299dfb3c06b29
Author: Ryan Curtin <ryan at ratml.org>
Date:   Sat Oct 17 11:12:43 2015 -0400

    Don't save observations we haven't seen yet.
    
    This significantly reduces the size of saved models.


>---------------------------------------------------------------

736df582dab50845715ca8f53e3299dfb3c06b29
 .../hoeffding_trees/hoeffding_numeric_split_impl.hpp   | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/mlpack/methods/hoeffding_trees/hoeffding_numeric_split_impl.hpp b/src/mlpack/methods/hoeffding_trees/hoeffding_numeric_split_impl.hpp
index e5ff5fb..cfe71b5 100644
--- a/src/mlpack/methods/hoeffding_trees/hoeffding_numeric_split_impl.hpp
+++ b/src/mlpack/methods/hoeffding_trees/hoeffding_numeric_split_impl.hpp
@@ -194,8 +194,22 @@ void HoeffdingNumericSplit<FitnessFunction, ObservationType>::Serialize(
   {
     // The binning has not happened yet, so we only need to save the information
     // required before binning.
-    ar & CreateNVP(observations, "observations");
-    ar & CreateNVP(labels, "labels");
+    if (Archive::is_loading::value)
+    {
+      observations.zeros(observationsBeforeBinning);
+      labels.zeros(observationsBeforeBinning);
+    }
+
+    for (size_t i = 0; i < samplesSeen; ++i)
+    {
+      std::ostringstream oss;
+      oss << "observation" << i;
+      ar & CreateNVP(observations[i], oss.str());
+
+      oss.clear();
+      oss << "label" << i;
+      ar & CreateNVP(labels[i], oss.str());
+    }
 
     if (Archive::is_loading::value)
     {



More information about the mlpack-git mailing list