Movatterモバイル変換


[0]ホーム

URL:


CN116680486B - User interest prediction method based on space-time attention mechanism - Google Patents

User interest prediction method based on space-time attention mechanism
Download PDF

Info

Publication number
CN116680486B
CN116680486BCN202310635734.6ACN202310635734ACN116680486BCN 116680486 BCN116680486 BCN 116680486BCN 202310635734 ACN202310635734 ACN 202310635734ACN 116680486 BCN116680486 BCN 116680486B
Authority
CN
China
Prior art keywords
user
space
time
information
spatiotemporal
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310635734.6A
Other languages
Chinese (zh)
Other versions
CN116680486A (en
Inventor
赵雪青
张慧婷
刘宁
师昕
刘浩
杨晗
吴祯鴻
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Xinban Network Technology Co ltd
Original Assignee
Xian Polytechnic University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xian Polytechnic UniversityfiledCriticalXian Polytechnic University
Priority to CN202310635734.6ApriorityCriticalpatent/CN116680486B/en
Publication of CN116680486ApublicationCriticalpatent/CN116680486A/en
Application grantedgrantedCritical
Publication of CN116680486BpublicationCriticalpatent/CN116680486B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Classifications

Landscapes

Abstract

Translated fromChinese

本发明公开的基于时空注意力机制的用户兴趣预测方法,包括获取用户信息和时空信息并进行预处理;获取用户访问记录之间的时间间隔和空间间隔,进而分别得到用户访问记录的时间关系和空间关系矩阵;采用时空注意力机制对时间关系和空间关系矩阵进行嵌入表示,得到融合时空特征的用户轨迹表示序列;通过softmax函数判断用户轨迹表示序列,计算权重得分来对用户兴趣进行预测。本发明的基于时空注意力机制的用户兴趣预测方法,通过双层时空注意力考虑时空间隔差异对用户兴趣所造成的影响,能够有效表征基于用户时空行为的真实兴趣偏好,从而有效提升了用户兴趣预测的准确度。

The user interest prediction method based on the spatiotemporal attention mechanism disclosed in the present invention includes obtaining user information and spatiotemporal information and performing preprocessing; obtaining the time interval and space interval between user access records, and then obtaining the time relationship and space relationship matrix of the user access records respectively; using the spatiotemporal attention mechanism to embed the time relationship and space relationship matrix to obtain a user trajectory representation sequence integrating spatiotemporal features; judging the user trajectory representation sequence by a softmax function, and calculating the weight score to predict the user's interest. The user interest prediction method based on the spatiotemporal attention mechanism of the present invention considers the impact of the difference in spatiotemporal intervals on user interests through double-layer spatiotemporal attention, and can effectively characterize the real interest preference based on the user's spatiotemporal behavior, thereby effectively improving the accuracy of user interest prediction.

Description

Translated fromChinese
基于时空注意力机制的用户兴趣预测方法User interest prediction method based on spatiotemporal attention mechanism

技术领域Technical Field

本发明属于用户定制个性化推荐方法技术领域,具体涉及一种基于时空注意力机制的用户兴趣预测方法。The present invention belongs to the technical field of user customized personalized recommendation methods, and specifically relates to a user interest prediction method based on a spatiotemporal attention mechanism.

背景技术Background technique

目前,越来越多的互联网场景开始使用推荐算法为用户定制个性化推荐界面,而推荐算法的准确率与用户对该应用的依赖度明显成正比关系,因此只有充分提高应用的推荐算法性能才能有效提高该应用的使用率,这样一方面有利于用户检索匹配自身需求的信息,另一方面有利于“商品”的有效推广。传统的推荐算法往往只单独关注了用户的长期或者短期兴趣,即根据用户的属性以及长期以来关注的更多的信息进行推荐,或是仅根据用户近几次会话进行即时推荐。而在实际应用中,用户的兴趣并不是固定不变的,而是会随着时间的推移动态变化,因此基于时间的序列推荐被提出,该类推荐致力于挖掘用户的动态兴趣,以实现对用户兴趣的更精准预测。早期解决序列推荐问题的方法是使用马尔可夫链(Markov Chain,MC)等。后来,循环神经网络(Recurrent Neural Network,RNN)、卷积神经网络(Convolutiona l Neural Network,CNN)等被成功地应用于序列推荐。再到后面注意力机制(Attention Mechanism,AM)在深度学习模型上的应用取得了巨大成果,也大大改善了序列推荐的预测能力。At present, more and more Internet scenarios are beginning to use recommendation algorithms to customize personalized recommendation interfaces for users. The accuracy of the recommendation algorithm is obviously proportional to the user's dependence on the application. Therefore, only by fully improving the performance of the application's recommendation algorithm can the usage rate of the application be effectively improved. This is beneficial to users in retrieving information that matches their needs on the one hand, and on the other hand, it is beneficial to the effective promotion of "goods". Traditional recommendation algorithms often only focus on the long-term or short-term interests of users, that is, they make recommendations based on the user's attributes and more information that they have been paying attention to for a long time, or they only make instant recommendations based on the user's recent sessions. In actual applications, the user's interests are not fixed, but will change dynamically over time. Therefore, time-based sequence recommendations are proposed. This type of recommendation is committed to exploring the user's dynamic interests in order to achieve more accurate predictions of user interests. The early method to solve the sequence recommendation problem was to use Markov Chain (MC) and so on. Later, Recurrent Neural Network (RNN), Convolutional Neural Network (CNN) and so on were successfully applied to sequence recommendation. Later, the application of Attention Mechanism (AM) in deep learning models has achieved great results and greatly improved the prediction ability of sequence recommendation.

目前,针对用户时空行为的兴趣预测问题的相关研究主要集中于利用显式的时间信息和空间地理位置信息挖掘并分析用户时空行为属性背后潜藏的用户兴趣偏好。然而,在实际情况中,用户的行为具有一定的规律性、时效性以及空间就近性,现有的方法未充分考虑时空间隔差异对用户兴趣预测的影响,导致用户兴趣预测的准确率较低,而挖掘用户相邻两次访问行为之间的时间间隔和空间间隔,明确地表示每两次行为之间的时空差距的影响,能够有效表征基于用户时空行为的真实兴趣偏好。At present, the research on the problem of predicting user interest based on spatiotemporal behavior mainly focuses on using explicit time information and spatial location information to mine and analyze the user interest preferences hidden behind the spatiotemporal behavior attributes of users. However, in reality, user behavior has certain regularity, timeliness, and spatial proximity. Existing methods do not fully consider the impact of spatiotemporal interval differences on user interest prediction, resulting in low accuracy of user interest prediction. Mining the time interval and spatial interval between two adjacent user visit behaviors and explicitly expressing the impact of the spatiotemporal gap between each two behaviors can effectively characterize the real interest preferences based on user spatiotemporal behavior.

发明内容Summary of the invention

本发明的目的在于提供一种基于时空注意力机制的用户兴趣预测方法,解决了现有方法预测准确度低的问题。The purpose of the present invention is to provide a user interest prediction method based on spatiotemporal attention mechanism, which solves the problem of low prediction accuracy of existing methods.

本发明所采用的技术方案是:基于时空注意力机制的用户兴趣预测方法,包括以下步骤:The technical solution adopted by the present invention is: a user interest prediction method based on spatiotemporal attention mechanism, comprising the following steps:

步骤1、获取用户信息和时空信息并进行预处理;Step 1: Obtain user information and spatiotemporal information and perform preprocessing;

步骤2、基于步骤1所得用户信息和时空信息获取用户访问记录之间的时间间隔和空间间隔,进而分别得到用户访问记录的时间关系和空间关系矩阵;Step 2: Based on the user information and spatiotemporal information obtained in step 1, the time interval and spatial interval between user access records are obtained, and then the time relationship and spatial relationship matrices of the user access records are obtained respectively;

步骤3、采用时空注意力机制对步骤2所得时间关系和空间关系矩阵进行嵌入表示,得到融合时空特征的用户轨迹表示序列;Step 3: Use the spatiotemporal attention mechanism to embed the temporal relationship and spatial relationship matrices obtained in step 2 to obtain a user trajectory representation sequence that integrates spatiotemporal features.

步骤4、通过softmax函数判断步骤3所得用户轨迹表示序列,计算权重得分来对用户兴趣进行预测。Step 4: Use the softmax function to determine the user trajectory representation sequence obtained in step 3, and calculate the weight score to predict user interests.

本发明的特点还在于,The present invention is also characterized in that:

步骤1中的预处理方式为将用户信息和时空信息转化为矩阵形式。The preprocessing method in step 1 is to convert the user information and spatiotemporal information into a matrix form.

步骤2具体为:将步骤1预处理所得矩阵进行建模,设置成两个关系矩阵WT和WL,分别存储用户访问记录的时间信息和空间信息,将时间间隔和空间地理距离建模为两个访问地点之间明确的时空关系,用户相邻两次访问记录之间的时间间隔由其历史访问记录与临近访问记录的时间差得到,表示为|ti-tj|;用户访问记录的空间间隔/>由用户历史访问记录与相邻的下一个访问记录的距离相减得到,空间间隔/>利用Haversine距离函数进行计算,如公式(3)所示:Step 2 is as follows: the matrix obtained by preprocessing in step 1 is modeled into two relationship matrices WT and WL , which store the time information and spatial information of user access records respectively, and the time interval and spatial geographic distance are modeled as the clear time-space relationship between two access locations, and the time interval between two adjacent user access records is The time difference between the historical access record and the recent access record is obtained, expressed as |ti -tj |; the spatial interval of the user's access record/> The spatial interval is obtained by subtracting the distance between the user's historical access record and the next adjacent access record. The Haversine distance function is used for calculation, as shown in formula (3):

式(3)中,r为地球的半径,la和lb分别为经度差和纬度差,分别如公式(1)和公式(2)所示:In formula (3), r is the radius of the earth, la and lb are the longitude difference and latitude difference, respectively, as shown in formula (1) and formula (2):

la=latj-lati (1)la=latj -lati (1)

lb=lonj-loni (2)lb=lonj -loni (2)

式(1)和式(2)中,lati,loni,latj与lonj分别为第i次和第j次访问记录的经纬度值;In formula (1) and formula (2), lati , loni , latj and lonj are the longitude and latitude values of the i-th and j-th access records respectively;

则用户访问记录的时间关系矩阵WT和用户访问记录的空间关系矩阵WL,如公式(4)所示:Then the time relationship matrixWT of user access records and the spatial relationship matrixWL of user access records are as shown in formula (4):

步骤3具体为:在计算时空间隔真实差值的基础上,将时间间隔与空间间隔/>分别与以一小时和一千米为基本单元的单位嵌入向量et和el相乘得到时空信息的嵌入表示E(WT)和E(WL),如公式(5)所示:Step 3 is as follows: on the basis of calculating the true difference of the time-space interval, With space interval /> The embedded representations of spatiotemporal information E(WT ) and E(WL ) are obtained by multiplying them with the unit embedding vectorset andel with one hour and one kilometer as the basic units, respectively, as shown in formula (5):

式(5)中,分别如公式(6)和公式(7)所示:In formula (5), As shown in formula (6) and formula (7) respectively:

给定用户非零填充的信息嵌入表示E(ui),通过线性转换分别获得查询矩阵Wq、键矩阵Wk和值矩阵Wv,进而将Wq、Wk、Wv输入到一个注意力层,采用缩放点积注意力评分函数计算注意力分布权重,得到一个融合时空特征的用户轨迹表示序列,如公式(8)所示:Given the user’s non-zero filled information embedding representation E(ui ), the query matrixWq , key matrixWk and value matrixWv are obtained through linear transformation respectively. ThenWq ,Wk andWv are input into an attention layer, and the attention distribution weight is calculated using the scaled dot product attention scoring function to obtain a user trajectory representation sequence that integrates spatiotemporal features, as shown in formula (8):

A(ui)=Att(E(ui)Wq,E(ui)Wk,E(ui)Wv,E(WiT),E(WiL)) (8)A(ui )=Att(E(ui )Wq ,E(ui )Wk ,E(ui )Wv ,E(WiT ),E(WiL )) (8)

式(8)中,In formula (8),

Att(q,k,v,WiT,WiL)=softmax(s(q,WiT,WiL))v (9)Att(q,k,v,WiT,WiL )=softmax(s(q,WiT,WiL)) v (9)

式(9)中,Att表示缩放点积注意力,q表示查询,k表示键,v表示值,s表示缩放点积注意力分布函数,表示尺度因子。In formula (9), Att represents the scaled dot product attention, q represents the query, k represents the key, v represents the value, and s represents the scaled dot product attention distribution function. Represents the scale factor.

步骤4具体为:基于用户历史访问记录的相关性更新步骤3所得用户轨迹表示序列A(ui),根据给定的访问地点集合L的嵌入表示EL={El1,El2,...,ElL},通过时空注意力机制自顶向下的选择机制来过滤无用的信息,为不同的访问地点分配不同的权重,从而挑选描述用户兴趣的代表性访问地点信息;具体为:Step 4 is as follows: based on the correlation of the user's historical visit records, the user trajectory representation sequence A(ui ) obtained in step 3 is updated. According to the embedding representationEL = {El1 ,El2 ,...,ElL } of the given visit location set L, useless information is filtered out through the top-down selection mechanism of the spatiotemporal attention mechanism, and different weights are assigned to different visit locations, so as to select representative visit location information that describes the user's interests; specifically:

首先根据公式(11)计算注意力分数a(A(ui),EL),然后根据公式(12)使用softmax函数进行归一化计算注意力权重得分α(ui),计算公式如下:First, the attention score a(A(ui ),EL ) is calculated according to formula (11), and then the attention weight score α(ui ) is calculated by normalizing it using the softmax function according to formula (12). The calculation formula is as follows:

α(ui)=soft max(a(A(ui),EL)) (12)α(ui )=soft max(a(A(ui ),EL )) (12)

最后根据权重得分α(ui)对用户兴趣进行预测,权值得分α(ui)越大,就证明用户越感兴趣。Finally, the user's interest is predicted based on the weight score α(ui ). The larger the weight score α(ui ), the more interested the user is.

本发明的有益效果是:本发明的基于时空注意力机制的用户兴趣预测方法,通过双层时空注意力考虑时空间隔差异对用户兴趣所造成的影响,能够有效表征基于用户时空行为的真实兴趣偏好,从而有效提升了用户兴趣预测的准确度。The beneficial effect of the present invention is that the user interest prediction method based on the spatiotemporal attention mechanism of the present invention considers the impact of spatiotemporal interval differences on user interests through double-layer spatiotemporal attention, and can effectively characterize the real interest preferences based on the user's spatiotemporal behavior, thereby effectively improving the accuracy of user interest prediction.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1是本发明的基于时空注意力机制的用户兴趣预测方法的结构示意图。FIG1 is a schematic diagram of the structure of a user interest prediction method based on a spatiotemporal attention mechanism of the present invention.

具体实施方式Detailed ways

下面结合附图以及具体实施方式对本发明进行详细说明,本发明中所有获取用户信息、时空信息和轨迹数据的动作都是在遵照所在地国家相应的数据保护法规政策的前提下,并获得用户相应授权的情况进行的。The present invention is described in detail below in conjunction with the accompanying drawings and specific implementation methods. In the present invention, all actions of obtaining user information, spatiotemporal information and trajectory data are performed in accordance with the relevant data protection laws and policies of the country where the user is located and with the corresponding authorization of the user.

实施例1Example 1

本发明提供了一种基于时空注意力机制的用户兴趣预测方法,使用时空注意力机制来实现对用户兴趣的预测。本发明的基于时空注意力机制的用户兴趣预测方法的结构示意图如图1所示主要由输入层、嵌入层、时空注意力层和全连接层组成。输入层来实现对用户信息,时间信息和空间信息进行输入,将所收集到的信息转成矩阵;嵌入层将用户信息,时空间隔信息进行处理嵌入到密集的特征向量中,分别生成用户访问记录的时间关系和空间关系矩阵;时空注意力层主要用来处理时空间隔信息特征。最后通过全连接层实现用户兴趣预测。具体按照以下步骤实施:The present invention provides a user interest prediction method based on a spatiotemporal attention mechanism, which uses the spatiotemporal attention mechanism to predict user interests. The structural schematic diagram of the user interest prediction method based on the spatiotemporal attention mechanism of the present invention is shown in Figure 1, and is mainly composed of an input layer, an embedding layer, a spatiotemporal attention layer, and a fully connected layer. The input layer is used to input user information, time information, and spatial information, and convert the collected information into a matrix; the embedding layer processes the user information and spatiotemporal interval information and embeds them into a dense feature vector, and generates the time relationship and spatial relationship matrices of the user access records respectively; the spatiotemporal attention layer is mainly used to process the spatiotemporal interval information features. Finally, user interest prediction is achieved through the fully connected layer. It is implemented specifically according to the following steps:

步骤1、对获取到的用户信息和时空信息进行预处理。具体为:通过输入层对输入的用户信息和时空信息来进行预处理,将用户信息和时空信息转化为矩阵的形式,方便以后在嵌入层进行处理。Step 1: Preprocess the acquired user information and spatiotemporal information. Specifically, the input user information and spatiotemporal information are preprocessed through the input layer, and the user information and spatiotemporal information are converted into a matrix form to facilitate subsequent processing in the embedding layer.

步骤2、通过用户信息和时空信息获取用户访问记录之间的时间间隔和空间间隔,进而得到用户访问记录的时空关系矩阵。具体按照以下步骤实施:Step 2: Obtain the time interval and space interval between user access records through user information and spatiotemporal information, and then obtain the spatiotemporal relationship matrix of user access records. This is specifically implemented in the following steps:

在本发明的基于时空注意力机制的用户兴趣预测方法的结构示意图的第二层,也就是嵌入层,将用户信息、时空信息嵌入到特征矩阵中,其中:时空间隔嵌入通过设置2个关系矩阵WT和WL对用户的时间信息和空间信息进行建模,用于捕获用户访问记录之间的时间间隔和空间间隔对用户兴趣的影响,在训练时,将时间间隔和空间地理距离建模为两个访问地点之间明确的时空关系,用户相邻两次访问记录之间的时间间隔由其历史访问记录与临近访问记录的时间差得到,表示为|ti-tj|,用户访问记录的空间间隔/>由用户历史访问记录与相邻的下一个访问记录的距离相减得到,空间间隔/>利用Haversine距离函数进行计算,其公式如下所示。In the second layer of the structural diagram of the user interest prediction method based on the spatiotemporal attention mechanism of the present invention, that is, the embedding layer, the user information and spatiotemporal information are embedded into the feature matrix, wherein: the spatiotemporal interval embedding models the user's time information and spatial information by setting two relationship matricesWT andWL to capture the influence of the time interval and spatial interval between the user's visit records on the user's interest. During training, the time interval and spatial geographic distance are modeled as a clear spatiotemporal relationship between two visit locations, and the time interval between two adjacent visit records of the user is The time difference between the historical access record and the recent access record is obtained, expressed as |ti -tj |, and the spatial interval of the user's access record/> The spatial interval is obtained by subtracting the distance between the user's historical access record and the next adjacent access record. The Haversine distance function is used for calculation, and the formula is as follows.

la=latj-lati (1)la=latj -lati (1)

lb=lonj-loni (2)lb=lonj -loni (2)

其中,lati,loni,latj与lonj分别为第i次和第j次访问记录的经纬度值,la和lb分别为经度差和纬度差,r为地球的半径,为空间间隔差值。Where, lati , loni , latj and lonj are the longitude and latitude values of the i-th and j-th access records respectively, la and lb are the longitude difference and latitude difference respectively, r is the radius of the earth, is the spatial interval difference.

则用户访问记录的时间关系矩阵WT和用户访问记录的空间关系矩阵WL,如公式(4)所示:Then the time relationship matrixWT of user access records and the spatial relationship matrixWL of user access records are as shown in formula (4):

步骤3、采用时空注意力机制来对时间关系和空间关系矩阵进行嵌入表示,得到融合时空特征的用户轨迹表示序列。具体实施步骤为:Step 3: Use the spatiotemporal attention mechanism to embed the temporal relationship and spatial relationship matrices to obtain a user trajectory representation sequence that integrates spatiotemporal features. The specific implementation steps are:

在计算时空间隔真实差值的基础上,将时间间隔与空间间隔/>分别与以一小时和一千米为基本单元的单位嵌入向量et和el相乘得到时空信息的嵌入表示E(WT)和E(WL),如公式(5)所示:Based on the calculation of the true difference of the time-space interval, the time interval With space interval /> The embedded representations of spatiotemporal information E(WT ) and E(WL ) are obtained by multiplying them with the unit embedding vectorset andel with one hour and one kilometer as the basic units, respectively, as shown in formula (5):

式(5)中,分别如公式(6)和公式(7)所示:In formula (5), As shown in formula (6) and formula (7) respectively:

给定用户非零填充的信息嵌入表示E(ui),通过线性转换分别获得查询矩阵Wq、键矩阵Wk和值矩阵Wv,进而将Wq、Wk、Wv输入到一个注意力层,采用缩放点积注意力评分函数计算注意力分布权重,得到一个融合时空特征的用户轨迹表示序列,如公式(8)所示:Given the user’s non-zero filled information embedding representation E(ui ), the query matrixWq , key matrixWk and value matrixWv are obtained through linear transformation respectively. ThenWq ,Wk andWv are input into an attention layer, and the attention distribution weight is calculated using the scaled dot product attention scoring function to obtain a user trajectory representation sequence that integrates spatiotemporal features, as shown in formula (8):

A(ui)=Att(E(ui)Wq,E(ui)Wk,E(ui)Wv,E(WiT),E(WiL)) (8)A(ui )=Att(E(ui )Wq ,E(ui )Wk ,E(ui )Wv ,E(WiT ),E(WiL )) (8)

式(8)中,In formula (8),

Att(q,k,v,WiT,WiL)=softmax(s(q,WiT,WiL))v (9)Att(q,k,v,WiT,WiL )=softmax(s(q,WiT,WiL)) v (9)

式(9)中,Att表示缩放点积注意力,q表示查询,k表示键,v表示值,s表示缩放点积注意力分布函数,直观地说,注意力层计算所有值的加权和,尺度因子是为了避免内积的值过大,特别是当维数较高时。In formula (9), Att represents the scaled dot product attention, q represents the query, k represents the key, v represents the value, and s represents the scaled dot product attention distribution function. Intuitively, the attention layer calculates the weighted sum of all values, and the scale factor This is to avoid the inner product value being too large, especially when the dimension is high.

在训练过程中,还需要考虑预测的因果关系,在预测第t+1项时,模型应该只考虑前t项。然而,时间感知自注意层的第t个输出包含了所有的输入信息,这使得模型具有不确定性。因此,通过阻止qi和kj(j>i)之间的所有联系来修改注意力。During training, the causal relationship of predictions also needs to be considered. When predicting the t+1th item, the model should only consider the first t items. However, the tth output of the time-aware self-attention layer contains all the input information, which makes the model uncertain. Therefore, the attention is modified by blocking all connections between qi and kj (j>i).

步骤4、通过全连接层来实现用户兴趣预测。具体步骤为:Step 4: Use the fully connected layer to predict user interests. The specific steps are:

在通过本发明的基于时空注意力机制的用户兴趣预测方法中的时空注意力层提取时空间隔特征之后,就可以采用softmax层(全连接层)来实现对用户兴趣的预测。在融合时空间隔考虑用户历史访问记录内部时空相关性更新轨迹表示A(ui)的基础上,根据给定的访问地点集合L的嵌入表示EL={El1,El2,...,ElL},通过时空注意力机制自顶向下的选择机制来过滤无用的信息,为不同的访问地点分配不同的权重,从而挑选可以描述用户兴趣的代表性访问地点信息。After extracting the spatiotemporal interval features through the spatiotemporal attention layer in the user interest prediction method based on the spatiotemporal attention mechanism of the present invention, the softmax layer (fully connected layer) can be used to realize the prediction of user interests. On the basis of updating the trajectory representation A(ui ) by integrating the spatiotemporal interval and considering the internal spatiotemporal correlation of the user's historical visit records, according to the embedded representation EL ={El1 ,El2 ,...,ElL } of the given visit location set L, the top-down selection mechanism of the spatiotemporal attention mechanism is used to filter useless information, and different weights are assigned to different visit locations, so as to select representative visit location information that can describe the user's interests.

首先计算注意力分数a,然后使用softmax函数进行归一化计算注意力权重得分α,计算公式如下:First, the attention score a is calculated, and then the softmax function is used to normalize and calculate the attention weight score α. The calculation formula is as follows:

α(ui)=softmax(a(A(ui),EL)) (12)α(ui )=softmax(a(A(ui ),EL )) (12)

通过该权重得分可以对用户兴趣进行预测,通过两种指标即准确率和召回率。ACC@K是常用的衡量预测效果好坏的指标,对于用户预测结果,如果用户访问的下一个地点出现在预测列表中,则认为预测正确,其值为1,否则为0。ACC@K的值是取所有测试实例的平均值,值越高表示模型的预测效果越好。R@k是衡量预测列表中结果排名的标准,其考虑了预测精准度和相对顺序,如果用户下一条访问记录在预测列表的位置越靠前,R@k的取值就会越大。The weighted score can be used to predict user interests through two indicators, namely accuracy and recall. ACC@K is a commonly used indicator to measure the quality of prediction. For user prediction results, if the next location visited by the user appears in the prediction list, the prediction is considered correct and its value is 1, otherwise it is 0. The value of ACC@K is the average of all test instances. The higher the value, the better the prediction effect of the model. R@k is a standard for measuring the ranking of results in the prediction list, which takes into account the prediction accuracy and relative order. The higher the position of the user's next visit record in the prediction list, the larger the value of R@k will be.

实施例2Example 2

基于Foursquare、Gowalla和Brightkite三个公开的真实数据集进行仿真实验。Foursquare原始数据集由2153469个用户从2012年4月到2014年1月之间的1021966条用户访问记录组成;Gowalla中用户访问记录时间涉及从2009年2月到2010年10月,由18737个用户和1278274条访问记录组成;Brightkite原始数据集则由58228个用户从2008年4月到2010年10月的4491143条用户访问记录组成。实验数据集为从原始数据集中导出的子集,其中每名用户的访问记录序列长度不小于20,时间跨度涉及的范围不少于10天,具体数据统计如下表:The simulation experiments are conducted based on three public real data sets: Foursquare, Gowalla and Brightkite. The original Foursquare data set consists of 1,021,966 user access records from 2,153,469 users from April 2012 to January 2014; the user access records in Gowalla cover the period from February 2009 to October 2010, consisting of 18,737 users and 1,278,274 access records; the original Brightkite data set consists of 4,491,143 user access records from 58,228 users from April 2008 to October 2010. The experimental data set is a subset derived from the original data set, in which the length of the access record sequence of each user is not less than 20, and the time span involved is not less than 10 days. The specific data statistics are shown in the following table:

表1实验数据集基本信息Table 1 Basic information of experimental dataset

具体按照以下步骤实施:Follow these steps to implement it:

步骤1、对获取到的用户信息和时空信息进行预处理。具体为:Step 1: Preprocess the acquired user information and spatiotemporal information. Specifically:

首先在Foursquare和Gowalla公开数据集上进行分析,分析用户历史访问记录中蕴含的时空信息特点。通过对Foursquare和Gowalla数据集中用户的历史访问数据分析,发现用户在不同时间不同环境下可能会呈现出不同的访问偏好,在大多情况下用户的固定访问模式会随时间而变化。First, we analyze the spatiotemporal information characteristics contained in the user's historical access records on the Foursquare and Gowalla public data sets. By analyzing the historical access data of users in the Foursquare and Gowalla data sets, we find that users may have different access preferences at different times and in different environments. In most cases, users' fixed access patterns will change over time.

步骤2、通过用户信息和时空信息获取用户访问记录之间的时间间隔和空间间隔,进而得到用户访问记录的时空关系矩阵。具体为:Step 2: Obtain the time interval and space interval between user access records through user information and spatiotemporal information, and then obtain the spatiotemporal relationship matrix of user access records. Specifically:

时空间隔嵌入通过设置2个关系矩阵WT和WL对用户的时间信息和空间信息进行建模,用于捕获用户访问记录之间的时间间隔和空间间隔对用户兴趣的影响,在训练时,将时间间隔和空间地理距离建模为两个访问地点之间明确的时空关系,用户相邻两次访问记录之间的时间间隔由其历史访问记录与临近访问记录的时间差得到,表示为|ti-tj|,用户访问记录的空间间隔/>由用户历史访问记录与相邻的下一个访问记录的距离相减得到,空间间隔/>利用Haversine距离函数进行计算,其公式如下所示:The time-space embedding models the user's time and space information by setting two relationship matrices WT and WL to capture the impact of the time interval and space interval between user visit records on user interests. During training, the time interval and spatial geographic distance are modeled as a clear time-space relationship between two visit locations. The time interval between two adjacent visit records of a user is The time difference between the historical access record and the recent access record is obtained, expressed as |ti -tj |, and the spatial interval of the user's access record/> The spatial interval is obtained by subtracting the distance between the user's historical access record and the next adjacent access record. The Haversine distance function is used for calculation, and the formula is as follows:

la=latj-lati (1)la=latj -lati (1)

lb=lonj-loni (2)lb=lonj -loni (2)

其中,lati,loni,latj与lonj分别为第i次和第j次访问记录的经纬度值,la和lb分别为经度差和纬度差,r为地球的半径,为空间间隔差值。Where, lati , loni , latj and lonj are the longitude and latitude values of the i-th and j-th access records respectively, la and lb are the longitude difference and latitude difference respectively, r is the radius of the earth, is the spatial interval difference.

则用户访问记录的时间关系矩阵WT和用户访问记录的空间关系矩阵WL,如公式(4)所示:Then the time relationship matrixWT of user access records and the spatial relationship matrixWL of user access records are as shown in formula (4):

步骤3、采用时空注意力机制来对时间关系和空间关系矩阵进行嵌入表示,得到融合时空特征的用户轨迹表示序列。具体为:Step 3: Use the spatiotemporal attention mechanism to embed the temporal relationship and spatial relationship matrices to obtain a user trajectory representation sequence that integrates spatiotemporal features. Specifically:

在计算时空间隔真实差值的基础上,将时间间隔与空间间隔/>分别与以一小时和一千米为基本单元的单位嵌入向量et和el相乘得到时空信息的嵌入表示E(WT)和E(WL),如公式(5)所示:Based on the calculation of the true difference of the time-space interval, the time interval With space interval /> The embedded representations of spatiotemporal information E(WT ) and E(WL ) are obtained by multiplying them with the unit embedding vectorset andel with one hour and one kilometer as the basic units, respectively, as shown in formula (5):

式(5)中,分别如公式(6)和公式(7)所示:In formula (5), As shown in formula (6) and formula (7) respectively:

给定用户非零填充的信息嵌入表示E(ui),通过线性转换分别获得查询矩阵Wq、键矩阵Wk和值矩阵Wv,进而将Wq、Wk、Wv输入到一个注意力层,采用缩放点积注意力评分函数计算注意力分布权重,得到一个融合时空特征的用户轨迹表示序列,如公式(8)所示:Given the user’s non-zero filled information embedding representation E(ui ), the query matrixWq , key matrixWk and value matrixWv are obtained through linear transformation respectively. ThenWq ,Wk andWv are input into an attention layer, and the attention distribution weight is calculated using the scaled dot product attention scoring function to obtain a user trajectory representation sequence that integrates spatiotemporal features, as shown in formula (8):

A(ui)=Att(E(ui)Wq,E(ui)Wk,E(ui)Wv,E(WiT),E(WiL)) (8)A(ui )=Att(E(ui )Wq ,E(ui )Wk ,E(ui )Wv ,E(WiT ),E(WiL )) (8)

式(8)中,In formula (8),

Att(q,k,v,WiT,WiL)=softmax(s(q,WiT,WiL))v (9)Att(q,k,v,WiT,WiL )=softmax(s(q,WiT,WiL)) v (9)

式(9)中,Att表示缩放点积注意力,q表示查询,k表示键,v表示值,s表示缩放点积注意力分布函数,直观地说,注意力层计算所有值的加权和,尺度因子是为了避免内积的值过大,特别是当维数较高时。In formula (9), Att represents the scaled dot product attention, q represents the query, k represents the key, v represents the value, and s represents the scaled dot product attention distribution function. Intuitively, the attention layer calculates the weighted sum of all values, and the scale factor This is to avoid the inner product value being too large, especially when the dimension is high.

在训练过程中,还需要考虑预测的因果关系,在预测第t+1项时,模型应该只考虑前t项。然而,时间感知自注意层的第t个输出包含了所有的输入信息,这使得模型具有不确定性。因此,通过阻止qi和kj(j>i)之间的所有联系来修改注意力。During training, the causal relationship of predictions also needs to be considered. When predicting the t+1th item, the model should only consider the first t items. However, the tth output of the time-aware self-attention layer contains all the input information, which makes the model uncertain. Therefore, the attention is modified by blocking all connections between qi and kj (j>i).

步骤4、通过全连接层来实现对用户兴趣的预测。具体为:Step 4: Use the fully connected layer to predict user interests. Specifically:

在融合时空间隔考虑用户历史访问记录内部时空相关性更新轨迹表示A(ui)的基础上,根据给定的访问地点集合L的嵌入表示EL={El1,El2,...,ElL},通过时空注意力机制自顶向下的选择机制来过滤无用的信息,为不同的访问地点分配不同的权重,从而挑选可以描述用户兴趣的代表性访问地点信息。On the basis of updating the trajectory representation A(ui ) by integrating the spatiotemporal interval and considering the internal spatiotemporal correlation of the user's historical visit records, according to the embedded representationEL ={El1 ,El2 ,...,ElL } of the given visited location set L, a top-down selection mechanism of the spatiotemporal attention mechanism is used to filter out useless information, assign different weights to different visited locations, and thus select representative visited location information that can describe the user's interests.

首先计算注意力分数a,然后使用softmax函数进行归一化计算注意力权重得分α,计算公式如下:First, the attention score a is calculated, and then the softmax function is used to normalize and calculate the attention weight score α. The calculation formula is as follows:

α(ui)=soft max(a(A(ui),EL)) (12)α(ui )=soft max(a(A(ui ),EL )) (12)

为了定量分析和评估本发明所提方法的预测性能,本发明在Foursquare、Gowalla和Brightkite数据集上进行了仿真实验。通过两种常用的衡量指标,即准确率(Accuracy@K,简称ACC@K)和召回率(Recall@k,简称R@k)。ACC@K是常用的衡量预测效果好坏的指标,对于用户预测结果,如果用户访问的下一个地点出现在预测列表中,则认为预测正确,其值为1,否则为0。ACC@K的值是取所有测试实例的平均值,值越高表示模型的预测效果越好。R@k是衡量预测列表中结果排名的标准,其考虑了预测精准度和相对顺序,如果用户下一条访问记录在预测列表的位置越靠前,R@k的取值就会越大。In order to quantitatively analyze and evaluate the prediction performance of the method proposed in the present invention, the present invention has carried out simulation experiments on Foursquare, Gowalla and Brightkite data sets. Through two commonly used measurement indicators, namely, accuracy (Accuracy@K, referred to as ACC@K) and recall (Recall@k, referred to as R@k). ACC@K is a commonly used indicator to measure the quality of prediction. For the user prediction result, if the next place visited by the user appears in the prediction list, the prediction is considered correct, and its value is 1, otherwise it is 0. The value of ACC@K is the average value of all test instances. The higher the value, the better the prediction effect of the model. R@k is a standard for measuring the ranking of results in the prediction list, which takes into account the prediction accuracy and relative order. If the user's next visit record is closer to the front in the prediction list, the value of R@k will be larger.

实施例3Example 3

即实施例2仿真实验结果,对本发明所提方法与现有的PRME-G、FPMC以及Distance2Pre3种方法进行比较,证明其相比于其他方法具有更好的预测性能。其中,PRME-G利用度量嵌入的方法对用户序列信息建模,将空间距离作为权重控制用户的距离偏好;FPMC利用个性化马尔科夫链对用户签到序列建模,结合用户的地理位置限制进行兴趣预测。为了保证实验数据的准确和客观,将每个模型在同一训练和测试数据集上分别运行5次,求得ACC@5、ACC@10、R@5以及R@10作为模型评价指标,最终各模型在Foursquare、Gowalla和Brightkite数据集上所得到的实验结果对比分别如表2、表3和表4所示。That is, the simulation experiment results of Example 2 compare the proposed method with the existing PRME-G, FPMC and Distance2Pre3 methods, proving that it has better prediction performance than other methods. Among them, PRME-G uses the metric embedding method to model the user sequence information, and uses the spatial distance as a weight to control the user's distance preference; FPMC uses a personalized Markov chain to model the user's check-in sequence, and predicts the user's interest in combination with the user's geographical location restrictions. In order to ensure the accuracy and objectivity of the experimental data, each model is run 5 times on the same training and test data sets, and ACC@5, ACC@10, R@5 and R@10 are obtained as model evaluation indicators. Finally, the experimental results of each model on the Foursquare, Gowalla and Brightkite data sets are compared as shown in Table 2, Table 3 and Table 4 respectively.

表2不同模型在Foursquare数据集上的实验结果Table 2 Experimental results of different models on Foursquare dataset

表3不同模型在Gowalla数据集上的实验结果Table 3 Experimental results of different models on the Gowalla dataset

表4不同模型在Brightkite数据集上的实验结果Table 4 Experimental results of different models on the Brightkite dataset

从上述三张表可以看出,对比所有基准方法,在三组数据集上的实验结果表明,结合了用户时空偏好和序列信息的Distance2Pre方法为效果最好的基准方法。同时,通过本发明方法与其他方法总体比较,体现了本发明方法的优势,说明充分利用时间信息、空间信息进行用户兴趣预测的重要性。在测试集上的平均效果表明,本发明所提的基于时空注意力机制的用户兴趣预测方法本发明方法在三组数据集上对应的ACC@5、R@5、ACC@10以及R@10评价指标相比于最好的基准方法Distance2Pre效果分别相对提升了1.85%、0.91%、2.5%、2.03%。It can be seen from the above three tables that, compared with all the benchmark methods, the experimental results on the three data sets show that the Distance2Pre method that combines user spatiotemporal preferences and sequence information is the best benchmark method. At the same time, the overall comparison of the method of the present invention with other methods reflects the advantages of the method of the present invention, and illustrates the importance of making full use of time information and spatial information to predict user interests. The average effect on the test set shows that the user interest prediction method based on the spatiotemporal attention mechanism proposed by the present invention has a relative improvement of 1.85%, 0.91%, 2.5%, and 2.03% in the ACC@5, R@5, ACC@10, and R@10 evaluation indicators on the three data sets compared with the best benchmark method Distance2Pre.

由于3个数据集上时间间隔wt的取值对于模型的表现有很微弱的影响,因此首先研究长短时间间隔wt和远近空间距离间隔wl对用户下一个感兴趣访问地点的影响。参数wt和wl的取值之间相互关联,找到最好的参数值需要大量的计算。随机设置一些wt={6,12,18,24,30}h和wl={25,50,75,100,125}km的参数组合,当wt=18h,wl=125km时,模型在3个数据集上表现优越。为了进一步了解较好的参数值,首先固定wl=125km,找出最好的wt取值,实验结果如表5所示。找到最优的wt参数值后,再固定wt的值,之后找出最优wl参数值,实验结果如表6所示。最终得到的较优的wt和wl参数将作为三个数据集上最终的实验参数设置。实验中,将ACC@10和R@1作为评价指标。Since the value of the time interval wt on the three data sets has a weak effect on the performance of the model, we first study the impact of long and short time intervals wt and long and short spatial distance intervals wl on the user's next interesting place to visit. The values of the parameters wt and wl are related to each other, and finding the best parameter values requires a lot of calculations. Randomly set some parameter combinations of wt = {6, 12, 18, 24, 30}h and wl = {25, 50, 75, 100, 125}km. When wt = 18h and wl = 125km, the model performs well on the three data sets. In order to further understand the better parameter values, we first fix wl = 125km and find the best wt value. The experimental results are shown in Table 5. After finding the optimal wt parameter value, we fix the value of wt again, and then find the optimal wl parameter value. The experimental results are shown in Table 6. The better wt and wl parameters finally obtained will be used as the final experimental parameter settings on the three data sets. In the experiment, ACC@10 and R@1 are used as evaluation indicators.

表5时间间隔wt对不同数据集影响Table 5 The impact of time intervalwt on different data sets

表6空间间隔wl对不同数据集影响Table 6 Effect of spatial interval wl on different data sets

从上述两张表的实验结果可以看出:在Foursquare数据集上,当wt=24h,wl=100km时模型表现较好;在Gowalla数据集上,当wt=30h,wl=75km时模型表现较好;当wt=18h,wl=100km时,模型在Brightkite数据集上表现最好。From the experimental results in the above two tables, we can see that: on the Foursquare dataset, the model performs better when wt = 24h, wl = 100km; on the Gowalla dataset, the model performs better when wt = 30h, wl = 75km; when wt = 18h, wl = 100km, the model performs best on the Brightkite dataset.

通过上述方式,本发明的基于时空注意力机制的用户兴趣预测方法,通过双层时空注意力考虑时空间隔差异对用户兴趣所造成的影响,第一层自注意力机制融合时空间隔自动聚合各种输入(时间、空间信息、时间间隔以及空间距离)的相关性,考虑用户历史访问记录内部的时空信息之间的交互作用,第二层注意力机制从访问地点集合中匹配代表性的访问地点信息。为验证本发明所提方法的有效性,在Foursquare、Gowalla和Brightkite三组数据集上进行实验,结果表明,所提方法能够有效提升用户兴趣预测准确度,预测的准确度相比于最好的基准方法Distance2Pre平均提高了2.18%。In the above manner, the user interest prediction method based on the spatiotemporal attention mechanism of the present invention considers the impact of spatiotemporal interval differences on user interests through double-layer spatiotemporal attention. The first layer of self-attention mechanism integrates the spatiotemporal interval to automatically aggregate the correlation of various inputs (time, spatial information, time interval and spatial distance), considers the interaction between spatiotemporal information within the user's historical visit records, and the second layer of attention mechanism matches representative visit location information from the visit location set. In order to verify the effectiveness of the method proposed in the present invention, experiments were conducted on three sets of data sets: Foursquare, Gowalla and Brightkite. The results show that the proposed method can effectively improve the accuracy of user interest prediction, and the prediction accuracy is improved by an average of 2.18% compared to the best benchmark method Distance2Pre.

Claims (1)

step 2, acquiring a time interval and a space interval between user access records based on the user information and the space-time information obtained in the step 1, and further respectively obtaining a time relationship and a space relationship matrix of the user access records; the step 2 is specifically as follows: modeling the matrix obtained by preprocessing in the step 1, setting two relation matrices WT and WL, respectively storing time information and space information of user access records, modeling a time interval and a space geographic distance as a definite time-space relation between two access places, and modeling the time interval between two adjacent access records of the userDerived from the time difference between the user history access record and the next adjacent access record, denoted as |ti-tj |; spatial interval of user access records/>From the subtraction of the distance between the user history access record and the next adjacent access record, the space interval/>Calculation was performed using HAVERSINE distance functions as shown in equation (3):
CN202310635734.6A2023-05-312023-05-31User interest prediction method based on space-time attention mechanismActiveCN116680486B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202310635734.6ACN116680486B (en)2023-05-312023-05-31User interest prediction method based on space-time attention mechanism

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202310635734.6ACN116680486B (en)2023-05-312023-05-31User interest prediction method based on space-time attention mechanism

Publications (2)

Publication NumberPublication Date
CN116680486A CN116680486A (en)2023-09-01
CN116680486Btrue CN116680486B (en)2024-06-14

Family

ID=87784803

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202310635734.6AActiveCN116680486B (en)2023-05-312023-05-31User interest prediction method based on space-time attention mechanism

Country Status (1)

CountryLink
CN (1)CN116680486B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN112199609A (en)*2020-11-172021-01-08东北大学 Spatiotemporal semantic interval-aware POI recommendation system and method under self-attention

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN112925893B (en)*2021-03-232023-09-15苏州大学Conversational interest point recommendation method and device, electronic equipment and storage medium
CN114741590B (en)*2022-03-282024-07-02西北大学Multi-interest recommendation method based on self-attention routing and Transformer

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN112199609A (en)*2020-11-172021-01-08东北大学 Spatiotemporal semantic interval-aware POI recommendation system and method under self-attention

Also Published As

Publication numberPublication date
CN116680486A (en)2023-09-01

Similar Documents

PublicationPublication DateTitle
Jiao et al.A novel next new point-of-interest recommendation system based on simulated user travel decision-making process
CN110020862B (en) A business risk assessment method, apparatus and computer-readable storage medium
CN111091196B (en)Passenger flow data determination method and device, computer equipment and storage medium
CN109062962A (en)A kind of gating cycle neural network point of interest recommended method merging Weather information
CN113065911A (en) Recommended information generation method, device, storage medium and electronic device
CN115510333B (en)POI prediction method based on space-time perception and combining local and global preference
CN113139140A (en)Tourist attraction recommendation method based on space-time perception GRU and combined with user relation preference
CN115982468A (en) A Point-of-Interest Recommendation Method Combining User Periodic Preferences and Short-term Interests
CN110704741A (en)Interest point prediction method based on space-time point process
CN119006145B (en) Financial platform risk prediction method and system based on multi-source user behavior data
CN111241425A (en)POI recommendation method based on hierarchical attention mechanism
CN114896481A (en)Interest point recommendation method based on improved LSTM and position jump
CN116991908A (en)Interest point recommendation method based on multivariable Hawkes space-time point process embedded attention
CN112650949B (en)Regional POI (point of interest) demand identification method based on multi-source feature fusion collaborative filtering
CN113837383A (en)Model training method and device, electronic equipment and storage medium
CN117609631A (en) A fine-grained point of interest recommendation method and device based on a few-sample knowledge graph
CN117056601A (en)Music recommendation method and system based on hypergraph
CN113282842A (en)Travel purpose identification method based on travel survey of smart phone and artificial neural network particle swarm optimization algorithm
Ragapriya et al.Machine learning based house price prediction using modified extreme boosting
CN115905893A (en)Resource numerical value prediction method, device, computer equipment and storage medium
CN108364098A (en)A kind of weather characteristics register on user the measure of influence
CN115630221A (en)Terminal application interface display data processing method and device and computer equipment
CN116680486B (en)User interest prediction method based on space-time attention mechanism
CN111833171B (en)Abnormal operation detection and model training method, device and readable storage medium
CN118941322A (en) Supply chain demand forecasting method, device, equipment, storage medium and program product

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant
TR01Transfer of patent right

Effective date of registration:20241011

Address after:Room 1404, Building B, Northwest Guojin Center, Fengcheng Eighth Road, Xi'an Economic and Technological Development Zone, Shaanxi Province 710018

Patentee after:Xi'an Qingtian Zhanchuang Network Technology Co.,Ltd.

Country or region after:China

Address before:710048 Shaanxi province Xi'an Beilin District Jinhua Road No. 19

Patentee before:XI'AN POLYTECHNIC University

Country or region before:China

TR01Transfer of patent right
TR01Transfer of patent right

Effective date of registration:20250423

Address after:518000 Hualian City Panorama, Zone 27, Dalang Community, Xin'an Street, Bao'an District, Shenzhen City, Guangdong Province 621, Building E, F, G, Building G

Patentee after:Shenzhen Xinban Network Technology Co.,Ltd.

Country or region after:China

Address before:Room 1404, Building B, Northwest Guojin Center, Fengcheng Eighth Road, Xi'an Economic and Technological Development Zone, Shaanxi Province 710018

Patentee before:Xi'an Qingtian Zhanchuang Network Technology Co.,Ltd.

Country or region before:China

TR01Transfer of patent right

[8]ページ先頭

©2009-2025 Movatter.jp