RegularizedSVDFunction< MatType > Class Template Reference

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 &parameters) const
 Evaluates the cost function over all examples in the data. More...

 
double Evaluate (const arma::mat &parameters, 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 &parameters, 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 &parameters, 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...

 

Detailed Description


template
<
typename
MatType
=
arma::mat
>

class mlpack::svd::RegularizedSVDFunction< MatType >

The data is stored in a matrix of type MatType, so that this class can be used with both dense and sparse matrix types.

Template Parameters
MatTypeThe matrix type of the dataset.

Definition at line 29 of file regularized_svd_function.hpp.

Constructor & Destructor Documentation

◆ RegularizedSVDFunction()

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.

Parameters
dataDataset for which SVD is calculated.
rankRank used for matrix factorization.
lambdaRegularization parameter used for optimization.

Member Function Documentation

◆ Dataset()

const arma::mat& Dataset ( ) const
inline

Return the dataset passed into the constructor.

Definition at line 101 of file regularized_svd_function.hpp.

◆ Evaluate() [1/2]

double Evaluate ( const arma::mat &  parameters) const

Evaluates the cost function over all examples in the data.

Parameters
parametersParameters(user/item matrices) of the decomposition.

◆ Evaluate() [2/2]

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
parametersParameters(user/item matrices) of the decomposition.
startFirst index of the training examples to be used.
batchSizeSize of batch to evaluate.

◆ GetInitialPoint()

const arma::mat& GetInitialPoint ( ) const
inline

Return the initial point for the optimization.

Definition at line 98 of file regularized_svd_function.hpp.

◆ Gradient() [1/2]

void Gradient ( const arma::mat &  parameters,
arma::mat &  gradient 
) const

Evaluates the full gradient of the cost function over all the training examples.

Parameters
parametersParameters(user/item matrices) of the decomposition.
gradientCalculated gradient for the parameters.

◆ Gradient() [2/2]

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.

Template Parameters
GradTypeThe type of the gradient out-param.
Parameters
parametersParameters(user/item matrices) of the decomposition.
startThe first index of the training examples to use.
gradientCalculated gradient for the parameters.
batchSizeSize of batch to calculate gradient for.

◆ Lambda()

double Lambda ( ) const
inline

Return the regularization parameters.

Definition at line 113 of file regularized_svd_function.hpp.

◆ NumFunctions()

size_t NumFunctions ( ) const
inline

Return the number of training examples. Useful for SGD optimizer.

Definition at line 104 of file regularized_svd_function.hpp.

◆ NumItems()

size_t NumItems ( ) const
inline

Return the number of items in the data.

Definition at line 110 of file regularized_svd_function.hpp.

◆ NumUsers()

size_t NumUsers ( ) const
inline

Return the number of users in the data.

Definition at line 107 of file regularized_svd_function.hpp.

◆ Rank()

size_t Rank ( ) const
inline

Return the rank used for the factorization.

Definition at line 116 of file regularized_svd_function.hpp.

◆ Shuffle()

void Shuffle ( )

Shuffle the points in the dataset.

This may be used by optimizers.


The documentation for this class was generated from the following file: