SVDPlusPlusFunction< MatType > Class Template Reference

This class contains methods which are used to calculate the cost of SVD++'s objective function, to calculate gradient of parameters with respect to the objective function, etc. More...

Public Member Functions

 SVDPlusPlusFunction (const MatType &data, const arma::sp_mat &implicitData, const size_t rank, const double lambda)
 Constructor for SVDPlusPlusFunction 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...

 
const arma::sp_mat & ImplicitDataset () const
 Return the implicit data passed into the constructor. 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::SVDPlusPlusFunction< MatType >

This class contains methods which are used to calculate the cost of SVD++'s objective function, to calculate gradient of parameters with respect to the objective function, etc.

Template Parameters
MatTypeThe matrix type of the dataset.

Definition at line 31 of file svdplusplus_function.hpp.

Constructor & Destructor Documentation

◆ SVDPlusPlusFunction()

SVDPlusPlusFunction ( const MatType &  data,
const arma::sp_mat &  implicitData,
const size_t  rank,
const double  lambda 
)

Constructor for SVDPlusPlusFunction 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.
implicitDataImplicit feedback matrix where a non-zero entry means interaction between a user and an item is observed.
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 110 of file svdplusplus_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, user/item bias, item implicit matrix) 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, user/item bias, item implicit matrix) 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 107 of file svdplusplus_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, user/item bias, item implicit matrix) 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, user/item bias, item implicit matrix) of the decomposition.
startThe first index of the training examples to use.
gradientCalculated gradient for the parameters.
batchSizeSize of batch to calculate gradient for.

◆ ImplicitDataset()

const arma::sp_mat& ImplicitDataset ( ) const
inline

Return the implicit data passed into the constructor.

Definition at line 113 of file svdplusplus_function.hpp.

◆ Lambda()

double Lambda ( ) const
inline

Return the regularization parameters.

Definition at line 125 of file svdplusplus_function.hpp.

◆ NumFunctions()

size_t NumFunctions ( ) const
inline

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

Definition at line 116 of file svdplusplus_function.hpp.

◆ NumItems()

size_t NumItems ( ) const
inline

Return the number of items in the data.

Definition at line 122 of file svdplusplus_function.hpp.

◆ NumUsers()

size_t NumUsers ( ) const
inline

Return the number of users in the data.

Definition at line 119 of file svdplusplus_function.hpp.

◆ Rank()

size_t Rank ( ) const
inline

Return the rank used for the factorization.

Definition at line 128 of file svdplusplus_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: