## 3 The Proposed Recommendation System
### Collaborative Filtering  
In addition to content-based filtering, we also use collaborative filtering. The advantage of using collaborative filtering is that it is able to recommend things based on the patterns of others without requiring personal or item information. Collaborative filtering has become popular because of the Netflix Prize, an open competition for the best collaborative filtering algorithm. We use two notable algorithms for collaborative filtering. The first algorithm for collaborative filtering is the KNN classifier [60; 61; 62]. The KNN algorithm is one example of lazy learning since it memorizes the data sets instead of learning a discriminative function from the data sets. As the name implies, the KNN algorithm is straightforward. 1. Get the system parameters, such as \(k\) (the number of neighbors) and a metric for measuring the distance. 2. Locate reference points for data sets in a feature space. 3. Find the \(k\)-nearest neighbors based on the distance metric. 4. Calculate the majority and assign a label to a class. Simply put, the KNN algorithm uses the following formula for the expected similarity to weigh the score based on the \(k\)-nearest neighbors in a feature space:  
\[Expected(r_{u,i})=\frac{\sum_{v}Similarity(u,v)\times r_{v,i}}{\sum_{v}Similarity (u,v)} \tag{5}\] \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline  & **And** & **Cold** & **Drinking** & **Jack** & **Juice** & **Kevin** & **Like** & **Warm** & **Water** \\ \hline Document 1 & 0 & 0 & 1 & 0 & 0 & 1.41 & 1 & 0 & 0 \\ Document 2 & 0 & 0 & 1 & 1.41 & 2.10 & 0 & 1 & 2.10 & 0 \\ Document 3 & 2.10 & 2.10 & 1 & 1.41 & 0 & 1.41 & 1 & 0 & 2.10 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: An example of tf-idf. \begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Document 1** & **Document 2** & **Document 3** \\ \hline Document 1 & 1 & 0.28 & 0.46 \\ Document 2 & 0.28 & 1 & 0.25 \\ Document 3 & 0.46 & 0.25 & 1 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: An example of document similarity using \(\cos(\theta)\). In Equation (5), the expected rating (\(r_{u,i}\)) for user \(u\) for item \(i\) can be calculated with the average of the neighbors' rating scores for \(r_{v,i}\). Note that it can use various similarity measures, such as cosine similarity and the Pearson correlation. One requirement of using the KNN classifier is that the data sets must contain the score or rating information of the items for users. To this end, we allow users to rate items on the user page, as shown in Figure 2.  
The second algorithm for collaborative filtering is the latent factor model [63; 64]. The basic concept of latent factor collaborative filtering is to find a latent factor that represents users and items to fill empty slots in the rating matrix. The core principle of latent factor collaborative filtering is matrix factorization, which is also used in the Netflix Prize. The well-known methods for latent factor collaborative filtering are singular value decomposition (SVD) [65], stochastic gradient descent (SGD) [66; 67], and alternating least squares (ALS) [68; 69]. The downside of SVD is that it neither captures biases for users and items nor allows missing values. Note that SVD can be defined for complete matrices; thus, zeroing missing values is used instead of removing entire rows. The SGD method performs matrix diagonalization, like eigenvalue decomposition. In fact, the SGD method optimizes two matrices (user latent and item latent) simultaneously. Meanwhile, the ALS method fixes one of the two matrixes and optimizes the other matrix. Hence, the optimization problem can be converted to a convex type, which makes convergence faster than SGD. Thus, we use the ALS method for our collaborative filtering. The procedures for ALS are as follows:  
1. Initialize both the user latent and the item latent. 2. Optimize the user latent while fixing the item latent. 3. Optimize the item latent while fixing the user latent. 4. Iterate steps 2 and 3.