# Recommendation Framework Combining User Interests with Fashion Trends in Apparel Online Shopping
## 3 Proposed Method
### Rating Item Clusters
\begin{table}
\begin{tabular}{c c c c c c} \hline
**User ID** & **Item ID** & **Gender** & **Category** & **Activity** & **Time Stamp** \\ \hline \(u_{1}\) & \(i_{1}\) & W & \(A_{1}\) & CLICK & 2017-01-09 20:59 \\ \(u_{1}\) & \(i_{4}\) & W & \(A_{1}\) & CLICK & 2017-01-09 21:00 \\ \(u_{1}\) & \(i_{3}\) & W & \(A_{1}\) & CLICK & 2017-01-09 21:01 \\ \(u_{1}\) & \(i_{1}\) & W & \(A_{1}\) & CLICK & 2017-01-09 21:17 \\ \(u_{1}\) & \(i_{7}\) & W & \(A_{2}\) & CLICK & 2017-01-10 19:05 \\ \(u_{1}\) & \(i_{3}\) & W & \(A_{1}\) & ORDER & 2017-01-10 19:07 \\ \hline \(u_{2}\) & \(i_{2}\) & W & \(A_{1}\) & CLICK & 2017-01-09 11:24 \\ \(u_{2}\) & \(i_{3}\) & W & \(A_{1}\) & CLICK & 2017-01-09 11:31 \\ \(u_{2}\) & \(i_{3}\) & W & \(A_{1}\) & CART & 2017-01-09 11:36 \\ \(u_{2}\) & \(i_{2}\) & W & \(A_{1}\) & CLICK & 2017-01-10 15:27 \\ \(u_{2}\) & \(i_{5}\) & W & \(A_{1}\) & CLICK & 2017-01-10 15:31 \\ \(u_{2}\) & \(i_{2}\) & W & \(A_{1}\) & CLICK & 2017-01-10 16:02 \\ \hline \(u_{3}\) & \(i_{6}\) & W & \(A_{2}\) & ORDER & 2017-01-09 13:37 \\ \(u_{3}\) & \(i_{8}\) & W & \(A_{2}\) & CLICK & 2017-01-10 17:18 \\ \(u_{3}\) & \(i_{9}\) & M & \(A_{3}\) & CLICK & 2017-01-10 18:09 \\ \hline \end{tabular}
\end{table} 
Table 1: An example of user activity log. click, \(N(CLICK(1)\cap ORDER)=1\). After finding \(N(CLICK(k)\cap ORDER)\) and \(N(CLICK(k))\) for each \(k\) (\(k=1,\ 2,\ 3,\cdots\)), we compute the proportion of purchases to the total number of \(k\) clicks:  
\[w_{click}(k)=\frac{N(CLICK(k)\cap ORDER)}{N(CLICK(k))}. \tag{2}\]  
Therefore, \(w_{click}(1)=\frac{1}{2}\) from our example, which means that one purchase occurred among seven one-click activities. Instead of using \(w_{click}(k)\) directly, we propose to estimate a function \(f\), by fitting \(w_{click}(k)\) on \(k\) and use the predicted value \(f(k)=\hat{w}_{click}(k)\), such that the click rating can be generalized and robust to outliers. The \(f\) can be any function that can determine the relationship between the number of clicks (\(k\)) and the proportion of purchases by \(k\) clicks (\(w_{click}(k)\)), but we believe that a sigmoid function would be a good choice, because a lag phase at small \(k\) values and a stabilization phase at large \(k\) values tend to appear in purchase behaviors. The example in Table 1 is too small to show a fitted function. See the graph of the function fitted based on our real dataset in Figure 7, where the hollow circles indicate the observed pairs of \(\{k,w_{click}(k)\}\) from our real dataset. In summary, \(k\) click activity, cart activity, and order activity on a certain item by a user is rated by \(\hat{w}_{click}(k)\), \(w_{cart}\), and \(w_{order}\), respectively, across all users and all items. Although we applied our rating scheme to three types of activities, notice that Equation (1) can be applied to any other one-time activity and Equation (2) to any other recurring activities if needed. To finally determine the user \(u\)'s implicit rating on item \(i\) (\(r_{ui}\)), we first assign \(\hat{w}_{click}(k)\), \(w_{cart}\), and \(w_{order}\) values based on the user-item-activity combination, and then take the maximum value among those. Table 2 shows how the implicit ratings can be generated from the activity ratings by using the example in Table 1. Notice that, owing to the size of the example, we used \(\hat{w}_{click}(1)=0.021\), \(\hat{w}_{click}(2)=0.032\), \(\hat{w}_{click}(3)=0.049\), and \(w_{cart}=0.18\), as shown in Figure 7, which were computed from our real dataset. Based on the user-item ratings matrix, we derive the item similarity of item \(i\) and item \(j\), \(sim(i,j)\) by calculating the cosine similarity of item vectors as follows:  
\[sim(i,j)=\frac{\sum_{u\in[U(i)\cap U(j)]}r_{ui}\cdot r_{uj}}{\sqrt{\sum_{u\in [U(i)\cap U(j)]}r_{ui}\cdot 2}\cdot\sqrt{\sum_{u\in[U(i)\cap U(j)]}r_{uj} \cdot 2}}, \tag{3}\]  
where \(U(i)\) and \(U(j)\) denote the set of users who have accessed item \(i\) and item \(j\), respectively.