## 4 Methodology and Methods
### Pattern-Based Model Training
#### 4.1.1 Contextualised Data Partitioning and Models  
The rebalancing framework proposes different contextualised data partitioning strategies to extract meaningful insights at different time partitioning groups and to let the framework adapt according to different habits of users and contexts. Each partition includes the data used to train a tailored model for a specific temporal context. The proposed contextualised partition-based approach allows to model more precisely the characteristics  
Figure 1: Framework structure at training time.  
of each context and hence plan more effective rebalancing strategies, as shown in the experimental section.  
The data partitioning component of our framework receives an input dataset \(\mathcal{D}_{\mathcal{CR}}\) with the timestamp \(t\) information associated to each record and divides the dataset into N non-overlapping partitions \(\mathcal{P}_{i}\), based on the value of \(t\), such that  
\[\bigcup_{i}\mathcal{P}_{i}=\mathcal{D}\]  
It is useful to notice that, given a contextualised temporal partition strategy, a specific timestamp \(t\) belongs to only one single partition \(\mathcal{P}_{i}\).  
Different partitioning strategies lead to different frequent patterns and different contextualised models. Using different time partitioning strategies, our framework is able to collect meaningful information about users' usage patterns in different moments of the day, week, and month and allows us to understand how the usage behaviour changes in different temporal contexts. Considering different partitioning strategies, we can understand if finer or coarser temporal contexts should be used in the bike sharing domain. Finer partitioning strategies should provide more tailored and precise models but overfitting could occur with a higher probability. Conversely, coarser partitioning strategies avoid overfitting but could be too general and do not perform well for all contexts.  
We proposed and evaluated the following temporal contextualised data partitioning strategies:  
**Per month partitioning.** Data belonging to the same month are kept together and monthly models are trained.  
**Per day of the week partitioning.** Data belonging to the same day of the week are included in the same partition and analysed together. By doing this, the mined patterns are able to get insights about critical stations within the same day of the week. A total number of seven groups \(\mathcal{P}_{1},...,\mathcal{P}_{7}\) are generated.  
**Per time slot partitioning.** Three timeslots are defined: 5:00-13:00, 13:00-21:00, and 21:00-05:00. One partition for each timeslot is defined. Association rules in this case gather insights about frequent critical stations in certain time slots of the day, independently of the day of the week.  
**Per day of the week and time slot partitioning.** This approach combines together the latter two partitioning approaches, defining one partition for each combination (timeslot, day of the week).  
We consider the time information the most relevant context in this domain and for this reason we decided to partition data based on the timestamp dimension. However, the proposed methodology can be easily adapted also to other contextual dimensions.