# User Mobility Modeling in Crowdsourcing Application to Prevent Inference Attacks
## 4 Proposed Approach
### POI Extraction
#### 4.5.2 Building Our Bayesian Network
```
1:Input:\(G\leftarrow\) user's mobility graph
2:Input:\(k\leftarrow\) number of categories (e.g., 3 for low, medium, high)
3:Initialize dictionaries \(F\) and \(S\) to store frequency and stay duration for each vertex
4:for each \(v\in G.\mathcal{V}\)do
5:for each \(e\in G.\mathcal{E}\) where \(e\) is connected to \(v\) as the source node do\(\triangleright\) For each edge connected to the vertex
6: Retrieve \(\mathcal{W}\) for edge \(e\)
7:for each \(\langle ts,td,fs,st,dt\rangle\in\mathcal{W}\)do
8:\(F\gets F\cup fs\)\(\triangleright\) Add visit frequency
9:\(S\gets S\cup st\)\(\triangleright\) Add stay duration
10:endfor
11:endfor
12:endfor
13:\(Q_{f}\leftarrow\) computeQuantiles(F, k)\(\triangleright\) Compute quantiles for frequency
14:\(Q_{s}\leftarrow\) computeQuantiles(S, k)\(\triangleright\) Compute quantiles for stay duration
15:for each \(v\in G.\mathcal{V}\)do
16:for each \(e\in G.\mathcal{E}\) where \(e\) is connected to \(v\) as the source node do
17: Retrieve \(\mathcal{W}\) for edge \(e\)
18:for each \(\langle ts,td,fs,st,dt\rangle\in\mathcal{W}\)do
19:\(fs\leftarrow\) getQuantileCategory\(\langle fs,Q_{f}\rangle\)\(\triangleright\) Determine the position of the frequency fs as a function of its position relative to the quartiles Qf
20:\(st\leftarrow\) getQuantileCategory\(\langle St,Q_{s}\rangle\)\(\triangleright\) Determine the position of the stay duration st as a function of its position relative to the quartiles Qs
21: Update \(\langle ts,td,fs,st,dt\rangle\) with \(fs\) and \(st\)
22:endfor
23:endfor
24:endfor
```  
**Algorithm 3** Categorization of locations according to visit frequencies and stay durations in \(G\). These variables are interlinked within the network, where the Day Index and Time Index influence the Category of Place, which in turn affects both the Visit Frequency and the Stay Duration. This causality is represented in the network's directed acyclic graph, which illustrates the directional influence of one variable over another, thereby structuring clear dynamics and dependencies within the model. After defining this network structure, the next critical step involves configuring the network using historical data, which includes collecting comprehensive datasets and learning the CPTs for each node, except for the root nodes. These CPTs quantify how the states of parent nodes influence the states of their child nodes. The decision-making process within the network is facilitated by special nodes such as the Utility Node, which calculates the utility value based on the outputs from the _Visit Frequency_ and _Stay Duration_. This utility reflects the desirability or value derived from visiting a specific category of place at certain times and frequencies, effectively guiding the decision on whether a location qualifies as a POI or not. The decision node (POI) evaluates whether the calculated utility exceeds a predefined threshold, indicating significant importance or interest, to decide about considering a location as a point of interest. The joint probability distribution of the network is given by the following:  
\[\mathbb{P}(D,T,C,V,S)=\mathbb{P}(D)\cdot\mathbb{P}(T\mid D)\cdot\mathbb{P}(C \mid D,T)\cdot\mathbb{P}(V\mid D,T,C)\cdot\mathbb{P}(S\mid D,T,C,V) \tag{1}\]  
where \(\mathbb{P}(D)\) is the probability of the day; \(\mathbb{P}(T\mid D)\) is the conditional probability of the time given the day; \(\mathbb{P}(C\mid D,T)\) is the conditional probability of the category of place given the day and time; \(\mathbb{P}(V\mid D,T,C)\) is the conditional probability of the visit frequency given the day, time, and category of place; and \(\mathbb{P}(S\mid D,T,C,V)\) is the conditional probability of the stay duration given the day, time, category of place, and visit frequency.