mlpack  1.0.12
regularized_svd_function.hpp
Go to the documentation of this file.
1 
15 #ifndef __MLPACK_METHODS_REGULARIZED_SVD_REGULARIZED_FUNCTION_SVD_HPP
16 #define __MLPACK_METHODS_REGULARIZED_SVD_REGULARIZED_FUNCTION_SVD_HPP
17 
18 #include <mlpack/core.hpp>
20 
21 namespace mlpack {
22 namespace svd {
23 
25 {
26  public:
27 
37  RegularizedSVDFunction(const arma::mat& data,
38  const size_t rank,
39  const double lambda);
40 
46  double Evaluate(const arma::mat& parameters) const;
47 
55  double Evaluate(const arma::mat& parameters,
56  const size_t i) const;
57 
65  void Gradient(const arma::mat& parameters,
66  arma::mat& gradient) const;
67 
69  const arma::mat& GetInitialPoint() const { return initialPoint; }
70 
72  const arma::mat& Dataset() const { return data; }
73 
75  size_t NumFunctions() const { return data.n_cols; }
76 
78  size_t NumUsers() const { return numUsers; }
79 
81  size_t NumItems() const { return numItems; }
82 
84  double Lambda() const { return lambda; }
85 
87  size_t Rank() const { return rank; }
88 
89  private:
91  const arma::mat& data;
93  arma::mat initialPoint;
95  size_t rank;
97  double lambda;
99  size_t numUsers;
101  size_t numItems;
102 };
103 
104 }; // namespace svd
105 }; // namespace mlpack
106 
107 namespace mlpack {
108 namespace optimization {
109 
115  template<>
117  arma::mat& parameters);
118 
119 }; // namespace optimization
120 }; // namespace mlpack
121 
122 #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:23
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.