mlpack  master
regularized_svd_function.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_REGULARIZED_SVD_REGULARIZED_FUNCTION_SVD_HPP
14 #define MLPACK_METHODS_REGULARIZED_SVD_REGULARIZED_FUNCTION_SVD_HPP
15 
16 #include <mlpack/prereqs.hpp>
18 
19 namespace mlpack {
20 namespace svd {
21 
23 {
24  public:
25 
35  RegularizedSVDFunction(const arma::mat& data,
36  const size_t rank,
37  const double lambda);
38 
44  double Evaluate(const arma::mat& parameters) const;
45 
53  double Evaluate(const arma::mat& parameters,
54  const size_t i) const;
55 
63  void Gradient(const arma::mat& parameters,
64  arma::mat& gradient) const;
65 
67  const arma::mat& GetInitialPoint() const { return initialPoint; }
68 
70  const arma::mat& Dataset() const { return data; }
71 
73  size_t NumFunctions() const { return data.n_cols; }
74 
76  size_t NumUsers() const { return numUsers; }
77 
79  size_t NumItems() const { return numItems; }
80 
82  double Lambda() const { return lambda; }
83 
85  size_t Rank() const { return rank; }
86 
87  private:
89  const arma::mat& data;
91  arma::mat initialPoint;
93  size_t rank;
95  double lambda;
97  size_t numUsers;
99  size_t numItems;
100 };
101 
102 } // namespace svd
103 } // namespace mlpack
104 
105 namespace mlpack {
106 namespace optimization {
107 
113  template<>
114  double SGD<mlpack::svd::RegularizedSVDFunction>::Optimize(
115  arma::mat& parameters);
116 
117 } // namespace optimization
118 } // namespace mlpack
119 
120 #endif
arma::mat initialPoint
Initial parameter point.
size_t Rank() const
Return the rank used for the factorization.
const arma::mat & Dataset() const
Return the dataset passed into the constructor.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
size_t NumFunctions() const
Return the number of training examples. Useful for SGD optimizer.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double lambda
Regularization parameter for the optimization.
void Gradient(const arma::mat &parameters, arma::mat &gradient) const
Evaluates the full gradient of the cost function over all the training examples.
size_t NumUsers() const
Return the number of users in the data.
double Evaluate(const arma::mat &parameters) const
Evaluates the cost function over all examples in the data.
size_t NumItems() const
Return the number of items in the data.
size_t numItems
Number of items in the given dataset.
size_t numUsers
Number of users in the given dataset.
const arma::mat & GetInitialPoint() const
Return the initial point for the optimization.
double Lambda() const
Return the regularization parameters.
size_t rank
Rank used for matrix factorization.
RegularizedSVDFunction(const arma::mat &data, const size_t rank, const double lambda)
Constructor for RegularizedSVDFunction class.