MLPACK  1.0.10
regularized_svd_function.hpp
Go to the documentation of this file.
1 
23 #ifndef __MLPACK_METHODS_REGULARIZED_SVD_REGULARIZED_FUNCTION_SVD_HPP
24 #define __MLPACK_METHODS_REGULARIZED_SVD_REGULARIZED_FUNCTION_SVD_HPP
25 
26 #include <mlpack/core.hpp>
28 
29 namespace mlpack {
30 namespace svd {
31 
33 {
34  public:
35 
45  RegularizedSVDFunction(const arma::mat& data,
46  const size_t rank,
47  const double lambda);
48 
54  double Evaluate(const arma::mat& parameters) const;
55 
63  double Evaluate(const arma::mat& parameters,
64  const size_t i) const;
65 
73  void Gradient(const arma::mat& parameters,
74  arma::mat& gradient) const;
75 
77  const arma::mat& GetInitialPoint() const { return initialPoint; }
78 
80  const arma::mat& Dataset() const { return data; }
81 
83  size_t NumFunctions() const { return data.n_cols; }
84 
86  size_t NumUsers() const { return numUsers; }
87 
89  size_t NumItems() const { return numItems; }
90 
92  double Lambda() const { return lambda; }
93 
95  size_t Rank() const { return rank; }
96 
97  private:
99  const arma::mat& data;
101  arma::mat initialPoint;
103  size_t rank;
105  double lambda;
107  size_t numUsers;
109  size_t numItems;
110 };
111 
112 }; // namespace svd
113 }; // namespace mlpack
114 
115 namespace mlpack {
116 namespace optimization {
117 
123  template<>
125  arma::mat& parameters);
126 
127 }; // namespace optimization
128 }; // namespace mlpack
129 
130 #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: load.hpp:31
size_t NumFunctions() const
Return the number of training examples. Useful for SGD optimizer.
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.
double Optimize(arma::mat &iterate)
Optimize the given function using stochastic gradient descent.
RegularizedSVDFunction(const arma::mat &data, const size_t rank, const double lambda)
Constructor for RegularizedSVDFunction class.