This class contains methods which are used to calculate the cost of BiasSVD's objective function, to calculate gradient of parameters with respect to the objective function, etc. More...
Public Member Functions | |
BiasSVDFunction (const MatType &data, const size_t rank, const double lambda) | |
Constructor for BiasSVDFunction 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... | |
This class contains methods which are used to calculate the cost of BiasSVD's objective function, to calculate gradient of parameters with respect to the objective function, etc.
MatType | The matrix type of the dataset. |
Definition at line 31 of file bias_svd_function.hpp.
BiasSVDFunction | ( | const MatType & | data, |
const size_t | rank, | ||
const double | lambda | ||
) |
Constructor for BiasSVDFunction 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 107 of file bias_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/bias) 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/bias) 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 104 of file bias_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/bias) 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/bias) 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 119 of file bias_svd_function.hpp.
|
inline |
Return the number of training examples. Useful for SGD optimizer.
Definition at line 110 of file bias_svd_function.hpp.
|
inline |
Return the number of items in the data.
Definition at line 116 of file bias_svd_function.hpp.
|
inline |
Return the number of users in the data.
Definition at line 113 of file bias_svd_function.hpp.
|
inline |
Return the rank used for the factorization.
Definition at line 122 of file bias_svd_function.hpp.
void Shuffle | ( | ) |
Shuffle the points in the dataset.
This may be used by optimizers.