\section{Introduction}\label{cftutorial_intro_cftut}
Collaborative filtering is an increasingly popular approach for recommender systems. A typical formulation of the problem is as follows\+: there are $n$ users and $m$ items, and each user has rated some of the items. We want to provide each user with a recommendation for an item they have not rated yet, which they are likely to rate highly. In another formulation, we may want to predict a user\textquotesingle{}s rating of an item. This type of problem has been considered extensively, especially in the context of the Netflix prize. The winning approach for the Netflix prize was a collaborative filtering approach which utilized matrix decomposition. More information on their approach can be found in the following paper\+:


\begin{DoxyCode}
@article\{koren2009matrix,
  title=\{Matrix factorization techniques \textcolor{keywordflow}{for} recommender systems\},
  author=\{Koren, Yehuda and Bell, Robert and Volinsky, Chris\},
  journal=\{Computer\},
  number=\{8\},
  pages=\{30--37\},
  year=\{2009\},
  publisher=\{IEEE\}
\}
\end{DoxyCode}


The key to this approach is that the data is represented as an incomplete matrix $V \in \Re^{n \times m}$, where $V_{ij}$ represents user $i$\textquotesingle{}s rating of item $j$, if that rating exists. The task, then, is to complete the entries of the matrix.

In the matrix factorization framework, the matrix $V$ is assumed to be low-\/rank and decomposed into components as $V \approx WH$ according to some heuristic.

In order to solve problems of this form, {\bfseries mlpack} provides\+:


\begin{DoxyItemize}
\item a \doxyref{simple command-\/line interface}{p.}{cftutorial_cli_cftut} to perform collaborative filtering
\item a \doxyref{simple C++ interface}{p.}{cftutorial_cf_cftut} to perform collaborative filtering
\item an \doxyref{extensible C++ interface}{p.}{cftutorial_cpp_cftut} for implementing new collaborative filtering techniques
\end{DoxyItemize}\section{Table of Contents}\label{cftutorial_toc_cftut}

\begin{DoxyItemize}
\item \doxyref{Introduction}{p.}{cftutorial_intro_cftut}
\item \doxyref{Table of Contents}{p.}{cftutorial_toc_cftut}
\item \doxyref{The \textquotesingle{}mlpack\+\_\+cf\textquotesingle{} program}{p.}{cftutorial_cli_cftut}
\begin{DoxyItemize}
\item \doxyref{Input format for mlpack\+\_\+cf}{p.}{cftutorial_cli_input_format}
\item \doxyref{mlpack\+\_\+cf with default parameters}{p.}{cftutorial_ex1_cf_cli}
\item \doxyref{Saving mlpack\+\_\+cf models}{p.}{cftutorial_ex1a_cf_cli}
\item \doxyref{Loading mlpack\+\_\+cf models}{p.}{cftutorial_ex1b_cf_cli}
\item \doxyref{Specifying rank of mlpack\+\_\+cf decomposition}{p.}{cftutorial_ex2_cf_cli}
\item \doxyref{mlpack\+\_\+cf with single-\/user recommendation}{p.}{cftutorial_ex3_cf_cli}
\item \doxyref{mlpack\+\_\+cf with non-\/default factorizer}{p.}{cftutorial_ex4_cf_cli}
\item \doxyref{mlpack\+\_\+cf with non-\/default neighborhood size}{p.}{cftutorial_ex5_cf_cli}
\end{DoxyItemize}
\item \doxyref{The \textquotesingle{}CF\textquotesingle{} class}{p.}{cftutorial_cf_cftut}
\begin{DoxyItemize}
\item \doxyref{CF with default parameters}{p.}{cftutorial_ex1_cf_cpp}
\item \doxyref{CF with other factorizers}{p.}{cftutorial_ex2_cf_cpp}
\item \doxyref{Predicting individual user/item ratings}{p.}{cftutorial_ex3_cf_cpp}
\item \doxyref{Other operations with the W and H matrices}{p.}{cftutorial_ex4_cf_cpp}
\end{DoxyItemize}
\item \doxyref{Template parameters for the \textquotesingle{}CF\textquotesingle{} class}{p.}{cftutorial_cpp_cftut}
\item \doxyref{Further documentation}{p.}{cftutorial_further_doc_cftut}
\end{DoxyItemize}\section{The \textquotesingle{}mlpack\+\_\+cf\textquotesingle{} program}\label{cftutorial_cli_cftut}
{\bfseries mlpack} provides a command-\/line program, {\ttfamily mlpack\+\_\+cf}, which is used to perform collaborative filtering on a given dataset. It can provide neighborhood-\/based recommendations for users. The algorithm used for matrix factorization is configurable, and the parameters of each algorithm are also configurable.

The following examples detail usage of the {\ttfamily mlpack\+\_\+cf} program. Note that you can get documentation on all the possible parameters by typing\+:


\begin{DoxyCode}
$ mlpack\_cf --help
\end{DoxyCode}
\subsection{Input format for mlpack\+\_\+cf}\label{cftutorial_cli_input_format}
The input file for the {\ttfamily mlpack\+\_\+cf} program is specified with the {\ttfamily --training\+\_\+file} or {\ttfamily -\/t} option. This file is a coordinate-\/format sparse matrix, similar to the Matrix Market (MM) format. The first coordinate is the user id; the second coordinate is the item id; and the third coordinate is the rating. So, for instance, a dataset with 3 users and 2 items, and ratings between 1 and 5, might look like the following\+:


\begin{DoxyCode}
$ cat dataset.csv
0, 1, 4
1, 0, 5
1, 1, 1
2, 0, 2
\end{DoxyCode}


This dataset has four ratings\+: user 0 has rated item 1 with a rating of 4; user 1 has rated item 0 with a rating of 5; user 1 has rated item 1 with a rating of 1; and user 2 has rated item 0 with a rating of 2. Note that the user and item indices start from 0, and the identifiers must be numeric indices, and not names.

The type does not necessarily need to be a csv; it can be any supported storage format, assuming that it is a coordinate-\/format file in the format specified above. For more information on mlpack file formats, see the documentation for \doxyref{mlpack\+::data\+::\+Load()}{p.}{namespacemlpack_1_1data_a19805d6585ac8b0be7c4e4b7f081977c}.\subsection{mlpack\+\_\+cf with default parameters}\label{cftutorial_ex1_cf_cli}
In this example, we have a dataset from Movie\+Lens, and we want to use {\ttfamily mlpack\+\_\+cf} with the default parameters, which will provide 5 recommendations for each user, and we wish to save the results in the file {\ttfamily recommendations.\+csv}. Assuming that our dataset is in the file {\ttfamily Movie\+Lens-\/100k.\+csv} and it is in the correct format, we may use the {\ttfamily mlpack\+\_\+cf} executable as below\+:


\begin{DoxyCode}
$ mlpack\_cf -t MovieLens-100k.csv -v -o recommendations.csv
\end{DoxyCode}


The {\ttfamily -\/v} option provides verbose output, and may be omitted if desired. Now, for each user, we have recommendations in {\ttfamily recommendations.\+csv\+:} 


\begin{DoxyCode}
$ head recommendations.csv
317,422,482,356,495
116,120,180,6,327
312,49,116,99,236
312,116,99,236,285
55,190,317,194,63
171,209,180,175,95
208,0,94,87,57
99,97,0,203,172
257,99,180,287,0
171,203,172,209,88
\end{DoxyCode}


So, for user 0, the top 5 recommended items that user 0 has not rated are items 317, 422, 482, 356, and 495. For user 5, the recommendations are on the sixth line\+: 171, 209, 180, 175, 95.

The {\ttfamily mlpack\+\_\+cf} program can be built into a larger recommendation framework, with a preprocessing step that can turn user information and item information into numeric I\+Ds, and a postprocessing step that can map these numeric I\+Ds back to the original information.\subsection{Saving mlpack\+\_\+cf models}\label{cftutorial_ex1a_cf_cli}
The {\ttfamily mlpack\+\_\+cf} program is able to save a particular model for later loading. Saving a model can be done with the {\ttfamily --output\+\_\+model\+\_\+file} or {\ttfamily -\/M} option. The example below builds a CF model on the {\ttfamily Movie\+Lens-\/100k.\+csv} dataset, and then saves the model to the file {\ttfamily cf-\/model.\+xml} for later usage.


\begin{DoxyCode}
$ mlpack\_cf -t MovieLens-100k.csv -M cf-model.xml -v
\end{DoxyCode}


The models can also be saved as {\ttfamily }.bin or {\ttfamily }.txt; the {\ttfamily }.xml format provides a human-\/inspectable format (though the models tend to be quite complex and may be difficult to read). These models can then be re-\/used to provide specific recommendations for certain users, or other tasks.\subsection{Loading mlpack\+\_\+cf models}\label{cftutorial_ex1b_cf_cli}
Instead of training a model, the {\ttfamily mlpack\+\_\+cf} model can also load a model to provide recommendations, using the {\ttfamily --input\+\_\+model\+\_\+file} or {\ttfamily -\/m} option. For instance, the example below will load the model from {\ttfamily cf-\/model.\+xml} and then generate 3 recommendations for each user in the dataset, saving the results to {\ttfamily recommendations.\+csv}.


\begin{DoxyCode}
$ mlpack\_cf -m cf-model.xml -v -o recommendations.csv
\end{DoxyCode}
\subsection{Specifying rank of mlpack\+\_\+cf decomposition}\label{cftutorial_ex2_cf_cli}
By default, the matrix factorizations in the {\ttfamily mlpack\+\_\+cf} program decompose the data matrix into two matrices $W$ and $H$ with rank two. Often, this default parameter is not correct, and it makes sense to use a higher-\/rank decomposition. The rank can be specified with the {\ttfamily --rank} or {\ttfamily -\/R} parameter\+:


\begin{DoxyCode}
$ mlpack\_cf -t MovieLens-100k.csv -R 10 -v
\end{DoxyCode}


In the example above, the data matrix will be decomposed into two matrices of rank 10. In general, higher-\/rank decompositions will take longer, but will give more accurate predictions.\subsection{mlpack\+\_\+cf with single-\/user recommendation}\label{cftutorial_ex3_cf_cli}
In the previous two examples, the output file {\ttfamily recommendations.\+csv} contains one line for each user in the input dataset. But often, recommendations may only be desired for a few users. In that case, we can assemble a file of query users, with one user per line\+:


\begin{DoxyCode}
$ cat query.csv
0
17
31
\end{DoxyCode}


Now, if we run the {\ttfamily mlpack\+\_\+cf} executable with this query file, we will obtain recommendations for users 0, 17, and 31\+:


\begin{DoxyCode}
$ mlpack\_cf -i MovieLens-100k.csv -R 10 -q query.csv -o recommendations.csv
$ cat recommendations.csv
474,356,317,432,473
510,172,204,483,182
0,120,236,257,126
\end{DoxyCode}
\subsection{mlpack\+\_\+cf with non-\/default factorizer}\label{cftutorial_ex4_cf_cli}
The {\ttfamily --algorithm} (or {\ttfamily -\/a} ) parameter controls the factorizer that is used. Several options are available\+:


\begin{DoxyItemize}
\item {\ttfamily \textquotesingle{}N\+MF\textquotesingle{}}\+: non-\/negative matrix factorization; see mlpack\+::amf\+::\+A\+M\+F$<$$>$
\item {\ttfamily \textquotesingle{}S\+V\+D\+Batch\textquotesingle{}}\+: S\+VD batch factorization
\item {\ttfamily \textquotesingle{}S\+V\+D\+Incomplete\+Incremental\textquotesingle{}}\+: incomplete incremental S\+VD
\item {\ttfamily \textquotesingle{}S\+V\+D\+Complete\+Incremental\textquotesingle{}}\+: complete incremental S\+VD
\item {\ttfamily \textquotesingle{}Reg\+S\+VD\textquotesingle{}}\+: regularized S\+VD; see \doxyref{mlpack\+::svd\+::\+Regularized\+S\+VD}{p.}{classmlpack_1_1svd_1_1RegularizedSVD}
\end{DoxyItemize}

The default factorizer is {\ttfamily \textquotesingle{}N\+MF\textquotesingle{}}. The example below uses the \textquotesingle{}Reg\+S\+VD\textquotesingle{} factorizer\+:


\begin{DoxyCode}
$ mlpack\_cf -i MovieLens-100k.csv -R 10 -q query.csv -a RegSVD -o recommendations.csv
\end{DoxyCode}
\subsection{mlpack\+\_\+cf with non-\/default neighborhood size}\label{cftutorial_ex5_cf_cli}
The {\ttfamily mlpack\+\_\+cf} program produces recommendations using a neighborhood\+: similar users in the query user\textquotesingle{}s neighborhood will be averaged to produce predictions. The size of this neighborhood is controlled with the {\ttfamily --neighborhood} (or {\ttfamily -\/n} ) option. An example using a neighborhood with 10 similar users is below\+:


\begin{DoxyCode}
$ mlpack\_cf -i MovieLens-100k.csv -R 10 -q query.csv -a RegSVD -n 10
\end{DoxyCode}
\section{The \textquotesingle{}\+C\+F\textquotesingle{} class}\label{cftutorial_cf_cftut}
The {\ttfamily CF} class in {\bfseries mlpack} offers a simple, flexible A\+PI for performing collaborative filtering for recommender systems within C++ applications. In the constructor, the {\ttfamily CF} class takes a coordinate-\/list dataset and decomposes the matrix according to the specified {\ttfamily Factorizer\+Type} template parameter.

Then, the {\ttfamily Get\+Recommendations()} function may be called to obtain recommendations for certain users (or all users), and the {\ttfamily W()} and {\ttfamily H()} matrices may be accessed to perform other computations.

The data which the {\ttfamily CF} constructor takes should be an Armadillo matrix ({\ttfamily arma\+::mat} ) with three rows. The first row corresponds to users; the second row corresponds to items; the third column corresponds to the rating. This is a coordinate list format, like the format the {\ttfamily cf} executable takes. The \doxyref{data\+::\+Load()}{p.}{namespacemlpack_1_1data_a19805d6585ac8b0be7c4e4b7f081977c} function can be used to load data.

The following examples detail a few ways that the {\ttfamily CF} class can be used.\subsection{C\+F with default parameters}\label{cftutorial_ex1_cf_cpp}
This example constructs the {\ttfamily CF} object with default parameters and obtains recommendations for each user, storing the output in the {\ttfamily recommendations} matrix.


\begin{DoxyCode}
\textcolor{preprocessor}{#include <mlpack/methods/cf/cf.hpp>}

\textcolor{keyword}{using namespace }mlpack::cf;

\textcolor{comment}{// The coordinate list of ratings that we have.}
\textcolor{keyword}{extern} arma::mat data;
\textcolor{comment}{// The size of the neighborhood to use to get recommendations.}
\textcolor{keyword}{extern} \textcolor{keywordtype}{size\_t} neighborhood;
\textcolor{comment}{// The rank of the decomposition.}
\textcolor{keyword}{extern} \textcolor{keywordtype}{size\_t} rank;

\textcolor{comment}{// Build the CF object and perform the decomposition.}
\textcolor{comment}{// The constructor takes a default-constructed factorizer, which, by default,}
\textcolor{comment}{// is of type amf::NMFALSFactorizer.}
CF cf(data, amf::NMFALSFactorizer(), neighborhood, rank);

\textcolor{comment}{// Store the results in this object.}
arma::Mat<size\_t> recommendations;

\textcolor{comment}{// Get 5 recommendations for all users.}
cf.GetRecommendations(5, recommendations);
\end{DoxyCode}
\subsection{C\+F with other factorizers}\label{cftutorial_ex2_cf_cpp}
{\bfseries mlpack} provides a number of existing factorizers which can be used in place of the default \doxyref{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Factorizer}{p.}{namespacemlpack_1_1amf_a3e3179901b352438bc974218b6ba0fab} (which is non-\/negative matrix factorization with alternating least squares update rules). These include\+:


\begin{DoxyItemize}
\item \doxyref{mlpack\+::amf\+::\+S\+V\+D\+Batch\+Factorizer}{p.}{namespacemlpack_1_1amf_aedb113157f87759c24e2368dfd7b9216}
\item \doxyref{mlpack\+::amf\+::\+S\+V\+D\+Complete\+Incremental\+Factorizer}{p.}{namespacemlpack_1_1amf_aeaa4b749fc1afc70451f096dca4228b5}
\item \doxyref{mlpack\+::amf\+::\+S\+V\+D\+Incomplete\+Incremental\+Factorizer}{p.}{namespacemlpack_1_1amf_a681ac877cb603d00766e015ff4d4c294}
\item \doxyref{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Factorizer}{p.}{namespacemlpack_1_1amf_a3e3179901b352438bc974218b6ba0fab}
\item \doxyref{mlpack\+::svd\+::\+Regularized\+S\+VD}{p.}{classmlpack_1_1svd_1_1RegularizedSVD}
\item \doxyref{mlpack\+::svd\+::\+Q\+U\+I\+C\+\_\+\+S\+VD}{p.}{classmlpack_1_1svd_1_1QUIC__SVD}
\end{DoxyItemize}

The amf\+::\+A\+M\+F$<$$>$ class has many other possibilities than those listed here; it is a framework for alternating matrix factorization techniques. See the class documentation or \doxyref{tutorial on A\+MF}{p.}{amftutorial} for more information.

The use of another factorizer is straightforward; the example from the previous section is adapted below to use svd\+::\+Regularized\+S\+VD\+:


\begin{DoxyCode}
\textcolor{preprocessor}{#include <mlpack/methods/cf/cf.hpp>}
\textcolor{preprocessor}{#include <mlpack/methods/regularized_svd/regularized_svd.hpp>}

\textcolor{keyword}{using namespace }mlpack::cf;

\textcolor{comment}{// The coordinate list of ratings that we have.}
\textcolor{keyword}{extern} arma::mat data;
\textcolor{comment}{// The size of the neighborhood to use to get recommendations.}
\textcolor{keyword}{extern} \textcolor{keywordtype}{size\_t} neighborhood;
\textcolor{comment}{// The rank of the decomposition.}
\textcolor{keyword}{extern} \textcolor{keywordtype}{size\_t} rank;

\textcolor{comment}{// Build the CF object and perform the decomposition.}
CF cf(data, svd::RegularizedSVD(), neighborhood, rank);

\textcolor{comment}{// Store the results in this object.}
arma::Mat<size\_t> recommendations;

\textcolor{comment}{// Get 5 recommendations for all users.}
cf.GetRecommendations(5, recommendations);
\end{DoxyCode}
\subsection{Predicting individual user/item ratings}\label{cftutorial_ex3_cf_cpp}
The {\ttfamily Predict()} method can be used to predict the rating of an item by a certain user, using the same neighborhood-\/based approach as the {\ttfamily Get\+Recommendations()} function or the {\ttfamily cf} executable. Below is an example of the use of that function.

The example below will obtain the predicted rating for item 50 by user 12.


\begin{DoxyCode}
\textcolor{preprocessor}{#include <mlpack/methods/cf/cf.hpp>}

\textcolor{keyword}{using namespace }mlpack::cf;

\textcolor{comment}{// The coordinate list of ratings that we have.}
\textcolor{keyword}{extern} arma::mat data;
\textcolor{comment}{// The size of the neighborhood to use to get recommendations.}
\textcolor{keyword}{extern} \textcolor{keywordtype}{size\_t} neighborhood;
\textcolor{comment}{// The rank of the decomposition.}
\textcolor{keyword}{extern} \textcolor{keywordtype}{size\_t} rank;

\textcolor{comment}{// Build the CF object and perform the decomposition.}
\textcolor{comment}{// The constructor takes a default-constructed factorizer, which, by default,}
\textcolor{comment}{// is of type amf::NMFALSFactorizer.}
CF cf(data, amf::NMFALSFactorizer(), neighborhood, rank);

\textcolor{keyword}{const} \textcolor{keywordtype}{double} prediction = cf.Predict(12, 50); \textcolor{comment}{// User 12, item 50.}
\end{DoxyCode}
\subsection{Other operations with the W and H matrices}\label{cftutorial_ex4_cf_cpp}
Sometimes, the raw decomposed W and H matrices can be useful. The example below obtains these matrices, and multiplies them against each other to obtain a reconstructed data matrix with no missing values.


\begin{DoxyCode}
\textcolor{preprocessor}{#include <mlpack/methods/cf/cf.hpp>}

\textcolor{keyword}{using namespace }mlpack::cf;

\textcolor{comment}{// The coordinate list of ratings that we have.}
\textcolor{keyword}{extern} arma::mat data;
\textcolor{comment}{// The size of the neighborhood to use to get recommendations.}
\textcolor{keyword}{extern} \textcolor{keywordtype}{size\_t} neighborhood;
\textcolor{comment}{// The rank of the decomposition.}
\textcolor{keyword}{extern} \textcolor{keywordtype}{size\_t} rank;

\textcolor{comment}{// Build the CF object and perform the decomposition.}
\textcolor{comment}{// The constructor takes a default-constructed factorizer, which, by default,}
\textcolor{comment}{// is of type amf::NMFALSFactorizer.}
CF cf(data, amf::NMFALSFactorizer(), neighborhood, rank);

\textcolor{comment}{// References to W and H matrices.}
\textcolor{keyword}{const} arma::mat& W = cf.W();
\textcolor{keyword}{const} arma::mat& H = cf.H();

\textcolor{comment}{// Multiply the matrices together.}
arma::mat reconstructed = W * H;
\end{DoxyCode}
\section{Template parameters for the \textquotesingle{}\+C\+F\textquotesingle{} class}\label{cftutorial_cpp_cftut}
The {\ttfamily CF} class takes the {\ttfamily Factorizer\+Type} as a template parameter to some of its constructors and to the {\ttfamily Train()} function. The {\ttfamily Factorizer\+Type} class defines the algorithm used for matrix factorization. There are a number of existing factorizers that can be used in {\bfseries mlpack}; these were detailed in the \doxyref{\textquotesingle{}other factorizers\textquotesingle{} example}{p.}{cftutorial_ex2_cf_cpp} of the previous section.

The {\ttfamily Factorizer\+Type} class must implement one of the two following methods\+:


\begin{DoxyItemize}
\item {\ttfamily Apply(arma\+::mat\& data, const size\+\_\+t rank, arma\+::mat\& W, arma\+::mat\& H);}
\item {\ttfamily Apply(arma\+::sp\+\_\+mat\& data, const size\+\_\+t rank, arma\+::mat\& W, arma\+::mat\& H);}
\end{DoxyItemize}

The difference between these two methods is whether {\ttfamily arma\+::mat} or {\ttfamily arma\+::sp\+\_\+mat} is used as input. If {\ttfamily arma\+::mat} is used, then the data matrix is a coordinate list with three columns, as in the constructor to the {\ttfamily CF} class. If {\ttfamily arma\+::sp\+\_\+mat} is used, then a sparse matrix is passed with the number of rows equal to the number of items and the number of columns equal to the number of users, and each nonzero element in the matrix corresponds to a non-\/missing rating.

The method that the factorizer implements is specified via the {\ttfamily Factorizer\+Traits} class, which is a template metaprogramming traits class\+:


\begin{DoxyCode}
\textcolor{keyword}{template}<\textcolor{keyword}{typename} FactorizerType>
\textcolor{keyword}{struct }FactorizerTraits
\{
  \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{bool} UsesCoordinateList = \textcolor{keyword}{false};
\};
\end{DoxyCode}


If {\ttfamily Factorizer\+Traits$<$\+My\+Factorizer$>$\+::\+Uses\+Coordinate\+List} is {\ttfamily true}, then {\ttfamily CF} will try to call {\ttfamily Apply()} with an {\ttfamily arma\+::mat} object. Otherwise, {\ttfamily CF} will try to call {\ttfamily Apply()} with an {\ttfamily arma\+::sp\+\_\+mat} object. Specifying the value of {\ttfamily Uses\+Coordinate\+List} is straightforward; provide this specialization of the {\ttfamily Factorizer\+Traits} class\+:


\begin{DoxyCode}
\textcolor{keyword}{template}<>
\textcolor{keyword}{struct }FactorizerTraits<MyFactorizer>
\{
  \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{bool} UsesCoordinateList = \textcolor{keyword}{true}; \textcolor{comment}{// Set your value here.}
\};
\end{DoxyCode}


The {\ttfamily Apply()} function also takes a reference to the matrices {\ttfamily W} and {\ttfamily H}. When the {\ttfamily Apply()} function returns, the input data matrix should be decomposed into these two matrices. {\ttfamily W} should have number of rows equal to the number of items and number of columns equal to the {\ttfamily rank} parameter, and {\ttfamily H} should have number of rows equal to the {\ttfamily rank} parameter, and number of columns equal to the number of users.

The \doxyref{amf\+:\+:A\+MF$<$$>$ class}{p.}{classmlpack_1_1amf_1_1AMF} can be used as a base for factorizers that alternate between updating {\ttfamily W} and updating {\ttfamily H}. A useful reference is the \doxyref{A\+MF tutorial}{p.}{amftutorial}.\section{Further documentation}\label{cftutorial_further_doc_cftut}
Further documentation for the {\ttfamily CF} class may be found in the complete A\+PI documentation. In addition, more information on the {\ttfamily A\+MF} class of factorizers may be found in its \doxyref{complete A\+PI documentation}{p.}{classmlpack_1_1amf_1_1AMF}. 