# Dirichlet Matrix Factorization: A Reliable Classification-Based Recommender System
## 2 Proposed Model
### Dirichlet Factorization  
In this section, we shall describe the mathematical formulation of the Dirichlet factorization model. Recall that, given parameters \(\rho^{1}\ldots,\rho^{D}>0\), the associated Dirichlet distribution is the \(D\)-dimensional random vector with joint probability density function \(f_{\rho_{1}\ldots,\rho_{D}}:\mathbb{R}^{D}\rightarrow\mathbb{R}^{D}\) given by  
\[f(x_{1},\ldots,x_{D}\,|\,\rho^{1},\ldots,\rho^{D})=\frac{1}{\mathrm{B}(\rho^{ 1}\ldots,\rho^{D})}\prod_{s=1}^{D}x_{s}^{\rho^{s}-1}, \tag{1}\]  
Figure 1: Plate diagram of DirMF model. for variables \(x_{s}\) in the standard simplex, i.e., \(x_{1},\ldots,x_{D}\geq 0\) and \(\sum_{s\in\mathcal{S}}x_{s}=1\). The density function is zero elsewhere. Here, the normalization factor is the Beta function  
\[\text{B}(\rho^{1},\ldots,\rho^{D})=\frac{\prod_{s=1}^{D}\Gamma(\rho^{s})}{ \Gamma\Big{(}\sum_{s=1}^{D}\rho^{s}\Big{)}},\]  
with \(\Gamma\) the Gamma function (the analytic continuation of the factorial into a meromorphic function in the complex plane). In this way, if we set as parameters \(\rho^{s}_{u,i}=\omega(P^{s}_{u}\cdot Q^{s}_{i})\) then, given the rating matrix \(R=(R_{u,i})_{u,i}\) decomposed into binary matrices \(R^{s}=(R^{s}_{u,i})_{u,i}\), we obtain that the associated likelihood \(\mathcal{L}(R|P,Q)\) is  
\[\mathcal{L}(R|P,Q)=\prod_{R_{u,i}\
eq\bullet}\frac{1}{\text{B}(\omega(P_{u} \cdot Q_{i}))}\prod_{s\in\mathcal{S}}(R^{s}_{u,i})^{\omega(P^{s}_{u}\cdot Q^{ s}_{i})-1}.\]  
Here, we have shortened \(\text{B}(\omega(P_{u}\cdot Q_{i}))=\text{B}(\omega(P^{1}_{u}\cdot Q^{1}_{i}),\ldots,\omega(P^{D}_{u}\cdot Q^{D}_{i}))\). However, observe that, since \(R^{s}_{u,i}\) is either 0 or 1, the previous likelihood is zero except for perfect prediction. To avoid this issue, we propose to use a'soft' version of the binary labeling. To do so, we take the softmax of the hard labels:  
\[\tilde{R}^{s}_{u,i}=\text{softmax}^{s}_{\beta_{u,i}}(R^{1}_{u,i},\ldots,R^{D}_{ u,i})=\frac{e^{\beta_{u,i}}R^{s}_{u,i}}{\sum_{r=1}^{D}e^{\beta_{u,i}}R^{r}_{u,i}}= \begin{cases}\frac{e^{\beta_{u,i}}}{(D-1)+e^{\beta_{u,i}}}&\text{if }R^{s}_{u,i}=1,\\ \frac{1}{(D-1)+e^{\beta_{u,i}}}&\text{if }R^{s}_{u,i}=0.\end{cases}  \tag{2}\]  
Here, \(\beta_{u,i}>0\) is a shape hyperparameter that controls the sharpness of the softmax function. It can be adjusted to increase the weight of some pairs \((u,i)\) in the likelihood function. In this way, the modified likelihood function that we shall consider is:  
\[\mathcal{L}(R|P,Q)=\prod_{R_{u,i}\
eq\bullet}\frac{1}{\text{B}(\omega(P_{u} \cdot Q_{i}))}\prod_{s\in\mathcal{S}}(\tilde{R}^{s}_{u,i})^{\omega(P^{s}_{u} \cdot Q^{s}_{i})-1}. \tag{3}\]  
Hence, the log-likelihood function, \(\ell(R|P,Q)=\log\mathcal{L}(R|P,Q)\), is given by:  
\[\ell(R|P,Q)= \sum_{R_{u,i}\
eq\bullet}\log\left(\Gamma\left(\sum_{s\in\mathcal{ S}}\omega(P^{s}_{u}\cdot Q^{s}_{i})\right)\right)-\sum_{s\in\mathcal{S}}\log( \Gamma(\omega(P^{s}_{u}\cdot Q^{s}_{i})))\] \[+\sum_{R_{u,i}\
eq\bullet}\sum_{s\in\mathcal{S}}\omega(P^{s}_{u} \cdot Q^{s}_{i})\log(\tilde{R}^{s}_{u,i}).\]  
To optimize this likelihood function, we will use a standard gradient ascent algorithm.