## 4 EPMRS Mathematical Model
### Weighted Feature Extraction
We note that the EPMRS has different matrices \(N\) based on how many types of ET, TD, and LOC the system has. The number of \(N\) is equal to \(|\text{ET}|\times|\text{TD}|\times|\text{LOC}|\), i.e., \(|\text{ET}|=4\), \(|\text{TD}|=5\), and \(|\text{LOC}|=3\) in the system because the EPMRS will record the users' behaviors under different emotions, the time of the day, and the location's conditions. For instance, \(N\)(happy, evening, home) representing one matrix means the users' preferences on songs under the condition of being happy, in the evening, and at home. We note that the selection of \(N\) with the conditions of being happy, evening, and home is based on the current data stored in the database. Thus, the result may be a null matrix. Let matrix \(M=(m_{j,k})\in\{0,1\}^{n\times v}\) denote a binary matrix that the songs correspond to their latent features. In the example, we assume each song has four latent features and we have  
\[M= \begin{array}{cccc}&f_{1}&f_{2}&f_{3}&f_{4}\\ &s_{1}\\ &s_{2}\\ &s_{3}\\ &s_{4}\\ &s_{5}\\ \end{array} \]  
For instance, \(M_{1,j}=[1~{}0~{}1~{}0]\) indicates that \(s_{1}\) has two features \(f_{1}\) and \(f_{3}\) and does not have features \(f_{2}\) and \(f_{4}\). We use matrices \(N\) and \(M\) to generate the matrix \(Q=(q_{i,k})\in\mathbf{Z}^{+n\times v}\) representing the user-to-feature relationship of size \(n\times v\) as  
\[Q=(q_{i,k})^{n\times v}=\sum_{j=1}^{|S|}m_{j,k},\forall n_{i,j}>T_{s}, \tag{2}\]where \(i=1,2,\ldots,n\), \(j=1,2,\ldots,m\), \(k=1,2,\ldots,v\), and \(T_{s}\) is the threshold value for overall interest for the song \(s\). In EPMRS, we set \(T_{s}=1\) as the default value:  
\[Q= \begin{array}{c}\begin{array}{cccc}f_{1}&f_{2}&f_{3}&f_{4}\\ u_{1}\\ u_{2}\\ u_{3}\\ u_{4}\\ u_{5}\\ u_{6}\end{array}&\begin{array}{cccc}f_{1}&f_{2}&f_{3}&f_{4}\\ 1&0&2&0\\ 2&2&3&1\\ 2&1&4&1\\ 1&2&0&2\\ 3&1&3&2\\ 2&1&3&1\end{array}\end{array} .\]  
The value \(q_{1,1}=1\) denotes that the feature \(f_{1}\) has appeared one time in the songs listened by the user \(u_{1}\), whereas the value \(q_{1,2}=0\) indicates that the feature \(f_{2}\) is not present in any of the songs listened to by the user \(u_{1}\). The matrix \(Q\) contains the relationship between each user \(u_{i}\) and all features, which includes some dominant features and some unimportant features with respect to the user \(u_{i}\). Hence, we apply weights on the features presented in the matrix \(Q\) to extract these dominant features with respect to each user \(u_{i}\). We use the term frequency and inverse document frequency (TF-IDF) [23] approach as the user feature frequency \(F_{U}(f_{k})\) and the inverse user frequency \(F_{U^{-1}}(f_{k})\) to generate the important features from the matrix \(Q\). The \(F_{U}(f_{k})\) represents which feature \(f_{k}\) is most relevant to the user \(u_{i}\) and is calculated as  
\[F_{U}(f_{k})=\sum_{i=1}^{|U|}1,\forall q_{i,k}>0,k=1,2,\ldots,v. \tag{3}\]  
Let \(F_{U}^{-1}(f_{k})\) represent how important a feature \(f_{k}\) is with respect to \(u_{i}\) and this is calculated as  
\[F_{U}^{-1}(f_{k})=\log\left(\frac{|U|}{F_{U}(f_{k})}\right). \tag{4}\]  
We note that \(F_{U}(f_{k})=F_{U}(f_{k})-0.1\) if \(F_{U}(f_{k})=|U|\). Let \(W=(w_{i,k})\in\mathbf{Z}^{+n\times v}\) denote the matrix of the weighted representation of \(Q\) and this is obtained by  
\[W=(w_{i,k})^{n\times v}=F_{U}(f_{k})\cdot F_{U}^{-1}(f_{k}),\forall u_{i}\in U, \tag{5}\]  
where \(i=1,2,\ldots,n\) and \(k=1,2,\ldots,v\). Following the example, we apply Equation (5) on the matrix \(Q\) to generate \(W=(w_{i,k})\in\mathbf{Z}^{+6\times 4}\) as  
\[W= \begin{array}{c}\begin{array}{c}\begin{array}{c}f_{1}\\ u_{2}\end{array}&\begin{array}{cccc}f_{1}\\ u_{2}\end{array}&\begin{array}{cccc}f_{1}\\ 0.007\\ 0.014\\ 0.014\\ 0.007\\ 0.007\\ 0.0158\\ u_{5}\\ u_{6}\end{array}&\begin{array}{cccc}f_{1}&f_{2}&f_{3}&f_{4}\\ 0.0158&0\\ 0.014&0.079&0.318&0.079\\ 0.0158&0&0.158\\ 0.021&0.079&0.238&0.158\\ 0.014&0.079&0.238&0.079\end{array}.\end{array}\end{array}