## 3 Modeling the Time Effect on Music Recommendations
### Time-Aware Music Recommendation Method
#### 3.2.1 Modeling the Evolution of Preferences
Nevertheless, certain likenesses among users who play songs at similar times of day can be found. Moreover, in order to introduce listening habits in the recommender models, it is necessary to define a variable that represents this behavior. The average time of day for every user \(u_{i}\) can be a suitable factor, which is defined below. \[dTAvg_{i}=\frac{\sum_{j}\sum_{p}t_{i,j,p}}{NP_{i}} \tag{16}\]

where \(t_{i,j,p}\) is the time of day for the play \(p\) of the song \(s_{j}\) by the user \(u_{i}\) and \(NP_{i}\) is the total number of plays of the user \(u_{i}\). This allows us to use the contextual variable of the time of day as an additional attribute for computing the similarity between users, which may ultimately improve the recommendation reliability. Once this new similarity \(sim(u_{a},u_{i})\) between the active user \(u_{a}\) and the other users \(u_{i}\) is computed, Equation (3) can be used to predict the rating that the active user would give to a song \(s_{j}\). We use the cosine function to compute the user similarity by taking ratings and \(dTAvg\) as attributes. In general, for any number of attributes, if \(d\) is the number of dimensions corresponding to the considered attributes, \(X_{a}=\left(x_{a,1},\ x_{a,2}\ldots x_{a,d}\right)\) a vector containing the values of the attributes for the active user \(u_{a}\), and \(X_{i}=\left(x_{i,1},\ x_{i,2}\ldots x_{i,d}\right)\) a vector containing the values of the attributes for the user \(u_{i}\), then the cosine similarity between \(u_{a}\) and \(u_{i}\) is defined as follows:

\[cosSim\ (u_{a},u_{i}\ )=\frac{\sum_{z=1}^{d}x_{a,z}\ x_{iz}}{\sqrt{\sum_{z=1}^{d}x_{a,j}^{2}\ \sqrt{\sum_{z=1}^{d}x_{ij}^{2}}}} \tag{17}\]The procedure for computing the implicit ratings from decay play frequencies, as well as the time of day variable, is described by Algorithm 1. This algorithm provides all the variables necessary as an output to apply collaborative filtering methods according to our proposal. In the experimental study detailed in the following section, the procedure is applied to the context-free dataset, as well as to the subsets corresponding to different contextual intervals regarding the time of the day. ## 4 Experimental Study and Validation

An experimental study using data collected by [PERSON] ([[https://www.upf.edu/web/mtg/lastfm360k](https://www.upf.edu/web/mtg/lastfm360k)]([https://www.upf.edu/web/mtg/lastfm360k](https://www.upf.edu/web/mtg/lastfm360k))) from Last.fm was conducted to validate the proposed method. The dataset used in this study consists of more than 80,000 songs listened to by 50 users over a 2-year period, creating a collection of more than 420,000 timestamped plays. The validation metrics used in the study are described in Section 4.1 and the baseline methods are described in Section 4.2. The first part of the study, presented in Section 4.3, is dedicated to validating the method for obtaining the implicit ratings considering the evolution of user preferences. In this part, two types of experiments are reported. First, the proposed method was applied without taking into account any contextual information. Then subsequently, the context of the time of day was considered and the results were compared. The second part, included in Section 4.4, is dedicated to introducing a time variable related to the listening habits of users, in an attempt to characterize their behavior. This variable was incorporated into collaborative filtering as an additional attribute for improving the recommendations. The work in this part is carried out in the same manner as mentioned above, and the results obtained are also compared in this section. Given that it is assumed that user preferences change over time, the validation was performed by splitting the entire dataset into a training set containing the data corresponding to the first 15 months and a test set including data from the last 2 months. The implicit ratings were computed.