The data is stored in a matrix of type MatType, so that this class can be used with both dense and sparse matrix types. More...
Public Member Functions | |
RegularizedSVDFunction (const MatType &data, const size_t rank, const double lambda) | |
Constructor for RegularizedSVDFunction class. More... | |
const arma::mat & | Dataset () const |
Return the dataset passed into the constructor. More... | |
double | Evaluate (const arma::mat ¶meters) const |
Evaluates the cost function over all examples in the data. More... | |
double | Evaluate (const arma::mat ¶meters, const size_t start, const size_t batchSize=1) const |
Evaluates the cost function for one training example. More... | |
const arma::mat & | GetInitialPoint () const |
Return the initial point for the optimization. More... | |
void | Gradient (const arma::mat ¶meters, arma::mat &gradient) const |
Evaluates the full gradient of the cost function over all the training examples. More... | |
template < typename GradType > | |
void | Gradient (const arma::mat ¶meters, const size_t start, GradType &gradient, const size_t batchSize=1) const |
Evaluates the gradient of the cost function over one training example. More... | |
double | Lambda () const |
Return the regularization parameters. More... | |
size_t | NumFunctions () const |
Return the number of training examples. Useful for SGD optimizer. More... | |
size_t | NumItems () const |
Return the number of items in the data. More... | |
size_t | NumUsers () const |
Return the number of users in the data. More... | |
size_t | Rank () const |
Return the rank used for the factorization. More... | |
void | Shuffle () |
Shuffle the points in the dataset. More... | |
The data is stored in a matrix of type MatType, so that this class can be used with both dense and sparse matrix types.
MatType | The matrix type of the dataset. |
Definition at line 29 of file regularized_svd_function.hpp.
RegularizedSVDFunction | ( | const MatType & | data, |
const size_t | rank, | ||
const double | lambda | ||
) |
Constructor for RegularizedSVDFunction class.
The constructor calculates the number of users and items in the passed data. It also randomly initializes the parameter values.
data | Dataset for which SVD is calculated. |
rank | Rank used for matrix factorization. |
lambda | Regularization parameter used for optimization. |
|
inline |
Return the dataset passed into the constructor.
Definition at line 101 of file regularized_svd_function.hpp.
double Evaluate | ( | const arma::mat & | parameters | ) | const |
Evaluates the cost function over all examples in the data.
parameters | Parameters(user/item matrices) of the decomposition. |
double Evaluate | ( | const arma::mat & | parameters, |
const size_t | start, | ||
const size_t | batchSize = 1 |
||
) | const |
Evaluates the cost function for one training example.
Useful for the SGD optimizer abstraction which uses one training example at a time.
parameters | Parameters(user/item matrices) of the decomposition. |
start | First index of the training examples to be used. |
batchSize | Size of batch to evaluate. |
|
inline |
Return the initial point for the optimization.
Definition at line 98 of file regularized_svd_function.hpp.
void Gradient | ( | const arma::mat & | parameters, |
arma::mat & | gradient | ||
) | const |
Evaluates the full gradient of the cost function over all the training examples.
parameters | Parameters(user/item matrices) of the decomposition. |
gradient | Calculated gradient for the parameters. |
void Gradient | ( | const arma::mat & | parameters, |
const size_t | start, | ||
GradType & | gradient, | ||
const size_t | batchSize = 1 |
||
) | const |
Evaluates the gradient of the cost function over one training example.
This function is useful for optimizers like SGD. The type of the gradient parameter is a template argument to allow the computation of a sparse gradient.
GradType | The type of the gradient out-param. |
parameters | Parameters(user/item matrices) of the decomposition. |
start | The first index of the training examples to use. |
gradient | Calculated gradient for the parameters. |
batchSize | Size of batch to calculate gradient for. |
|
inline |
Return the regularization parameters.
Definition at line 113 of file regularized_svd_function.hpp.
|
inline |
Return the number of training examples. Useful for SGD optimizer.
Definition at line 104 of file regularized_svd_function.hpp.
|
inline |
Return the number of items in the data.
Definition at line 110 of file regularized_svd_function.hpp.
|
inline |
Return the number of users in the data.
Definition at line 107 of file regularized_svd_function.hpp.
|
inline |
Return the rank used for the factorization.
Definition at line 116 of file regularized_svd_function.hpp.
void Shuffle | ( | ) |
Shuffle the points in the dataset.
This may be used by optimizers.