# Session-Based Recommendations for e-Commerce with Graph-Based Data Modeling
## 3 Recommendation Methods
### Hierarchical Sequence Probability Method--HSP  
The Hierarchical Sequence Probability approach is an item-item collaborative filtering recommendation method where the list of recommended items arises from the items' sequential appearances during session navigation. We consider \(t\) the current time instance and \(item_{t}\) the item that appears to a user in time \(t\) during the session \(s\). To recommend the next item at time instance \(t\) during \(s\), we introduce the concept of _\"item sequence probability\"_. This term derives from the visiting frequency of the item by users during the sessions on the e-shop platform. All the items have the _single item probability_, _pair sequence probability_ and _triplet sequence probability_ as follows:  
* \(P_{0}(A)\)--_single item probability_, or _cold-start probability_ is the number of appearances of item \(A\) in all sessions divided by the total number of appearances of all items: \[P_{0}(A)=\frac{\text{number of appearances of }A}{\text{number of appearances of all items}}\] (1) The _single item probability_ is derived from the relationship _ItemInSession_ of the graph;
* \(P_{1}(A,B)\)--_pair sequence probability_, the number of appearances of the item pair \((A,B)\) in successive instances in all sessions, i.e., \(item_{t-1}=A\), \(item_{t}=B\) divided by the number of appearances of item \(A\) \[P_{1}(A,B) =\frac{\text{number of appearances of consecutive pair }A,B}{\text{number of appearances of item }A}\] \[=P(item_{t}=B|item_{t-1}=A)\] (2) This function is created for all pairs of items using the _Next_ relationship;  
Figure 1: Representation of items (light blue nodes), sessions (pink nodes) and the relationships _ItemInSession_ (blue edges), _Next_ (red edges), _InNameSession_ (green edges). (**a**) The HSP Graph Model, (**b**) The RIC Graph Model. * \(P_{2}(A,B,C)\)_--triplet sequence probability_, the number of appearances of the item triplet (\(A\),\(B\),\(C\)) in successive steps in all sessions, i.e., \(item_{t-2}=A\), \(item_{t-1}=B\), \(item_{t}=C\) divided by the number of consecutive pairs \(A,B\) \[P_{2}(A,B,C) =\frac{\text{number of appearances of consecutive triplet }A,B,C}{\text{number of appearances of consecutive pair }A,B}\] \[=P(item_{t}=C|item_{t-2}=A,item_{t-1}=B)\] (3) This function is created for all triplets of items connected by the _Next_ relationship in a chain \(A\to B\to C\). The probabilities \(P_{1}\) and \(P_{2}\) are closely related to the confidences of the association rules \((A\Rightarrow B)\) and \((A,B\Rightarrow C)\) under the additional constraint that \(A\), \(B\), and \(C\) must be consecutive items [32]. The Algorithm  
The Hierarchical Sequence Probability (HSP) recommendation method is based on item sequences observed through the users' actions in the sessions. To recommend an item, we look at its probability of appearance as well as the history of sequences of length 1 or 2 in which this item has participated during the training sessions. In the absence of a history (i.e., in the first step of a session), items are recommended based on their probability. Thus, the recommendation of the next item is based on the following cases:  
1. The item recommendation list at step \(t=1\) (cold start case) contains the most frequently visited items ordered according to decreasing single item probability value \(P_{0}\). We call this the _\"0-history\"_ prediction since no previous session steps are required;
2. For step \(t=2\), the item recommendation list is compiled using navigation history of length 1. In particular, the recommendation list contains the items \(B\) that have a nonzero pair-sequence-probability value \(P_{1}(item_{1},B)\) with \(item_{1}\) appearing at step \(t=1\). The list is ordered by decreasing the \(P_{1}\) value. Since \(item_{1}\) may be unpopular, it is likely that there are very few items \(B\) with the non-zero \(P_{1}(item_{1},B)\) value.