# Leveraging User Comments for Recommendation in E-Commerce
## 4 Proposed Approach
### Step 1--Developing Item and User Vectors  
As mentioned, it is usually difficult to discover similarity between items or users solely based on the sparse ratings provided in the user-item rating matrix. Extra sources have to be consulted for help. In this step, we apply Word2 Vec on user comments to discover semantic relationships between products. Each product is converted to an item vector. Then, the item vectors can be used for clustering products later. In addition, the users can be converted to user vectors, by which the clustering on users can be done. We address the data sparsity problem by finding the relationship between items from the user comments posted on the public domain. We use these user comments to train a Word2 Vec network. The word vectors obtained after training should reveal semantic relationships among items, so it is required that the inputs to the Word2 Vec network be items in the training patterns. We take the user review text of an item and insert the item identity into the text repeatedly. Suppose that the window size is \(2s+1\). The item identity is inserted in the middle of every \(2s\) words in the original text. Training patterns, each consisting of an input-output word pair \((x,y)\), are extracted from the windows. For each window, the central word is taken as input \(x\), and each of its context words is taken as output \(y\) to form training patterns. Assume that a window contains \(2s+1\) words, \(w\prime_{r+1}\cdots w\prime_{r+s}w\prime_{r+s+1}w\prime_{r+s+2}\cdots w\prime_ {r+2s+1}\), where \(w\prime_{r+s+1}\) is the central word and the other words are context words. Then, there are \(2s\) training patterns, \((w\prime_{r+s+1},w\prime_{r+1}),\ldots,\)\((w\prime_{r+s+1},w\prime_{r+s})\), \((w\prime_{r+s+1},w\prime_{r+s+2}),\ldots,\)\((w\prime_{r+s+1},w\prime_{r+2s+1})\), extracted from the window. Let the review text of an item, with its item identity being 0000013714, be:  
_I bought this for my husband who plays the piano \(He\) is having a wonderful time playing these old_  
_hymms The music is at times hard to read because we..._  
For \(s=3\), the user review text after insertion is shown below, ignoring punctuation marks:I bought this \(\mathbf{0000013714}\) for my husband who plays the \(\mathbf{0000013714}\) piano He is having a wonderful \(\mathbf{0000013714}\) time playing these old thymus The \(\mathbf{0000013714}\) music is at times hard to \(\mathbf{0000013714}\) read because we..._  
Note that the item identity \(0000013714\) appears in the middle of each non-overlapping window of seven words. For instance, the first window consists of the following words:  
I bought this \(\mathbf{0000013714}\) for my husband. Then, we extract training patterns from each window. Considering the first window above, six training patterns are extracted:  
\[(0000013714,\,\text{I}),\,(0000013714,\,\text{bought}),\,(0000013714,\,\text{ this}),\] \[(0000013714,\,\text{for}),\,(0000013714,\,\text{my}),\,(0000013714, \,\text{husband}).\]  
For the second window \"who plays the \(0000013714\) piano He is\", another six training patterns are extracted:  
\[(0000013714,\,\text{who}),\,(0000013714,\,\text{plays}),\,(0000013714,\,\text{ the}),\] \[(0000013714,\,\text{piano}),\,(0000013714,\,\text{He}),\,(0000013714, \,\text{is}).\]  
Note that the first words in the training patterns are the item identity. After extracting the training patterns from the collected user comments, the training patterns are fed into the Word2 Vec network [21; 22], as shown in Figure 1, for training. The neural network is trained as follows. Suppose \((w_{i},w_{k})\) is a training pattern involving two words, \(w_{i}\) and \(w_{k}\). Word \(w_{i}\) corresponds to node \(i\) in the input layer, and word \(w_{k}\) corresponds to node \(k\) in the output layer, with input weights \(\mathbf{v}_{i}^{1}=\left[v_{1i}^{1}\cdots v_{Hi}^{1}\right]^{T}\) and output weights \(\mathbf{v}_{k}^{2}=\left[v_{k1}^{2}\cdots v_{kH}^{2}\right]^{T}\).