[mlpack-git] master: Allow serialization of linear regression. (d90f8ff)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Fri Jul 10 18:59:43 EDT 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/4a97187bbba7ce8a6191b714949dd818ef0f37d2...e5905e62c15d1bcff21e6359b11efcd7ab6d7ca0
>---------------------------------------------------------------
commit d90f8fff660f26a6d7bd83959a6448ca192cbc1a
Author: ryan <ryan at ratml.org>
Date: Mon Apr 20 13:16:07 2015 -0400
Allow serialization of linear regression.
>---------------------------------------------------------------
d90f8fff660f26a6d7bd83959a6448ca192cbc1a
.../linear_regression/linear_regression.hpp | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/mlpack/methods/linear_regression/linear_regression.hpp b/src/mlpack/methods/linear_regression/linear_regression.hpp
index 3d72389..511915e 100644
--- a/src/mlpack/methods/linear_regression/linear_regression.hpp
+++ b/src/mlpack/methods/linear_regression/linear_regression.hpp
@@ -34,8 +34,7 @@ class LinearRegression
const arma::vec& responses,
const double lambda = 0,
const bool intercept = true,
- const arma::vec& weights = arma::vec()
- );
+ const arma::vec& weights = arma::vec());
/**
* Initialize the model from a file.
@@ -94,6 +93,17 @@ class LinearRegression
//! Modify the Tikhonov regularization parameter for ridge regression.
double& Lambda() { return lambda; }
+ /**
+ * Serialize the model.
+ */
+ template<typename Archive>
+ void Serialize(Archive& ar, const unsigned int /* version */)
+ {
+ ar & data::CreateNVP(parameters, "parameters");
+ ar & data::CreateNVP(lambda, "lambda");
+ ar & data::CreateNVP(intercept, "intercept");
+ }
+
// Returns a string representation of this object.
std::string ToString() const;
@@ -103,16 +113,18 @@ class LinearRegression
* Initialized and filled by constructor to hold the least squares solution.
*/
arma::vec parameters;
+
/**
* The Tikhonov regularization parameter for ridge regression (0 for linear
* regression).
*/
double lambda;
+
//! Indicates whether first parameter is intercept.
bool intercept;
};
-}; // namespace linear_regression
-}; // namespace mlpack
+} // namespace linear_regression
+} // namespace mlpack
-#endif // __MLPACK_METHODS_LINEAR_REGRESSCLIN_HPP
+#endif // __MLPACK_METHODS_LINEAR_REGRESSION_HPP
More information about the mlpack-git
mailing list