# Improved DeepFM Recommendation Algorithm Incorporating Deep Feature Extraction
## 2 Improved DeepFM Recommendation Algorithm Incorporating Deep Feature Extraction
### Representation of User Characteristics Incorporating Temporal Factors  
A basic user representation can be obtained based on the user's historical interaction items, but the sequence of historical items that the user has interacted with is temporal in nature. In general, items that the user has recently interacted with have more influence on the user's choice than items that the user has previously interacted with. The GRU model can be used to process and predict sequential data. It will influence the subsequent output based on the previous memory information, and there is no gradient disappearance. Therefore this paper uses the GRU model to train to get the vector representation of the user. The model is shown in Figure 4.  
The overall representation of user characteristics can be obtained based on the historical items \(v\) that users have interacted with, defined as \(v=\{v_{u}^{1},v_{u}^{2},\cdots v_{u}^{n}\}\). Human behavior generally varies with weekly and monthly cycles; thus, a historical sequence of user interactions is divided according to weeks and months, then input into the GRU model separately, as shown in Equation (5)  
\[v^{T}=v_{1}^{T}+v_{2}^{T}+\cdots+v_{k}^{T} \tag{5}\]  
where \(v_{j}^{T}\) denotes the set of item sequences that have interacted in the \(j\)th cycle with \(T\) as the period.  
The GRU model obtains the state of the gating \(r\) and the gating \(z\) based on the state \(h_{t-1}\) passed down from the previous node, and the input \(x_{t}\) from the current node. The gating \(r\) is the control reset gating. The gating \(z\) is the control update gating. The equations are as follows:  
\[r =\sigma(W_{r}\cdot[h_{t-1},x_{t}]) \tag{6}\] \[z =\sigma(W_{2}\cdot[h_{t-1},x_{t}]) \tag{7}\]  
where \(\sigma\) is the sigmoid function that controls the data in the range of (0, 1) and \(W\) is the parameter where the closer the gating \(z\) is to 1 indicates the more data to stay.  
After getting the gating signal, the reset gate is used to get the reset data \(h_{t-1}^{\prime}=h_{t-1}\odot r\), \(\odot\) is the Hadamard product, Then \(h_{t-1}^{\prime}\) and the input \(x_{t}\) are spliced, and deflate the data to the (\(-1\), 1) by the function \(\tan\ln\) to get \(h^{\prime}\).  
\[h^{\prime}=\tan\hhhhh^{\prime}\cdot\left[h_{t-1}^{\prime},x_{t}\right]) \tag{8}\]  
where \(W_{h^{\prime}}\) is the parameter to be learned. The final update of memory requires both forgetting and remembering steps. The formula is shown in Equation (9).  
\[h_{t}=(1-z)\odot h_{t-1}+z\odot h^{\prime} \tag{9}\]  
This step excludes some dimensions of the previous step and adds some of the current stage input. \((1-z)\odot h_{t-1}\) means removing some unimportant information in the dimension \(h_{t-1}\), \(z\odot h^{\prime}\) means selectively retaining the information of the current node. The final obtained \(h_{t}\) is the user vector representation.  
The user representation with a weekly cycle is \(u_{T1}\), the user feature representation with a monthly cycle is \(u_{T2}\), and finally the two are stitched to obtain the user feature representation \(u\).  
Figure 4: GRU model structure.