# Dirichlet Matrix Factorization: A Reliable Classification-Based Recommender System
## 2 Proposed Model
### Prediction  
Once the model has been trained, we have obtained a collection of users' latent vectors \(P_{u}^{s}\) as well as items' latent vectors \(Q_{i}^{s}\) for \(s\in\mathcal{S}\). Given a new pair user-item \((u,i)\) to be predicted, the Dirichlet MF method assigns to it the \(D\)-dimensional continuous random vector \(\mathbf{R}_{u,i}=(\mathbf{R}_{u,i}^{1},\ldots,\mathbf{R}_{u,i}^{D})\) with parameters \(\rho^{s}=\omega(P_{u}^{s}\cdot Q_{i}^{s})\). That is, it is the \(D\)-dimensional random vector supported on the standard simplex whose probability density function is given by (1):  
\[f(x_{1},\ldots,x_{D}\,|\,\omega(P_{u}\cdot Q_{i}))=\frac{1}{\mathrm{B}(\omega (P_{u}\cdot Q_{i}))}\prod_{s=1}^{D}x_{s}^{\omega(P_{u}^{s}\cdot Q_{i}^{s})-1}.\]  
From this distribution, discrete random variables with supports on \(\mathcal{S}\) can be sampled. These discrete probability distributions represent the probability that the user \(u\) would score item \(i\) with each of the possible ratings. However, observe that, in sharp contrast with other matrix factorization approaches, the output \(\mathbf{R}_{u,i}\) here is not a discrete distribution, but a random variable that takes values in discrete probability distributions. Several criteria can be used to obtain the predicted ratings. In this work, we shall follow an approach based on the law of large numbers. Indeed, if we sampled \(\mathbf{R}_{u,i}\) a large number of times, the mean probability of the score \(s\in\mathcal{S}\) would be the mean of the \(s\)-th component of the Dirichlet distribution with parameters \(\rho^{1}=\omega(P_{u}^{1}\cdot Q_{i}^{1}),\ldots,\rho^{D}=\omega(P_{u}^{D} \cdot Q_{i}^{D})\), which is the value:  
\[\mathbb{E}(\mathbf{R}_{u,i}^{s})=\frac{\omega(P_{u}^{s}\cdot Q_{i}^{s})}{\sum _{s\in\mathcal{S}}\omega(P_{u}^{s}\cdot Q_{i}^{s})}.\]  
These means are positive \(\mathbb{E}(\mathbf{R}_{u,i}^{s})\geq 0\) and \(\sum_{s}\mathbb{E}(\mathbf{R}_{u,i}^{s})=1\), so they give rise to a discrete probability distribution on \(\mathcal{S}\). From it, we obtain two relevant data:* The final prediction \(\hat{R}_{u,i}\), which is the mode of the aforementioned distribution, that is, \[\hat{R}_{u,i}=\operatorname{argmax}_{s}\ \mathbb{E}(\mathbf{R}_{u,i}^{s}).\]
* The reliability \(\varrho_{u,i}\) in the prediction, which is the probability attained at the mode of the distribution, that is, \[\varrho_{u,i}=\max_{s}\ \mathbb{E}(\mathbf{R}_{u,i}^{s}).\]  
In this manner, fixed a threshold \(0\leq\vartheta\leq 1\), we can crop the predictions so that we artificially set \(\hat{R}_{u,i}=\bullet\) (no prediction is issued) if the reliability does not achieves the given threshold, that is, if \(\varrho_{u,i}<\vartheta\). Otherwise, when \(\varrho_{u,i}\geq\vartheta\), we keep, as the prediction \(\hat{R}_{u,i}\), the mode of the mean probability distribution. Summarizing, the workflow associated to a cycle of training and exploitation phases of the DirMF model is as follows:  
1. Collect the rating matrix \(R\) of shape \(N\times M\) with the known votes per user and item;
2. Choose hyperparameters \(K\) (number of latent factors), \(\gamma\) (learning rate), \(\eta\) (regularization), \(m\) (number of iterations) and \(\vartheta\) (reliability threshold, for the exploitation phase);
3. Execute the training algorithm for DirMF (Algorithm 1) with the chosen hyperparameters. The output of the training is a collection of pairs of matrices \((P^{s}=(P^{s}_{1},\dots,P^{s}_{N}),Q^{s}=(Q^{s}_{1},\dots,Q^{s}_{M}))\) for each possible vote \(s\);
4. Given a new pair \((u,i)\) of an user \(1\leq u\leq N\) and an item \(1\leq i\leq M\) to be predicted, compute the quantities \[\mathbb{E}(\mathbf{R}_{u,i}^{s})=\frac{\omega(P^{s}_{u}\cdot Q^{s}_{i})}{\sum _{s\in\mathcal{S}}\omega(P^{s}_{u}\cdot Q^{s}_{i})},\] for each possible score \(s\);
5. The prediction \(\hat{R}_{u,i}\) is the vote \(s_{0}\) for which \(\mathbb{E}(\mathbf{R}_{u,i}^{s_{0}})\) is maximum. The reliability is the value \(\varrho_{u,i}=\mathbb{E}(\mathbf{R}_{u,i}^{s_{0}})\). 6.